Package wsatools :: Module CLI :: Class CLI
[hide private]

Class CLI

source code


Command-line interface tool - manages command line arguments.

Nested Classes [hide private]
  Argument
A program argument definition.
  Option
A program option definition.
Instance Methods [hide private]
 
__init__(self, progName='', progVer='', progDesc='', checkSVN=True)
Parses command-line arguments.
source code
 
_updateProgVer(self)
Updates self._progVer to latest SVN version if possible.
source code
str or bool
getArg(self, name)
Returns: The argument value supplied via the command line.
source code
str or bool
getOpt(self, name)
Returns: The option value supplied via the command line.
source code
str
getProgDetails(self, progName='')
Returns a string giving the command-line programme's name, version and parameters.
source code
str
help(self)
Returns: A help string giving option definitions and command usage.
source code
str
resetOptArg(self, argName, value)
Resets an optional argument to the given value.
source code
str
usage(self)
Returns: A command usage definition string for this program.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
bool
assertFileExists(filePathName)
A command-line test to ensure a file-exists.
source code
 
check64bitServer()
Prompt operator to check that they are using the server with the most free memory.
source code
str or bool
getArgDef(name)
Returns: The example value for this argument.
source code
str or bool
getOptDef(name)
Returns: The default value for this option.
source code
bool
isConfirmed(message)
Standard user command-line confirmation request.
source code
bool
isDateOK(dateStr)
Checks to see if the supplied date string is in the correct format, either YYYY-MM-DD or YYYYMMDD or a semester date like 05A.
source code
Class Variables [hide private]
  progArgs = {'comment': 'A useful comment'}
Supported program arguments.
  progOpts = {'dbsonly': <wsatools.CLI.Option object at 0x47613d...
Supported program options.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, progName='', progVer='', progDesc='', checkSVN=True)
(Constructor)

source code 

Parses command-line arguments.

Parameters:
  • progName (str or class) - Name of the programme or just a class type.
  • progVer (str) - Version of the programme. (e.g. $Revision: 9505 $)
  • progDesc (str) - Description of what the programme does, not necessary if a class type was supplied as progName.
  • checkSVN (bool) - Check that SVN working copy is up-to-date.
Overrides: object.__init__

assertFileExists(filePathName)
Static Method

source code 

A command-line test to ensure a file-exists.

Parameters:
  • filePathName (str) - Full path to file.
Returns: bool
True, if file exists, otherwise the program quits with an error message.

getArg(self, name)

source code 
Parameters:
  • name (str) - Argument name.
Returns: str or bool
The argument value supplied via the command line.

getArgDef(name)
Static Method

source code 
Parameters:
  • name (str) - Argument name.
Returns: str or bool
The example value for this argument.

getOpt(self, name)

source code 
Parameters:
  • name (str) - Option long name.
Returns: str or bool
The option value supplied via the command line.

getOptDef(name)
Static Method

source code 
Parameters:
  • name (str) - Option long name.
Returns: str or bool
The default value for this option.

getProgDetails(self, progName='')

source code 

Returns a string giving the command-line programme's name, version and parameters.

Parameters:
  • progName (str) - Optional name of sub-programme being invoked by this programme.
Returns: str
Programme name, current version, and invoked parameters.

help(self)

source code 
Returns: str
A help string giving option definitions and command usage.

isConfirmed(message)
Static Method

source code 

Standard user command-line confirmation request.

Parameters:
  • message (str) - Message to give to user explaining why confirmation is required.
Returns: bool
True, if user gives confirmation.

isDateOK(dateStr)
Static Method

source code 

Checks to see if the supplied date string is in the correct format, either YYYY-MM-DD or YYYYMMDD or a semester date like 05A.

Parameters:
  • dateStr (str) - Date string to check formatting.
Returns: bool
True if the date string is correctly formatted.

resetOptArg(self, argName, value)

source code 

Resets an optional argument to the given value.

Parameters:
  • argName (str) - Name of optional argument to reset.
  • value (str) - New value for the optional argument.
Returns: str
The original command-line supplied value.

usage(self)

source code 
Returns: str
A command usage definition string for this program.

Class Variable Details [hide private]

progOpts

Supported program options.

Value:
{'dbsonly': <wsatools.CLI.Option object at 0x47613d0>, 'begin': <wsato\
ols.CLI.Option object at 0x2920590>, 'verbose': <wsatools.CLI.Option o\
bject at 0x2de5210>, 'db': <wsatools.CLI.Option object at 0x4761350>, \
'fitsonly': <wsatools.CLI.Option object at 0x4761390>, 'l': <wsatools.\
CLI.Option object at 0x4761410>, 'localonly': <wsatools.CLI.Option obj\
ect at 0x4761410>, 'end': <wsatools.CLI.Option object at 0x264ad90>, '\
help': <wsatools.CLI.Option object at 0x2910150>, 'c': <wsatools.CLI.O\
ption object at 0x37b9b50>, 'b': <wsatools.CLI.Option object at 0x2920\
...