File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 88import subprocess
99import sys
1010
11+ from collections import Counter
1112from lxml import etree
1213
1314conn = sqlite3 .connect (os .path .join (os .path .dirname (__file__ ), '../src/defaults/rulesets.sqlite' ))
3334xpath_host = etree .XPath ("/ruleset/target/@host" )
3435xpath_ruleset = etree .XPath ("/ruleset" )
3536
36- for fi in glob .iglob ('src/chrome/content/rules/*' ):
37- if fi .endswith ('/00README' ) or fi .endswith ('/make-trivial-rule' ):
37+ filenames = glob .glob ('src/chrome/content/rules/*' )
38+
39+ counted_lowercase_names = Counter ([name .lower () for name in filenames ])
40+ most_common_entry = counted_lowercase_names .most_common (1 )[0 ]
41+ if most_common_entry [1 ] > 1 :
42+ print ("%s failed case-insensitivity testing." % (most_common_entry [0 ]))
43+ print ("Rules exist with identical case-insensitive names, which breaks some filesystems." )
44+ sys .exit (1 )
45+
46+ for fi in filenames :
47+ if fi .endswith ('/00README' ) or fi .endswith ('/make-trivial-rule' ) or fi .endswith ('/default.rulesets' ):
3848 continue
3949
4050 if " " in fi :
4151 print ("%s failed validity: Rule filenames cannot contain spaces" % (fi ))
52+ sys .exit (1 )
4253 if not fi .endswith ('.xml' ):
4354 print ("%s failed validity: Rule filenames must end in .xml" % (fi ))
55+ sys .exit (1 )
4456
4557 try :
4658 tree = etree .parse (fi , parser )
You can’t perform that action at this time.
0 commit comments