Skip to content

Commit

Permalink
Apply black to upstream/merge-rulesets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
legoktm committed Dec 18, 2023
1 parent cd7928a commit 49b77f5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions upstream/merge-rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import unicodedata
import xml.etree.ElementTree


def normalize(f):
"""
OSX and Linux filesystems encode composite characters differently in
Expand All @@ -22,6 +23,7 @@ def normalize(f):
f = unicodedata.normalize("NFC", f)
return f


# commandline arguments parsing (nobody use it, though)
parser = argparse.ArgumentParser(description="Merge rulesets")
parser.add_argument("--source_dir", default="src/chrome/content/rules")
Expand Down Expand Up @@ -80,7 +82,9 @@ def normalize(f):
trivialNameSecureCookie["host"] = child.attrib["host"]
trivialNameSecureCookie["name"] = ".+"
else:
trivialNameSecureCookie["host"] = (trivialNameSecureCookie["host"] + "|" + child.attrib["host"])
trivialNameSecureCookie["host"] = (
trivialNameSecureCookie["host"] + "|" + child.attrib["host"]
)
else:
sc = {}
sc["host"] = child.attrib["host"]
Expand All @@ -92,15 +96,15 @@ def normalize(f):
if len(ruleset["exclusion"]) == 0:
ruleset["exclusion"].append(child.attrib["pattern"])
else:
ruleset["exclusion"][0] = (ruleset["exclusion"][0] + "|" + child.attrib["pattern"])
ruleset["exclusion"][0] = ruleset["exclusion"][0] + "|" + child.attrib["pattern"]

if trivialNameSecureCookie:
ruleset["securecookie"].insert(0, trivialNameSecureCookie)

library.append(ruleset);
library.append(ruleset)

# Write to default.rulesets
print(" * Writing JSON library to %s and %s"% (ofn, ojson) )
print(" * Writing JSON library to %s and %s" % (ofn, ojson))
outfile = open(ofn, "w")
jsonout = open(ojson, "w")

Expand Down

0 comments on commit 49b77f5

Please sign in to comment.