2 # -*- coding: utf-8 -*-
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
10 # Full author contact details are available in file CREDITS
12 # This script converts documentation .lyx files to current format
13 # The old files are backuped with extension ".old"
16 import os, re, string, sys, subprocess, shutil
19 def convertdir(docdir, prefix, lyx2lyx, systemlyxdir):
22 for i in os.listdir("."):
25 subdir = os.path.join(docdir, i)
26 subprefix = os.path.join(prefix, i)
27 convertdir(subdir, subprefix, lyx2lyx, systemlyxdir)
29 (base, ext) = os.path.splitext(i)
34 if sys.executable and sys.executable != '':
35 cmd = [sys.executable, lyx2lyx, old, '-s', systemlyxdir, '-o', i]
37 # assume that python is in the path
38 cmd = [lyx2lyx, old, '-s', systemlyxdir, '-o', i]
39 sys.stderr.write('Converting %s\n' % os.path.join(prefix, i))
46 toolsdir = os.path.dirname(argv[0])
47 lyx2lyx = os.path.abspath(os.path.join(toolsdir, "../../lib/lyx2lyx/lyx2lyx"))
48 systemlyxdir = os.path.abspath(os.path.join(toolsdir, "../../lib"))
49 docpaths = ['../../lib/doc', '../../lib/examples', '../../lib/templates', '../../development/MacOSX/ReadMe']
50 for docpath in docpaths:
51 docdir = os.path.abspath(os.path.join(toolsdir, docpath))
52 convertdir(docdir, '', lyx2lyx, systemlyxdir)
57 if __name__ == "__main__":