refactor to use a function to process files with lists of styles
This commit is contained in:
@ -89,7 +89,26 @@ def add_suffix(list,style):
|
|||||||
return style + ' (' + suffix + ')'
|
return style + ' (' + suffix + ')'
|
||||||
else:
|
else:
|
||||||
return style
|
return style
|
||||||
|
|
||||||
|
def check_style(file,dir,pattern,list,name,suffix=False,skip=()):
|
||||||
|
f = os.path.join(dir, file)
|
||||||
|
fp = open(f)
|
||||||
|
text = fp.read()
|
||||||
|
fp.close()
|
||||||
|
matches = re.findall(pattern,text,re.MULTILINE)
|
||||||
|
counter = 0
|
||||||
|
for c in list.keys():
|
||||||
|
# known undocumented aliases we need to skip
|
||||||
|
if c in skip: continue
|
||||||
|
s = c
|
||||||
|
if suffix: s = add_suffix(list,c)
|
||||||
|
if not s in matches:
|
||||||
|
if not list[c]['removed']:
|
||||||
|
print("%s style entry %s" % (name,s),
|
||||||
|
"is missing or incomplete in %s" % file)
|
||||||
|
counter += 1
|
||||||
|
return counter
|
||||||
|
|
||||||
for h in headers:
|
for h in headers:
|
||||||
if verbose: print("Checking ", h)
|
if verbose: print("Checking ", h)
|
||||||
fp = open(h)
|
fp = open(h)
|
||||||
@ -170,7 +189,7 @@ for h in headers:
|
|||||||
print("Skipping over: ",m)
|
print("Skipping over: ",m)
|
||||||
|
|
||||||
|
|
||||||
print("""Parsed styles from C++ tree in %s:
|
print("""Parsed style names w/o suffixes from C++ tree in %s:
|
||||||
Angle styles: %3d Atom styles: %3d
|
Angle styles: %3d Atom styles: %3d
|
||||||
Body styles: %3d Bond styles: %3d
|
Body styles: %3d Bond styles: %3d
|
||||||
Command styles: %3d Compute styles: %3d
|
Command styles: %3d Compute styles: %3d
|
||||||
@ -186,106 +205,39 @@ print("""Parsed styles from C++ tree in %s:
|
|||||||
|
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
# check main commands lists
|
|
||||||
f = os.path.join(doc, 'Commands_all.rst')
|
|
||||||
fp = open(f)
|
|
||||||
text = fp.read()
|
|
||||||
fp.close()
|
|
||||||
matches = re.findall(":doc:`(.+) <.+>`",text,re.MULTILINE)
|
|
||||||
for c in command.keys():
|
|
||||||
if not c in matches:
|
|
||||||
if not command[c]['removed']:
|
|
||||||
print("Command %s is missing in Commands_all.rst" % c)
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
f = os.path.join(doc, 'Commands_compute.rst')
|
counter += check_style('Commands_all.rst',doc,":doc:`(.+) <.+>`",
|
||||||
fp = open(f)
|
command,'Command',suffix=False)
|
||||||
text = fp.read()
|
counter += check_style('Commands_compute.rst',doc,":doc:`(.+) <compute.+>`",
|
||||||
fp.close()
|
compute,'Compute',suffix=True)
|
||||||
matches = re.findall(":doc:`(.+) <compute.+>`",text,re.MULTILINE)
|
counter += check_style('compute.rst',doc,":doc:`(.+) <compute.+>` -",
|
||||||
for c in compute.keys():
|
compute,'Compute',suffix=False)
|
||||||
if not add_suffix(compute,c) in matches:
|
counter += check_style('Commands_fix.rst',doc,":doc:`(.+) <fix.+>`",
|
||||||
if not compute[c]['removed']:
|
fix,'Fix',skip=('python'),suffix=True)
|
||||||
print("Compute style entry %s is missing or" % c,
|
counter += check_style('fix.rst',doc,":doc:`(.+) <fix.+>` -",
|
||||||
"incomplete in Commands_compute.rst")
|
fix,'Fix',skip=('python'),suffix=False)
|
||||||
counter += 1
|
counter += check_style('Commands_pair.rst',doc,":doc:`(.+) <pair.+>`",
|
||||||
|
pair,'Pair',skip=('meam','lj/sf'),suffix=True)
|
||||||
f = os.path.join(doc, 'Commands_fix.rst')
|
counter += check_style('pair_style.rst',doc,":doc:`(.+) <pair.+>` -",
|
||||||
fp = open(f)
|
pair,'Pair',skip=('meam','lj/sf'),suffix=False)
|
||||||
text = fp.read()
|
counter += check_style('Commands_bond.rst',doc,":doc:`(.+) <bond.+>`",
|
||||||
fp.close()
|
bond,'Bond',suffix=True)
|
||||||
matches = re.findall(":doc:`(.+) <fix.+>`",text,re.MULTILINE)
|
counter += check_style('bond_style.rst',doc,":doc:`(.+) <bond.+>` -",
|
||||||
for c in fix.keys():
|
bond,'Bond',suffix=False)
|
||||||
# known undocumented aliases we need to skip
|
counter += check_style('Commands_bond.rst',doc,":doc:`(.+) <angle.+>`",
|
||||||
if c in ('python'): continue
|
angle,'Angle',suffix=True)
|
||||||
if not add_suffix(fix,c) in matches:
|
counter += check_style('angle_style.rst',doc,":doc:`(.+) <angle.+>` -",
|
||||||
if not fix[c]['removed']:
|
angle,'Angle',suffix=False)
|
||||||
print("Fix style entry %s is missing or" % c,
|
counter += check_style('Commands_bond.rst',doc,":doc:`(.+) <dihedral.+>`",
|
||||||
"incomplete in Commands_fix.rst")
|
dihedral,'Dihedral',suffix=True)
|
||||||
counter += 1
|
counter += check_style('dihedral_style.rst',doc,":doc:`(.+) <dihedral.+>` -",
|
||||||
|
dihedral,'Dihedral',suffix=False)
|
||||||
f = os.path.join(doc, 'Commands_pair.rst')
|
counter += check_style('Commands_bond.rst',doc,":doc:`(.+) <improper.+>`",
|
||||||
fp = open(f)
|
improper,'Improper',suffix=True)
|
||||||
text = fp.read()
|
counter += check_style('improper_style.rst',doc,":doc:`(.+) <improper.+>` -",
|
||||||
fp.close()
|
improper,'Improper',suffix=False)
|
||||||
matches = re.findall(":doc:`(.+) <pair.+>`",text,re.MULTILINE)
|
counter += check_style('Commands_kspace.rst',doc,":doc:`(.+) <kspace_style>`",
|
||||||
for c in pair.keys():
|
kspace,'KSpace',suffix=True)
|
||||||
# known undocumented aliases we need to skip
|
|
||||||
if c in ('meam','lj/sf'): continue
|
|
||||||
if not add_suffix(pair,c) in matches:
|
|
||||||
if not pair[c]['removed']:
|
|
||||||
print("Pair style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_pair.rst")
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
f = os.path.join(doc, 'Commands_bond.rst')
|
|
||||||
fp = open(f)
|
|
||||||
text = fp.read()
|
|
||||||
fp.close()
|
|
||||||
matches = re.findall(":doc:`(.+) <bond.+>`",text,re.MULTILINE)
|
|
||||||
for c in bond.keys():
|
|
||||||
if not add_suffix(bond,c) in matches:
|
|
||||||
if not bond[c]['removed']:
|
|
||||||
print("Bond style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_bond.rst")
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
matches = re.findall(":doc:`(.+) <angle.+>`",text,re.MULTILINE)
|
|
||||||
for c in angle.keys():
|
|
||||||
if not add_suffix(angle,c) in matches:
|
|
||||||
if not angle[c]['removed']:
|
|
||||||
print("Angle style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_bond.rst")
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
matches = re.findall(":doc:`(.+) <dihedral.+>`",text,re.MULTILINE)
|
|
||||||
for c in dihedral.keys():
|
|
||||||
if not add_suffix(dihedral,c) in matches:
|
|
||||||
if not dihedral[c]['removed']:
|
|
||||||
print("Dihedral style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_bond.rst")
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
matches = re.findall(":doc:`(.+) <improper.+>`",text,re.MULTILINE)
|
|
||||||
for c in improper.keys():
|
|
||||||
if not add_suffix(improper,c) in matches:
|
|
||||||
if not improper[c]['removed']:
|
|
||||||
print("Improper style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_bond.rst")
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
f = os.path.join(doc, 'Commands_kspace.rst')
|
|
||||||
fp = open(f)
|
|
||||||
text = fp.read()
|
|
||||||
fp.close()
|
|
||||||
matches = re.findall(":doc:`(.+) <kspace_style>`",text,re.MULTILINE)
|
|
||||||
for c in kspace.keys():
|
|
||||||
if not add_suffix(kspace,c) in matches:
|
|
||||||
if not kspace[c]['removed']:
|
|
||||||
print("KSpace style entry %s is missing or" % c,
|
|
||||||
"incomplete in Commands_kspace.rst")
|
|
||||||
print(kspace[c])
|
|
||||||
counter += 1
|
|
||||||
|
|
||||||
if counter:
|
if counter:
|
||||||
print("Found %d issue(s) with style lists" % counter)
|
print("Found %d issue(s) with style lists" % counter)
|
||||||
|
|||||||
Reference in New Issue
Block a user