- print 'creating doc/LaTeXConfig.lyx'
- #
- # This is originally done by sed, using a
- # tex-generated file chkconfig.sed
- ##sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in
- ## >doc/LaTeXConfig.lyx
- # Now, we have to do it by hand (python).
- #
- # add to chekconfig.sed
- writeToFile('chkconfig.sed', '''s!@chk_linuxdoc@!%s!g
-s!@chk_docbook@!%s!g
- ''' % (chk_linuxdoc, chk_docbook) , append=True)
- # process this sed file!!!!
- lyxin = open( os.path.join(srcdir, 'doc', 'LaTeXConfig.lyx.in')).readlines()
- # get the rules
- p = re.compile(r's!(.*)!(.*)!g')
- # process each sed replace.
- for sed in open('chkconfig.sed').readlines():
- if sed.strip() == '':
- continue
- try:
- fr, to = p.match(sed).groups()
- # if latex did not run, change all @name@ to '???'
- if fr == '@.*@':
- for line in range(len(lyxin)):
- lyxin[line] = re.sub('@.*@', to, lyxin[line])
+ # build the list of available modules
+ foundClasses = []
+ for file in glob.glob( os.path.join('layouts', '*.module') ) + \
+ glob.glob( os.path.join(srcdir, 'layouts', '*.module' ) ) :
+ # valid file?
+ print file
+ if not os.path.isfile(file):
+ continue
+ tx.write(processModuleFile(file, bool_docbook, bool_linuxdoc))
+ tx.close()
+ print '\tdone'
+
+def processModuleFile(file, bool_docbook, bool_linuxdoc):
+ ''' process module file and get a line of result
+
+ Declare lines look like this:
+ \DeclareLyXModule[LaTeX Packages]{Description}{ModuleName}...
+ We expect output:
+ "ModuleName" "filename" "Description" "Packages"
+ "
+ '''
+ p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*)\])?{(.*)}{(.*)}')
+ for line in open(file).readlines():
+ res = p.search(line)
+ if res != None:
+ (packages, desc, modname) = res.groups()
+ #check availability...need to add that
+ if packages == None:
+ packages = ""