Package schrodinger :: Package application :: Package desmond :: Package packages :: Module cui :: Class LazyParser
[hide private]
[frames] | no frames]

Class LazyParser

object --+
         |
        LazyParser

Some argument parsers are so slow, e.g., the msys parser. We should avoid running them unless they are really needed. For example, when user just wants to see the help, or when there is another parsing errors which interrupts the execution of the command, there is no need to run these slow parsers. We use this class to delay slow parsers' running.

Instance Methods [hide private]
 
__init__(self, parser, priority=0)
x.__init__(...) initializes x; see help(type(x)) for signature
 
parse(self)
Calls the actual parser on the cached string and returns the parsing result.
 
__call__(self, string)
Just caches the string to be parsed, and returns this LazyParser object itself.

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

Properties [hide private]
  string
Return the original string from the command line.
int priority
Return the priority of this parser.

Inherited from object: __class__

Method Details [hide private]

__init__(self, parser, priority=0)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • parser (Callable object) - It should take a string argument, parse the string, and return the resultant object.
  • priority (int: 0-9) - Specify the priority of parsing. High numbered object will be parsed earlier.
Overrides: object.__init__

__call__(self, string)
(Call operator)

 

Just caches the string to be parsed, and returns this LazyParser object itself. The real parsing will be conducted when the parse method of this class is explicitly called.


Property Details [hide private]

string

Return the original string from the command line.

Get Method:
unreachable.string(self) - Return the original string from the command line.

priority

Return the priority of this parser.

Get Method:
unreachable.priority(self) - Return the priority of this parser.
Type:
int