mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
Convert updatelayouts.sh to python
This makes the script usable on windows and speeds it up by an order of magnitude, since no new process needs to be forked for each layout file. It also does not conevrt .old files again.
This commit is contained in:
parent
e7a8f63e1b
commit
f110ef2f41
38
development/tools/updatelayouts.py
Normal file
38
development/tools/updatelayouts.py
Normal file
@ -0,0 +1,38 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# file updatelayouts.py
|
||||
# This file is part of LyX, the document processor.
|
||||
# Licence details can be found in the file COPYING.
|
||||
|
||||
# author Georg Baum
|
||||
|
||||
# Full author contact details are available in file CREDITS
|
||||
|
||||
# This script converts all layout files to current format
|
||||
# The old files are backuped with extension ".old"
|
||||
|
||||
|
||||
import os, re, string, sys, subprocess, tempfile, shutil
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), "../../lib/scripts"))
|
||||
from layout2layout import main as layout2layout
|
||||
|
||||
def main(argv):
|
||||
|
||||
toolsdir = os.path.dirname(argv[0])
|
||||
layoutdir = os.path.join(toolsdir, '../../lib/layouts')
|
||||
os.chdir(layoutdir)
|
||||
for i in os.listdir("."):
|
||||
(base, ext) = os.path.splitext(i)
|
||||
if ext == ".old":
|
||||
continue
|
||||
args = ["layout2layout", i + ".old", i]
|
||||
shutil.copy(args[2], args[1])
|
||||
layout2layout(args)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# find out where we are relative to the program directory
|
||||
curdir=$(pwd);
|
||||
progloc=$0;
|
||||
pathto=${progloc%/*};
|
||||
# get us into development/tools
|
||||
if [ "$progloc" != "$pathto" ]; then
|
||||
if ! cd $pathto; then
|
||||
echo "Couldn't get to development/tools!";
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! cd ../../lib/layouts/; then
|
||||
echo "Couldn't get to lib/layouts!";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
for i in *; do
|
||||
cp $i $i.old;
|
||||
python ../scripts/layout2layout.py <$i.old >$i;
|
||||
done
|
@ -175,7 +175,7 @@ import os, re, string, sys
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
# You might also want to consider running the
|
||||
# development/tools/updatelayouts.sh script to update all
|
||||
# development/tools/updatelayouts.py script to update all
|
||||
# layout files to the new format.
|
||||
|
||||
currentFormat = 51
|
||||
|
@ -58,9 +58,8 @@ namespace lyx {
|
||||
// LayoutFile.cpp. Additions will never do so, but syntax changes
|
||||
// could. See LayoutFileList::addEmptyClass() and, especially, the
|
||||
// definition of the layoutpost string.
|
||||
// You should also run (or ask someone who has bash to run) the
|
||||
// development/tools/updatelayouts.sh script, to update the format of
|
||||
// all of our layout files.
|
||||
// You should also run the development/tools/updatelayouts.py script,
|
||||
// to update the format of all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 51; //spitz: add ToggleIndent tag
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user