Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
CommandLine.Option Class Reference

Option classes. More...

Inheritance diagram for CommandLine.Option:
Inheritance graph
[legend]
Collaboration diagram for CommandLine.Option:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __str__

Public Attributes

 prefix
 name
 help

Static Public Attributes

 default = None
string helptext = ''
string prefix = '-'
int takes_argument = 0
int has_default = 0
int tab = 15

Detailed Description

Option classes.

Option base class. Takes no argument.

Definition at line 155 of file CommandLine.py.


Constructor & Destructor Documentation

def CommandLine.Option.__init__ (   self,
  name,
  help = None 
)

Definition at line 167 of file CommandLine.py.

00167 
00168     def __init__(self,name,help=None):
00169 
00170         if not name[:1] == '-':
00171             raise TypeError('option names must start with "-"')
00172         if name[1:2] == '-':
00173             self.prefix = '--'
00174             self.name = name[2:]
00175         else:
00176             self.name = name[1:]
00177         if help:
00178             self.help = help

Here is the caller graph for this function:


Member Function Documentation

Definition at line 179 of file CommandLine.py.

00179 
00180     def __str__(self):
00181 
00182         o = self
00183         name = o.prefix + o.name
00184         if o.takes_argument:
00185             name = name + ' arg'
00186         if len(name) > self.tab:
00187             name = name + '\n' + ' ' * (self.tab + 1 + len(o.prefix))
00188         else:
00189             name = '%-*s ' % (self.tab, name)
00190         description = o.help
00191         if o.has_default:
00192             description = description + ' (%s)' % o.default
00193         return '%s %s' % (name, description)


Member Data Documentation

CommandLine.Option.default = None [static]

Reimplemented in CommandLine.SwitchOption, and CommandLine.ArgumentOption.

Definition at line 160 of file CommandLine.py.

Reimplemented in CommandLine.SwitchOption, and CommandLine.ArgumentOption.

Definition at line 164 of file CommandLine.py.

Definition at line 177 of file CommandLine.py.

Definition at line 161 of file CommandLine.py.

Definition at line 173 of file CommandLine.py.

Definition at line 162 of file CommandLine.py.

Definition at line 172 of file CommandLine.py.

int CommandLine.Option.tab = 15 [static]

Definition at line 165 of file CommandLine.py.

Reimplemented in CommandLine.ArgumentOption.

Definition at line 163 of file CommandLine.py.


The documentation for this class was generated from the following file: