File: updatelayouts.py

package info (click to toggle)
lyx 2.5.0~RC2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 138,212 kB
  • sloc: cpp: 244,227; ansic: 106,398; xml: 72,791; python: 39,384; sh: 7,666; makefile: 6,586; pascal: 2,143; perl: 2,101; objc: 1,084; tcl: 163; sed: 16
file content (44 lines) | stat: -rwxr-xr-x 1,247 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/python3
# -*- 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])
    dirs = []
    dirs.append(os.path.join(toolsdir, '../../lib/layouts'))
    dirs.append(os.path.join(toolsdir, '../../lib/citeengines'))
    for directory in dirs:
        oldcwd = os.getcwd()
        os.chdir(directory)
        for i in os.listdir("."):
            (base, ext) = os.path.splitext(i)
            # Skip files like lib/layouts/TODO.txt
            if ext in [ ".old", ".txt" ]:
                continue
            args = ["layout2layout", i + ".old", i]
            shutil.copy(args[2], args[1])
            layout2layout(args)
        os.chdir(oldcwd)

    return 0


if __name__ == "__main__":
    main(sys.argv)