File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 4
4
import argparse
5
5
import sys
6
6
7
+ def append_unless_dupe (alist , item ):
8
+ if not item in alist :
9
+ alist .append (item )
10
+
7
11
def main ():
8
12
parser = argparse .ArgumentParser ()
9
13
parser .add_argument ("--input" , type = argparse .FileType ('r' ), required = True )
@@ -23,7 +27,7 @@ def main():
23
27
elif line .startswith ("//" ):
24
28
pass
25
29
elif line .startswith ("- " ):
26
- current . append ({ "name" : line [2 :], "namespace" : None })
30
+ append_unless_dupe ( current , { "name" : line [2 :], "namespace" : None })
27
31
elif line .startswith ("[" ) and line .endswith ("Global]" ):
28
32
current = result ["attributes" ]
29
33
else :
@@ -35,7 +39,7 @@ def main():
35
39
else :
36
40
elem = {"name" : line , "namespace" : "http://www.w3.org/1999/xhtml" }
37
41
elem ["attributes" ] = []
38
- result ["elements" ]. append ( elem )
42
+ append_unless_dupe ( result ["elements" ], elem )
39
43
current = elem ["attributes" ]
40
44
41
45
try :
You can’t perform that action at this time.
0 commit comments