]> git.lyx.org Git - lyx.git/blob - development/tools/updatedocs.py
d2c7fe8c04cbdc4eb9650afc1feb40b685b1ecf1
[lyx.git] / development / tools / updatedocs.py
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # file updatedocs.py
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7
8 # author Georg Baum
9
10 # Full author contact details are available in file CREDITS
11
12 # This script converts documentation .lyx files to current format
13 # The old files are backuped with extension ".old"
14
15
16 import os, re, string, sys, subprocess, shutil
17
18
19 def convertdir(docdir, prefix, lyx2lyx):
20     olddir = os.getcwd()
21     os.chdir(docdir)
22     for i in os.listdir("."):
23         if os.path.isdir(i):
24             subdir = os.path.join(docdir, i)
25             subprefix = os.path.join(prefix, i)
26             convertdir(subdir, subprefix, lyx2lyx)
27             continue
28         (base, ext) = os.path.splitext(i)
29         if ext != ".lyx":
30             continue
31         old = i + ".old"
32         shutil.copy(i, old)
33         if sys.executable and sys.executable != '':
34             cmd = [sys.executable, lyx2lyx, old, '-o', i]
35         else:
36             # assume that python is in the path
37             cmd = [lyx2lyx, old, '-o', i]
38         sys.stderr.write('Converting %s\n' % os.path.join(prefix, i))
39         subprocess.call(cmd)
40     os.chdir(olddir)
41
42
43 def main(argv):
44
45     toolsdir = os.path.dirname(argv[0])
46     docdir = os.path.abspath(os.path.join(toolsdir, '../../lib/doc'))
47     lyx2lyx = os.path.abspath(os.path.join(toolsdir, "../../lib/lyx2lyx/lyx2lyx"))
48     convertdir(docdir, '', lyx2lyx)
49
50     return 0
51
52
53 if __name__ == "__main__":
54     main(sys.argv)