python/dist/src/Tools/scripts reindent.py, 1.4, 1.5

Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18556 Modified Files: reindent.py Log Message: add usage() function, -h(elp) flag and long versions of short flags Index: reindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/reindent.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** reindent.py 26 Mar 2002 11:39:26 -0000 1.4 --- reindent.py 27 Mar 2004 18:43:56 -0000 1.5 *************** *** 5,11 **** """reindent [-d][-r][-v] [ path ... ] ! -d Dry run. Analyze, but don't make any changes to, files. ! -r Recurse. Search for all .py files in subdirectories too. ! -v Verbose. Print informative msgs; else no output. Change Python (.py) files to use 4-space indents and no hard tab characters. --- 5,12 ---- """reindent [-d][-r][-v] [ path ... ] ! -d (--dryrun) Dry run. Analyze, but don't make any changes to, files. ! -r (--recurse) Recurse. Search for all .py files in subdirectories too. ! -v (--verbose) Verbose. Print informative msgs; else no output. ! -h (--help) Help. Print this usage information and exit. Change Python (.py) files to use 4-space indents and no hard tab characters. *************** *** 43,46 **** --- 44,52 ---- dryrun = 0 + def usage(msg=None): + if msg is not None: + print >> sys.stderr, msg + print >> sys.stderr, __doc__ + def errprint(*args): sep = "" *************** *** 54,68 **** global verbose, recurse, dryrun try: ! opts, args = getopt.getopt(sys.argv[1:], "drv") except getopt.error, msg: ! errprint(msg) return for o, a in opts: ! if o == '-d': dryrun += 1 ! elif o == '-r': recurse += 1 ! elif o == '-v': verbose += 1 if not args: r = Reindenter(sys.stdin) --- 60,78 ---- global verbose, recurse, dryrun try: ! opts, args = getopt.getopt(sys.argv[1:], "drvh", ! ["dryrun", "recurse", "verbose", "help"]) except getopt.error, msg: ! usage(msg) return for o, a in opts: ! if o in ('-d', '--dryrun'): dryrun += 1 ! elif o in ('-r', '--recurse'): recurse += 1 ! elif o in ('-v', '--verbose'): verbose += 1 + elif o in ('-h', '--help'): + usage() + return if not args: r = Reindenter(sys.stdin)
participants (1)
-
montanaroļ¼ users.sourceforge.net