@@ -45,11 +45,9 @@ def load_single_https_ruleset(filepath):
4545 # get root node
4646 root = tree.getroot()
4747
48− #print(etree.tostring(tree))
49−
5048 # check if root is a node with the name ruleset
5149 # TODO improve parsing
52− if root.tag != 'ruleset':
50+ if root.tag != 'ruleset':
5351 return ()
5452
5553 # check if rule is deactivated by default
@@ -68,36 +66,39 @@ def load_single_https_ruleset(filepath):
6866 for ruleset in root:
6967 # this child define a target
7068 if ruleset.tag == 'target':
71− # check if required tags available
69+ # check if required tags available
7270 if not ruleset.attrib.get('host'):
7371 continue
7472
7573 # convert host-rule to valid regex
76− host = ruleset.attrib.get('host').replace('.', '\.').replace('*', '.*')
74+ host = ruleset.attrib.get('host')\
75+ .replace('.', '\.').replace('*', '.*')
7776
7877 # append to host list
7978 hosts.append(host)
8079
8180 # this child define a rule
8281 elif ruleset.tag == 'rule':
83− # check if required tags available
82+ # check if required tags available
8483 if not ruleset.attrib.get('from')\
8584 or not ruleset.attrib.get('to'):
8685 continue
8786
88− # TODO hack, which convert a javascript regex group into a valid python regex group
87+ # TODO hack, which convert a javascript regex group
88+ # into a valid python regex group
8989 rule_from = ruleset.attrib.get('from').replace('$', '\\')
9090 rule_to = ruleset.attrib.get('to').replace('$', '\\')
9191
92− # TODO, not working yet because of the hack above, currently doing that in webapp.py
93− #rule_from_rgx = re.compile(rule_from, re.I)
92+ # TODO, not working yet because of the hack above,
93+ # currently doing that in webapp.py
94+ # rule_from_rgx = re.compile(rule_from, re.I)
9495
9596 # append rule
9697 rules.append((rule_from, rule_to))
9798
9899 # this child define an exclusion
99100 elif ruleset.tag == 'exclusion':
100− # check if required tags available
101+ # check if required tags available
101102 if not ruleset.attrib.get('pattern'):
102103 continue
103104
@@ -124,7 +125,9 @@ def load_https_rules(rules_path):
124125 rules_path += '/'
125126
126127 # search all xml files which are stored in the https rule directory
127− xml_files = [ join(rules_path,f) for f in listdir(rules_path) if isfile(join(rules_path,f)) and f[-4:] == '.xml' ]
128+ xml_files = [join(rules_path, f)
129+ for f in listdir(rules_path)
130+ if isfile(join(rules_path, f)) and f[-4:] == '.xml']
128131
129132 # load xml-files
130133 for ruleset_file in xml_files:
@@ -137,5 +140,5 @@ def load_https_rules(rules_path):
137140
138141 # append ruleset
139142 https_rules.append(ruleset)
140−
143+
141144 print(' * {n} https-rules loaded'.format(n=len(https_rules)))