Clarify code a bit.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34527 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-05-27 15:20:21 +00:00
parent 434af7df28
commit 35ee5f2040

View File

@ -1088,12 +1088,12 @@ def processModuleFile(file, bool_docbook):
We expect output:
"ModuleName" "filename" "Description" "Packages" "Requires" "Excludes" "Category"
'''
p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*?)\])?{(.*)}')
r = re.compile(r'#+\s*Requires: (.*)')
x = re.compile(r'#+\s*Excludes: (.*)')
c = re.compile(r'#+\s*Category: (.*)')
b = re.compile(r'#+\s*DescriptionBegin\s*$')
e = re.compile(r'#+\s*DescriptionEnd\s*$')
remods = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*?)\])?{(.*)}')
rereqs = re.compile(r'#+\s*Requires: (.*)')
reexcs = re.compile(r'#+\s*Excludes: (.*)')
recaty = re.compile(r'#+\s*Category: (.*)')
redbeg = re.compile(r'#+\s*DescriptionBegin\s*$')
redend = re.compile(r'#+\s*DescriptionEnd\s*$')
modname = desc = pkgs = req = excl = catgy = ""
readingDescription = False
@ -1103,18 +1103,18 @@ def processModuleFile(file, bool_docbook):
for line in open(file).readlines():
if readingDescription:
res = e.search(line)
res = redend.search(line)
if res != None:
readingDescription = False
desc = " ".join(descLines)
continue
descLines.append(line[1:].strip())
continue
res = b.search(line)
res = redbeg.search(line)
if res != None:
readingDescription = True
continue
res = p.search(line)
res = remods.search(line)
if res != None:
(pkgs, modname) = res.groups()
if pkgs == None:
@ -1123,19 +1123,19 @@ def processModuleFile(file, bool_docbook):
tmp = [s.strip() for s in pkgs.split(",")]
pkgs = ",".join(tmp)
continue
res = r.search(line)
res = rereqs.search(line)
if res != None:
req = res.group(1)
tmp = [s.strip() for s in req.split("|")]
req = "|".join(tmp)
continue
res = x.search(line)
res = reexcs.search(line)
if res != None:
excl = res.group(1)
tmp = [s.strip() for s in excl.split("|")]
excl = "|".join(tmp)
continue
res = c.search(line)
res = recaty.search(line)
if res != None:
catgy = res.group(1)
continue
@ -1160,6 +1160,7 @@ def processModuleFile(file, bool_docbook):
for line in testpackages:
cm.write(line + '\n')
cm.close()
return '"%s" "%s" "%s" "%s" "%s" "%s" "%s"\n' % (modname, filename, desc, pkgs, req, excl, catgy)