Mercurial > repos > yufei-luo > s_mart
view commons/tools/pathnum2id.py @ 19:9bcfa7936eec
Deleted selected files
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:23:29 -0400 |
parents | 94ab73e8a190 |
children |
line wrap: on
line source
#!/usr/bin/env python import os import sys import getopt def setup_env(): if "REPET_PATH" in os.environ.keys(): sys.path.append( os.environ["REPET_PATH"] ) else: print "*** Error: no environment variable REPET_PATH ***" sys.exit(1) setup_env() from commons.core.parsing.PathNum2Id import PathNum2Id #----------------------------------------------------------------------------- def help(): print "" print "usage:",sys.argv[0]," [ options ]" print "option:" print " -h: this help" print " -i: input file name (path format)" print " -o: output file name (path format, default=inFileName+'.path')" print "" #----------------------------------------------------------------------------- def main(): inFileName = "" outFileName = "" try: opts, args = getopt.getopt(sys.argv[1:],"hi:o:") except getopt.GetoptError: help() sys.exit(1) for o,a in opts: if o == "-h": help() sys.exit(0) elif o == "-i": inFileName = a elif o == "-o": outFileName = a if inFileName == "": print "*** Error: missing input file name" help() sys.exit(1) if outFileName == "": outFileName = inFileName + ".path" pathNum2Id = PathNum2Id() pathNum2Id.setInFileName( inFileName ) pathNum2Id.setOutFileName( outFileName ) pathNum2Id.run() return 0 #----------------------------------------------------------------------------- if __name__ == '__main__': main()