@@ -42,7 +42,7 @@ def rulesize():
4242 return len (open (rulesets_fn ).read ())
4343
4444def 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
5555library = open (rulesets_fn ,"w" )
5656
57- # XXX TODO replace all sed commands with native Python
58- #strip_oneline_comment = re.compile(r"<!--.*?-->")
59-
6057try :
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
6865print ("Removing whitespaces and comments..." )
6966
70- crush = rulesize ()
71-
7267for 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):
7772library .write ("</rulesetlibrary>\n " )
7873library .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-
8775try :
8876 if 0 == call (["xmllint" , "--noout" , rulesets_fn ]):
8977 print (rulesets_fn , "passed XML validity test." )
0 commit comments