Mercurial > repos > yufei-luo > s_mart
comparison commons/tools/pathnum2id.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:b0e8584489e6 | 18:94ab73e8a190 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import os | |
4 import sys | |
5 import getopt | |
6 | |
7 def setup_env(): | |
8 if "REPET_PATH" in os.environ.keys(): | |
9 sys.path.append( os.environ["REPET_PATH"] ) | |
10 else: | |
11 print "*** Error: no environment variable REPET_PATH ***" | |
12 sys.exit(1) | |
13 setup_env() | |
14 | |
15 from commons.core.parsing.PathNum2Id import PathNum2Id | |
16 | |
17 #----------------------------------------------------------------------------- | |
18 | |
19 def help(): | |
20 | |
21 print "" | |
22 print "usage:",sys.argv[0]," [ options ]" | |
23 print "option:" | |
24 print " -h: this help" | |
25 print " -i: input file name (path format)" | |
26 print " -o: output file name (path format, default=inFileName+'.path')" | |
27 print "" | |
28 | |
29 #----------------------------------------------------------------------------- | |
30 | |
31 def main(): | |
32 | |
33 inFileName = "" | |
34 outFileName = "" | |
35 | |
36 try: | |
37 opts, args = getopt.getopt(sys.argv[1:],"hi:o:") | |
38 except getopt.GetoptError: | |
39 help() | |
40 sys.exit(1) | |
41 for o,a in opts: | |
42 if o == "-h": | |
43 help() | |
44 sys.exit(0) | |
45 elif o == "-i": | |
46 inFileName = a | |
47 elif o == "-o": | |
48 outFileName = a | |
49 | |
50 if inFileName == "": | |
51 print "*** Error: missing input file name" | |
52 help() | |
53 sys.exit(1) | |
54 | |
55 if outFileName == "": | |
56 outFileName = inFileName + ".path" | |
57 | |
58 pathNum2Id = PathNum2Id() | |
59 pathNum2Id.setInFileName( inFileName ) | |
60 pathNum2Id.setOutFileName( outFileName ) | |
61 pathNum2Id.run() | |
62 | |
63 return 0 | |
64 | |
65 #----------------------------------------------------------------------------- | |
66 | |
67 if __name__ == '__main__': | |
68 main() |