| Trees | Index | Help |
|
|---|
| Module argparser :: Class ArgumentParser |
|
| Method Summary | |
|---|---|
Initializes the ArgParser instance so it can then parse user input for arguments. | |
Set the options for this ArgumentParser key=value values in argoptions get put directly into self.options other values in argoptions get set to 1 in self.options. | |
Build up the set of parsers to be used for argument parsing. | |
| varies (string or int) |
Gets a specific option from the arg options hash as passed into the __init__. |
| dict |
Takes an input string and produces the populated dictionary matching self's argspec. |
| list of 2-length-tuples |
Take an input string and tokenizes it into a list of pairs. |
| Method Details |
|---|
__init__(self,
argspec,
argoptions=None)
Initializes the ArgParser instance so it can then parse user input for
arguments. It also generates the syntaxline which is used by the help
system to tell the user what the command syntax is.
|
buildOptions(self, argoptions)Set the options for this ArgumentParser key=value values in argoptions get put directly into self.options other values in argoptions get set to 1 in self.options. example 1:
argoptions="ignorall loud:boolean=true"
self.options={"ignorall":1,"loud":1}
example 2:
argoptions="lalala wewewewe=hahaha"
self.options={"lalala":1,"wewewewe"="hahaha")
|
buildParsers(self, argspec)Build up the set of parsers to be used for argument parsing. The argspec follows the following format:
Any of the arguments can be specified either by name or populated by position, except for arguments after the index collector argument. Those must be specified by name only. Once one default value is given all further arguments must have default values (except collector arguments, which have implicit default arguments of the empty list and the empty map). For examples see the test code at the end of argparser.py.
|
getOption(self, optionname)Gets a specific option from the arg options hash as passed into the __init__.
|
parse(self, input, defaultresolver=None)Takes an input string and produces the populated dictionary matching self's argspec.
|
split(self, input, maxsplit=-1, buildsyntaxline=0)Take an input string and tokenizes it into a list of pairs. Tokens with equal signs come back as (key,value) pairs, those without come back as (argument,None) {}s are treated like quotes, and everything between the {}s is ignored. Any amount of white space between arguments is ignored. (No empty arguments are returned.) "\" (single backslash) escapes anything, including =, {, }, \ (single backslash), and any character, so "\a" (single backslash then a) becomes "a" in the argument, and "\n\o\t\a\d\r\a\g\o\n" (a series of single backslashes followed by a letter) is the same as "notadragon". After maxplit arguments are parsed (all of the arguments if maxsplit < 0), we'll stop and return the rest of input as the final item.
|
| Trees | Index | Help |
|
|---|
| Generated by Epydoc 1.1 on Mon Apr 28 21:11:24 2003 | http://epydoc.sf.net |