Skip to content

Commit a6dc4bc

Browse files
committed
Clean up
1 parent a311de4 commit a6dc4bc

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

utils/merge-rulesets.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def rulesize():
4242
return len(open(rulesets_fn).read())
4343

4444
def clean_up(rulefile):
45-
"""Remove extra whitespace and comments from ruleset library"""
45+
"""Remove extra whitespace and comments from a ruleset"""
4646
comment_and_newline_pattern = re.compile(r"<!--.*?-->|\n|\r", flags=re.DOTALL)
4747
rulefile = comment_and_newline_pattern.sub('', rulefile)
4848
to_and_from_pattern = re.compile(r'\s*(to=|from=)')
@@ -54,9 +54,6 @@ def clean_up(rulefile):
5454

5555
library = open(rulesets_fn,"w")
5656

57-
# XXX TODO replace all sed commands with native Python
58-
#strip_oneline_comment = re.compile(r"<!--.*?-->")
59-
6057
try:
6158
commit_id = os.environ["GIT_COMMIT_ID"]
6259
library.write('<rulesetlibrary gitcommitid="%s">' % commit_id)
@@ -67,8 +64,6 @@ def clean_up(rulefile):
6764
# Include the filename.xml as the "f" attribute
6865
print("Removing whitespaces and comments...")
6966

70-
crush = rulesize()
71-
7267
for rfile in sorted(xml_ruleset_files):
7368
ruleset = open(rfile).read()
7469
fn=os.path.basename(rfile)
@@ -77,13 +72,6 @@ def clean_up(rulefile):
7772
library.write("</rulesetlibrary>\n")
7873
library.close()
7974

80-
#sedcmd = ["sed", "-i", "-e", ":a", "-re"]
81-
#call(sedcmd + [r"s/<!--.*?-->//g;/<!--/N;//ba", rulesets_fn])
82-
#call(["sed", "-i", r":a;N;$!ba;s/\n//g;s/>[ ]*</></g;s/[ ]*to=/ to=/g;s/[ ]*from=/ from=/g;s/ \/>/\/>/g", rulesets_fn])
83-
#call(["sed", "-i", r"s/<\/ruleset>/<\/ruleset>\n/g", rulesets_fn])
84-
85-
print("Crushed", crush, "bytes of rulesets into", rulesize())
86-
8775
try:
8876
if 0 == call(["xmllint", "--noout", rulesets_fn]):
8977
print(rulesets_fn, "passed XML validity test.")

0 commit comments

Comments
 (0)