|
Imported modules
|
|
import os
import re
import string
import sys
import types
|
|
Functions
|
|
|
|
|
|
argParser
|
argParser ( arglist, d=0 )
Steps through arguments in arglist, loading
optdict with the values -key=value
Args without a leading - are given keys
infile_1, infile_2 ... infile_N
|
|
|
breakString
|
breakString ( str, w )
Word wraps a string into lengths at most w wide;
returns a list
|
|
|
dataType
|
dataType ( str, printError=0 )
Determines the data type of a string (str).
Tries to convert value to an int, then to a float. Returns the original string if both
conversion attempts fail.
|
|
|
define
|
define ()
%(filename)s
A module for parsing arguments from the command line. This module was designed
to permit the rapid construction of programs with a simple, uniform command-line
interface modeled roughly after the syntax used by GCG software. Gracefully
handles pipes, opens files for input and output, and automatically
generates a help string.
This example reads a list of files and writes them to outfile.
{{out name of outfile. Prints to stdout by default.}}
{{h Prints documentation.}}
{{v verbosity
1}}
{{version print version info and exit}}
%(version)s
|
|
|
formatOption
|
formatOption (
optTup,
docTup,
optWidth=15,
lineWidth=72,
valOffset=3,
verbosity=3,
)
Formats the string enclosed by {{ }} for output into a docstring.
verbosity: 1 first line only,
2 first line plus docstring for option
3 include values
|
|
|
getStdin
|
getStdin ( get=1 )
if get = 1, returns an open file object containing stdin if
there is standard input; otherwise returns a
value of 0.
if get = 0, returns 1 if stdin is supplied, 0 otherwise.
|
|
|
inFileStatus
|
inFileStatus (
filename,
ret='name',
ask=0,
exit=1,
)
Check availability of a file for reading.
ret ret='name': return name (filename). 0 if file not found.
ret='file': open file object. 0 if failed.
ask if 1, ask for new filename if not found.
exit if 1, calls sys.exit() if file is unavailable and ask=0
|
|
|
optStringParser
|
optStringParser (
optstring,
optWidth=15,
lineWidth=72,
valOffset=3,
putVals=1,
)
Parses a cpmmandparser-style docstring into a formatted
documentation string, a summary of options, and a list of tuples (optlist).
|
|
|
optToTuple
|
optToTuple ( opt )
|
|
|
optionParser
|
optionParser ( optionlist )
|
|
|
outFileStatus
|
outFileStatus (
filename,
ret='name',
ask=0,
exit=1,
)
Check availability of a file for writing.
ret ret='name': return filename if file does not exist, or 0 if it does
ret=file open file object. 0 if failed.
ask if 1, ask before overwrite.
exit if 1, calls sys.exit() if file exists and ask=0.
|
|
|
printOptions
|
printOptions ( optdict, putVals=1 )
Prints options and values from optdict; use for a summary statement
or for -ini file.
|
|
|
testparser
|
testparser ()
|
|
Classes
|
|
|
|