Pydoc: module utils
 
utils
index


 
Module with miscellaneous utilities.

 
Functions
       
aveDev(vector)
Return tuple of ave. and standard dev. of the input list of values, or
array of values
char_range(c1='A', c2='z', num=None)
Generates the characters from `c1` to `c2`, inclusive.
If num is specified, return a sequence with only num elements.
duration(start, end)
Return duration (in seconds) between start and end times.
 
This function is useful for timing the duration of an Xplor-NIH run.  The
arguments start and end are strings specifying the start and end times of
the run.  Their format is of the type 'hh:mm:ss dd-Mmm-yy', e.g., as in
'14:07:58 17-Jun-15' (this is the format used by the "entry time" or "exit
time" at end of an Xplor-NIH logfile).
 
It is assumed the years are in the 2000's.
fileContentsOrString(filenameOrString, splitLines=False, contentRegExp='[^/]\\b[0-9. ]+', dbEnvVar=None)
The argument is the name of a file or a string of contents.
If the argument corresponds to an existing file, it is read and its
contents returned. Otherwise, if the string contains a newline 
character or matches (via re.match) the contentRegExp pattern,
this string is returned. If neither of these conditions is met, this 
argument is assumed to be a non-existant file name, and an exception is
thrown.
 
If the splitLines argument is True, a list of strings split on newline
characters is returned.
 
The returned value is a tuple of the returned contents and a filename,
the later of which is replaced with the literal '[string]' in the case 
the argument does not correspond to a filename.
getDBfilename(filename, dbEnvVar)
Determine whether filename is in local directory or in the environment
variable whose name is dbEnvVar, and return the appropriate path.
histogram(data, weights=None, minVal=None, maxVal=None, numBins=20, useIntegerBins=False)
histogram2D(data, weights=None, minVal0=None, minVal1=None, maxVal0=None, maxVal1=None, numBins0=20, numBins1=20, useIntegerBins=False)
2D histogram. data is a sequence of 2-tuples. Weights is an optional
sequence of equal length containingweights for each data point.
 
The range in dimension N is specified by minValN and maxValN, and set to
the range of input values in the two dimensions if not specified. 
 
If useIntegerBins is specified, then bins are created for all integer
values which include the minimum and maximum value in each dimension.
Otherwise the numBinsN values are used.
 
The return value is a tuple of (minVal0,minVal1,maxVal0,maxVal1,binData).
printReStructuredText(rstString, outputType='txt', cachePrefix=None, cacheDir=None, cacheTime=None)
Print out reStructuredText as raw rst, markup-stripped txt, HTML or 
displayed as a pdf, depending on the outputType argument. Valid values are
"rst", "txt", "html" and "pdf".
 
The cache- arguments configured location and names for a cached PDF 
version which is regenerated if cacheTime > modification time of the 
cached PDF.
processReStructuredText(rstString, outputType='txt', part='whole', settings_overrides={'output_encoding': 'unicode'})
Process reStructuredText given in rstString and output as a string
in one of the following formats: "rst", "txt", "html", "tex", as specified 
by the outputType argument.

 
Data
        moname2num = {'': 0, 'Apr': 4, 'Aug': 8, 'Dec': 12, 'Feb': 2, 'Jan': 1, 'Jul': 7, 'Jun': 6, 'Mar': 3, 'May': 5, ...}