phydmslib.parsearguments module

Module for parsing arguments.

class phydmslib.parsearguments.ArgDefaultsRawDescriptFormatter(prog, indent_increment=2, max_help_position=24, width=None)

Bases: argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter

Print default arguments and raw text description formatter.

Based on this: http://stackoverflow.com/questions/18462610/argumentparser-epilog-and-description-formatting-in-conjunction-with-argumentdef

class phydmslib.parsearguments.ArgumentParserNoArgHelp(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)

Bases: argparse.ArgumentParser

Like argparse.ArgumentParser, but prints help when no arguments.

error(message)

Prints error message, then help.

phydmslib.parsearguments.ExistingFile(fname)

If fname is name of an existing file return it, otherwise an error.

phydmslib.parsearguments.ExistingFileOrNone(fname)

Like Existingfile, but if fname is “None” then return None.

phydmslib.parsearguments.FloatBetweenZeroAndOne(x)

Returns x only if 0 <= x <= 1, otherwise raises error.

phydmslib.parsearguments.FloatGreaterThanEqualToZero(x)

If x is a float >= 0, returns it, otherwise raises and error.

>>> print('%.1f' % FloatGreaterThanEqualToZero('1.5'))
1.5
>>> print('%.1f' % FloatGreaterThanEqualToZero('-1.1'))
Traceback (most recent call last):
   ...
ValueError: -1.1 not float greater than or equal to zero
phydmslib.parsearguments.FloatGreaterThanOne(x)

If x is a string for a float > 1, returns it, otherwise an error.

phydmslib.parsearguments.FloatGreaterThanZero(x)

If x is string for float > 0, returns it, otherwise an error.

Designed based on this: http://stackoverflow.com/questions/12116685/how-can-i-require-my-python-scripts-argument-to-be-a-float-between-0-0-1-0-usin

>>> print("%.3f" % FloatGreaterThanZero('0.1'))
0.100
>>> FloatGreaterThanZero('0.0')
Traceback (most recent call last):
    ...
ValueError: 0.0 not a float greater than zero
phydmslib.parsearguments.IntGreaterThanOne(n)

If n is an integer > 1, returns it, otherwise an error.

phydmslib.parsearguments.IntGreaterThanZero(n)

If n is an integer > 0, returns it, otherwise an error.

phydmslib.parsearguments.ModelOption(model)

Returns model if a valid choice.

Returns the string if it specifies a YNGKP_ model variant.

Returns (‘ExpCM’, prefsfile) if it specifies an ExpCM_ model.

phydmslib.parsearguments.NonNegativeInt(n)

If n is non-negative integer returns it, otherwise an error.

>>> print("%d" % NonNegativeInt('8'))
8
>>> NonNegativeInt('8.1')
Traceback (most recent call last):
   ...
ValueError: 8.1 is not an integer
>>> print("%d" % NonNegativeInt('0'))
0
>>> NonNegativeInt('-1')
Traceback (most recent call last):
   ...
ValueError: -1 is not non-negative
phydmslib.parsearguments.PhyDMSComprehensiveParser()

Returns argparse.ArgumentParser for phdyms_comprehensive.

phydmslib.parsearguments.PhyDMSLogoPlotParser()

Returns argparse.ArgumentParser for phydms_logoplot.

phydmslib.parsearguments.PhyDMSParser()

Returns argparse.ArgumentParser for phydms script.

phydmslib.parsearguments.PhyDMSPrepAlignmentParser()

Returns argparse.ArgumentParser for phydms_prepalignment.

phydmslib.parsearguments.PhyDMSTestdivpressureParser()

Returns argparse.ArgumentParser for phdyms_testdivpressure.

phydmslib.parsearguments.diffPrefsPrior(priorstring)

Parses priorstring and returns prior tuple.