equal
deleted
inserted
replaced
2 import gadict |
2 import gadict |
3 import io |
3 import io |
4 import sys |
4 import sys |
5 |
5 |
6 |
6 |
7 fgadict = None |
7 finame = None |
8 fnout = None |
8 foname = None |
9 if len(sys.argv) >= 2: |
9 if len(sys.argv) >= 2: |
10 fgadict = sys.argv[1] |
10 finame = sys.argv[1] |
11 if len(sys.argv) >= 3: |
11 if len(sys.argv) >= 3: |
12 fnout = sys.argv[2] |
12 foname = sys.argv[2] |
13 |
13 |
14 fin = io.open(fgadict, mode='r', buffering=1, encoding="utf-8") |
14 fin = io.open(finame, mode='r', buffering=1, encoding="utf-8") |
15 if fnout is None: |
15 if foname is None: |
16 fout = sys.stdout |
16 fout = sys.stdout |
17 else: |
17 else: |
18 fout = open(fnout, "w") |
18 fout = open(foname, "w") |
19 |
19 |
20 |
20 |
21 parser = gadict.Parser() |
21 parser = gadict.Parser() |
22 try: |
22 try: |
23 dom = parser.parse(fin) |
23 dom = parser.parse(fin) |
24 except gadict.ParseException as ex: |
24 except gadict.ParseException as ex: |
25 sys.stdout.write("{:s}{:s}\n".format(fgadict, repr(ex))) |
25 sys.stdout.write("{:s}{:s}\n".format(finame, repr(ex))) |
26 if __debug__: |
26 if __debug__: |
27 import traceback |
27 import traceback |
28 traceback.print_exc() |
28 traceback.print_exc() |
29 exit(1) |
29 exit(1) |
30 finally: |
30 finally: |