This has just come up on the users list: Running Reconfigure does update the
documernt class list from the available layouts, but it does not update the
lists of bst files, cls files etc. This is not very userfriendly IMO, so I
propose the attached patch.
The changes to TeXFiles.py are only refactoring (apart from correcting one
typo), so that it can be imported in configure.py.
OK to go in?
Georg
Log:
* lib/scripts/TeXFiles.py: Put everything in new function
createTeXFiles
* lib/configure.py: import TeXFiles.py and call createTeXFiles
Index: lib/scripts/TeXFiles.py
===================================================================
--- lib/scripts/TeXFiles.py (Revision 14417)
+++ lib/scripts/TeXFiles.py (Arbeitskopie)
@@ -35,11 +35,6 @@
import os, sys, re
-cls_stylefile = 'clsFiles.lst'
-sty_stylefile = 'styFiles.lst'
-bst_stylefile = 'bstFiles.lst'
-bib_files = 'bibFiles.lst'
-
def cmdOutput(cmd):
'''utility function: run a command and get its output as a string
cmd: command to run
@@ -49,69 +44,78 @@ def cmdOutput(cmd):
fout.close()
return output
-# processing command line options
-if len(sys.argv) > 1:
- if sys.argv[1] in ['--help', '-help']:
- print '''Usage: TeXFiles.py [-version | cls | sty | bst | bib ]
- Default is without any Parameters,
- so that all files will be created'''
- sye.exit(0)
- else:
- types = sys.argv[1:]
- for type in types:
- if type not in ['cls', 'sty', 'bst', 'bib']:
- print 'ERROR: unknown type', type
- sys.exit(1)
-else:
- # if no parameter is specified, assume all
- types = ['cls', 'sty', 'bst', 'bib']
-
-#
-# MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
-# directories in path lists whereas Unix uses `:'. Make an exception for
-# Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
-# Create a variable that holds the right character to be used by the scripts.
-path_sep = os.pathsep
-if sys.platform == 'cygwin':
- # MikTeX's kpsewhich says "kpathsea emulation version x.x.x", whereas
- # teTeX's simply "kpathsea version x.x.x".
- if 'emulation' in cmdOutput('kpsewhich --version'):
- path_sep = ';'
+def createTeXFiles(argv):
+ cls_stylefile = 'clsFiles.lst'
+ sty_stylefile = 'styFiles.lst'
+ bst_stylefile = 'bstFiles.lst'
+ bib_files = 'bibFiles.lst'
+
+ # processing command line options
+ if len(argv) > 1:
+ if argv[1] in ['--help', '-help']:
+ print '''Usage: TeXFiles.py [-version | cls | sty | bst | bib ]
+ Default is without any Parameters,
+ so that all files will be created'''
+ sys.exit(0)
+ else:
+ types = argv[1:]
+ for type in types:
+ if type not in ['cls', 'sty', 'bst', 'bib']:
+ print 'ERROR: unknown type', type
+ sys.exit(1)
else:
- path_sep = ':'
+ # if no parameter is specified, assume all
+ types = ['cls', 'sty', 'bst', 'bib']
-# process each file type
-for type in types:
- print "Indexing files of type", type
- if type == 'cls':
- outfile = cls_stylefile
- kpsetype = '.tex'
- elif type == 'sty':
- outfile = sty_stylefile
- kpsetype = '.tex'
- elif type == 'bst':
- outfile = bst_stylefile
- kpsetype = '.bst'
- elif type == 'bib':
- outfile = bib_files
- kpsetype = '.bib'
-
- dirs = cmdOutput('kpsewhich --show-path=' + kpsetype).replace('!!', '').strip()
- # remove excessive //
- dirs = re.sub('//+', '/', dirs)
+ #
+ # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
+ # directories in path lists whereas Unix uses `:'. Make an exception for
+ # Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
+ # Create a variable that holds the right character to be used by the scripts.
+ path_sep = os.pathsep
+ if sys.platform == 'cygwin':
+ # MikTeX's kpsewhich says "kpathsea emulation version x.x.x", whereas
+ # teTeX's simply "kpathsea version x.x.x".
+ if 'emulation' in cmdOutput('kpsewhich --version'):
+ path_sep = ';'
+ else:
+ path_sep = ':'
+
+ # process each file type
+ for type in types:
+ print "Indexing files of type", type
+ if type == 'cls':
+ outfile = cls_stylefile
+ kpsetype = '.tex'
+ elif type == 'sty':
+ outfile = sty_stylefile
+ kpsetype = '.tex'
+ elif type == 'bst':
+ outfile = bst_stylefile
+ kpsetype = '.bst'
+ elif type == 'bib':
+ outfile = bib_files
+ kpsetype = '.bib'
+
+ dirs = cmdOutput('kpsewhich --show-path=' + kpsetype).replace('!!', '').strip()
+ # remove excessive //
+ dirs = re.sub('//+', '/', dirs)
- file_ext = '.' + type
- out = open(outfile, 'w')
- for dir in dirs.split(path_sep):
- # for each valid directory
- if not os.path.isdir(dir):
- continue
- # walk down the file hierarchy
- for root,path,files in os.walk(dir):
- # check file type
- for file in files:
- if len(file) > 4 and file[-4:] == file_ext:
- # force the use of / since miktex uses / even under windows
- print >> out, root.replace('\\', '/') + '/' + file
- out.close()
+ file_ext = '.' + type
+ out = open(outfile, 'w')
+ for dir in dirs.split(path_sep):
+ # for each valid directory
+ if not os.path.isdir(dir):
+ continue
+ # walk down the file hierarchy
+ for root,path,files in os.walk(dir):
+ # check file type
+ for file in files:
+ if len(file) > 4 and file[-4:] == file_ext:
+ # force the use of / since miktex uses / even under windows
+ print >> out, root.replace('\\', '/') + '/' + file
+ out.close()
+
+if __name__ == "__main__":
+ createTeXFiles(sys.argv)
Index: lib/configure.py
===================================================================
--- lib/configure.py (Revision 14417)
+++ lib/configure.py (Arbeitskopie)
@@ -714,3 +714,7 @@ Options:
checkLatexConfig( lyx_check_config and LATEX != '', bool_docbook, bool_linuxdoc)
createLaTeXConfig()
removeTempFiles()
+ # Finally create lists of bib-, bst-, sty and cls files
+ sys.path.insert(0, os.path.join(srcdir, 'scripts'))
+ import TeXFiles
+ TeXFiles.createTeXFiles(['configure.py'])