Package lyntin :: Module argparser :: Class Parser
[show private | hide private]
[frames | no frames]

Class Parser

Known Subclasses:
ExtraIndexParser, ExtraNamedParser

This is the base class for the parsers that argumentparser uses to actually populate the dictionary with each argument.
Method Summary
  __init__(self, argparser, argname)
Initializes the Parser.
varies parse(self, val)
Parses the value according to this parser and its associated Typechecker.
  parseInto(self, key, val, argdict)
Populates the argument dictionary with the appropriate value.
  setDefault(self, val)
Sets the default value for this Parser which is used when no other value is given.
  setTypeChecker(self, typechecker)
Sets the typechecker.

Method Details

__init__(self, argparser, argname)
(Constructor)

Initializes the Parser.
Parameters:
argparser - the argparser instance this belongs to
           (type=argparser.ArgParser)
argname - the name of the argument this parser handles type and value checking for.
           (type=string)

parse(self, val)

Parses the value according to this parser and its associated Typechecker. We both typecheck it here (making sure it's valid) as well as convert it (i.e. strings -> ints, strings -> regexps...).
Parameters:
val - the value to parse
           (type=string)
Returns:
the newly adjusted value
           (type=varies)

parseInto(self, key, val, argdict)

Populates the argument dictionary with the appropriate value.
Parameters:
key - the argument name
           (type=string)
val - the argument value
           (type=string)
argdict - the argument dictionary to populate
           (type=dict)
Raises:
ParserException - if multiple values were given for the argument

setDefault(self, val)

Sets the default value for this Parser which is used when no other value is given. Also sets the "defaultset" member which tells the Parser that it has a default value.
Parameters:
val - the default value
           (type=string or int)

setTypeChecker(self, typechecker)

Sets the typechecker. The Parser then uses this to check the values coming in before setting them on the name/value dict.
Parameters:
typechecker - the typechecker to set
           (type=argparser.TypeChecker)

Generated by Epydoc 2.1 on Mon Aug 9 09:17:41 2004 http://epydoc.sf.net