# relies on python and kpsewhich (no shell command is used).
#
+from __future__ import print_function
import os, sys, re
cls_stylefile = 'clsFiles.lst'
# 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 | bbx| cbx ]
+ print('''Usage: TeXFiles.py [-version | cls | sty | bst | bib | bbx| cbx ]
Default is without any Parameters,
- so that all files will be created'''
+ so that all files will be created''')
sys.exit(0)
else:
types = sys.argv[1:]
for type in types:
if type not in ['cls', 'sty', 'bst', 'bib', 'bbx', 'cbx']:
- print 'ERROR: unknown type', type
+ print('ERROR: unknown type', type)
sys.exit(1)
else:
# if no parameter is specified, assume all
# process each file type
for type in types:
- print "Indexing files of type", type
+ print("Indexing files of type", type)
if type == 'cls':
outfile = cls_stylefile
kpsetype = '.tex'
if not os.path.isdir(dir):
continue
# walk down the file hierarchy
- for root,path,files in os.walk(dir):
+ visited = set()
+ for root,dirs,files in os.walk(dir, followlinks=True):
+ # prevent inifinite recursion
+ recurse = []
+ for dir in dirs:
+ dirname = os.path.join(root, dir)
+ dirname = os.path.realpath(dirname)
+ dirname = os.path.normcase(dirname)
+ if dirname not in visited:
+ visited.add(dirname)
+ recurse.append(dir)
+ dirs[:] = recurse
# 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
+ print(root.replace('\\', '/') + '/' + file, file=out)
out.close()