Skip to content

Commit 8c479f6

Browse files
committed
Check for dupes when generating the default config.
Fixes: #264
1 parent 80dfa6f commit 8c479f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

builtins/safe-default-configuration.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import argparse
55
import sys
66

7+
def append_unless_dupe(alist, item):
8+
if not item in alist:
9+
alist.append(item)
10+
711
def main():
812
parser = argparse.ArgumentParser()
913
parser.add_argument("--input", type=argparse.FileType('r'), required=True)
@@ -23,7 +27,7 @@ def main():
2327
elif line.startswith("//"):
2428
pass
2529
elif line.startswith("- "):
26-
current.append({ "name": line[2:], "namespace": None })
30+
append_unless_dupe(current, {"name": line[2:], "namespace": None})
2731
elif line.startswith("[") and line.endswith("Global]"):
2832
current = result["attributes"]
2933
else:
@@ -35,7 +39,7 @@ def main():
3539
else:
3640
elem = {"name": line, "namespace": "http://www.w3.org/1999/xhtml"}
3741
elem["attributes"] = []
38-
result["elements"].append(elem)
42+
append_unless_dupe(result["elements"], elem)
3943
current = elem["attributes"]
4044

4145
try:

0 commit comments

Comments
 (0)