def grabargs():
# "Grab command-line arguments"
fname = ''
options={
'strip':False,
'full':False,
'limit':False,
'stat':False,
'reduce':False,
}
if not sys.argv[1:]:
usage()
sys.exit(0)
try:
opts, args = getopt.getopt(sys.argv[1:], "hVtlv:f:l:",
["help", "version","stat", "limit=", "file="],)
except getopt.GetoptError:
usage()
sys.exit(0)
for o, val in opts:
if o in ("-h", "--help"):
usage()
sys.exit(0)
if o in ("-V", "--version"):
print scriptversion
sys.exit(0)
if o in ("-t", "--stat"):
options['stat'] = True;
if o in ("-l", "--limit"):
try: options['limit'] = int(val);
except: options['limit']=0;
if o in ("-f", "--file"):
fname = val
utfargs=[]
for a in args:
utfargs.append( a.decode('utf8'));
text= u' '.join(utfargs);
#if text: print text.encode('utf8');
return (fname, options)
评论列表
文章目录