CMS 3D CMS Logo

Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes

VarParsing::VarParsing Class Reference

List of all members.

Public Member Functions

def __getattr__
def __init__
def __setattr__
def __str__
def clearList
def has_key
def help
def loadFromFile
def parseArguments
def register
def setDefault
def setNoCommaSplit
def setNoDefaultClear
def setType
def setupTags

Public Attributes

 inputFiles
 Post-loading processing #.

Static Public Attributes

tuple commaRE = re.compile(r',')
tuple falseRE = re.compile(r'^false$', re.IGNORECASE)
tuple multiplicity = Enumerate("singleton list", "multiplicity")
tuple trueRE = re.compile(r'^true$', re.IGNORECASE)
tuple varType = Enumerate("bool int float string tagString")

Private Member Functions

def _convert
def _withTags

Private Attributes

 _beenSet
 _currentlyParsing
 _info
 _lists
 _maxLength
 _noCommaSplit
 _noDefaultClear
 _register
 _setDuringParsing
 _singletons
 _tagOrder
 _tags
 _types

Detailed Description

Infrastructure to parse variable definitions passed to cmsRun
configuration scripts

Definition at line 8 of file VarParsing.py.


Constructor & Destructor Documentation

def VarParsing::VarParsing::__init__ (   self,
  args 
)
Class initializer

Definition at line 20 of file VarParsing.py.

00021                               :
00022         """Class initializer"""
00023         # Set everything up first
00024         self._singletons       = {}
00025         self._lists            = {}
00026         self._register         = {}
00027         self._beenSet          = {}
00028         self._info             = {}
00029         self._types            = {}
00030         self._maxLength        = 0
00031         self._tags             = {}
00032         self._tagOrder         = []
00033         self._noCommaSplit     = {}
00034         self._noDefaultClear   = {}
00035         self._setDuringParsing = {}
00036         self._currentlyParsing = False
00037         # now play with the rest
00038         for arg in args:
00039             lower = arg.lower()
00040             if lower == 'python':
00041                 self.register ('storePrepend',
00042                                '',
00043                                VarParsing.multiplicity.singleton,
00044                                VarParsing.varType.string,
00045                                "Prepend location of files starting "
00046                                "with '/store'")
00047                 # Don't continue because we want to process the next
00048                 # piece, too.
00049             if lower == 'analysis' or lower == 'python':
00050                 # Optionos for cmsRun or FWLite.Python
00051                 self.register ('maxEvents',
00052                                -1,
00053                                VarParsing.multiplicity.singleton,
00054                                VarParsing.varType.int,
00055                                "Number of events to process (-1 for all)")
00056                 self.register ('totalSections',
00057                                0,
00058                                VarParsing.multiplicity.singleton,
00059                                VarParsing.varType.int,
00060                                "Total number of sections")
00061                 self.register ('section',
00062                                0,
00063                                VarParsing.multiplicity.singleton,
00064                                VarParsing.varType.int,
00065                                "This section (from 1..totalSections inclusive)")
00066                 self.register ('inputFiles',
00067                                '',
00068                                VarParsing.multiplicity.list,
00069                                VarParsing.varType.string,
00070                                "Files to process")
00071                 self.register ('secondaryInputFiles',
00072                                '',
00073                                VarParsing.multiplicity.list,
00074                                VarParsing.varType.string,
00075                                "Second group of files to process (if needed)")
00076                 self.register ('filePrepend',
00077                                '',
00078                                VarParsing.multiplicity.singleton,
00079                                VarParsing.varType.string,
00080                                "String to prepend location of all files")
00081                 self.register ('outputFile',
00082                                'output.root',
00083                                VarParsing.multiplicity.singleton,
00084                                VarParsing.varType.tagString,
00085                                "Name of output file (if needed)")
00086                 self.register ('secondaryOutputFile',
00087                                '',
00088                                VarParsing.multiplicity.singleton,
00089                                VarParsing.varType.tagString,
00090                                "Name of second output file (if needed)")
00091                 self.register ('tag',
00092                                '',
00093                                VarParsing.multiplicity.singleton,
00094                                VarParsing.varType.string,
00095                                "tag to add to output filename")
00096                 self.setupTags (tag = 'numEvent%d',
00097                                 ifCond = 'maxEvents > 0',
00098                                 tagArg = 'maxEvents')
00099                 self.setupTags (tag = '%s',
00100                                 ifCond = 'tag',
00101                                 tagArg = 'tag')
00102                 continue
00103             # old, depricated, but here for compatibility of older code
00104             if lower == "standard":
00105                 # load in old standard arguments and defaults
00106                 self.register ('maxEvents',
00107                                -1,
00108                                VarParsing.multiplicity.singleton,
00109                                VarParsing.varType.int,
00110                                "Number of events to process (-1 for all)")
00111                 self.register ('files',
00112                                '',
00113                                VarParsing.multiplicity.list,
00114                                VarParsing.varType.string,
00115                                "Files to process")
00116                 self.register ('secondaryFiles',
00117                                '',
00118                                VarParsing.multiplicity.list,
00119                                VarParsing.varType.string,
00120                                "Second group of files to process (if needed)")
00121                 self.register ('output',
00122                                'output.root',
00123                                VarParsing.multiplicity.singleton,
00124                                VarParsing.varType.tagString,
00125                                "Name of output file (if needed)")
00126                 self.register ('secondaryOutput',
00127                                '',
00128                                VarParsing.multiplicity.singleton,
00129                                VarParsing.varType.tagString,
00130                                "Name of second output file (if needed)")
00131                 self.setupTags (tag = 'numEvent%d',
00132                                 ifCond = 'maxEvents > 0',
00133                                 tagArg = 'maxEvents')
00134                 continue
00135             # if we're still here, then we've got a rogue arument
00136             print "Error: VarParsing.__init__ doesn't understand '%s'" \
00137                   % arg
00138             raise RuntimeError, "Failed to create VarParsing object"
00139 


Member Function Documentation

def VarParsing::VarParsing::__getattr__ (   self,
  name,
  noTags = False 
)
Lets user get the info they want with obj.name

Definition at line 598 of file VarParsing.py.

00599                                                 :
00600         """Lets user get the info they want with obj.name"""
00601         if name.startswith ("_"):
00602             # internal use
00603             return object.__getattribute__ (self, name)
00604         else:
00605             # user variable
00606             if not self._register.has_key (name):
00607                 print "Error:  '%s' not already registered." \
00608                       % name
00609                 raise RuntimeError, "Unknown variable"
00610             if VarParsing.multiplicity.singleton == self._register[name]:
00611                 if VarParsing.varType.tagString == self._types[name] \
00612                        and not noTags:
00613                     return self._withTags (name)
00614                 else:
00615                     return self._singletons[name]
00616             else:
00617                 return self._lists[name]
00618  

def VarParsing::VarParsing::__setattr__ (   self,
  name,
  value,
  extras 
)
Lets me set internal values, or uses setDefault

Definition at line 588 of file VarParsing.py.

00589                                                 :
00590         """Lets me set internal values, or uses setDefault"""
00591         if not name.startswith ("_"):
00592             mylist = list (extras)
00593             mylist.insert (0, value)
00594             self.setDefault (name, *mylist)
00595         else:
00596             object.__setattr__ (self, name, value)
00597 

def VarParsing::VarParsing::__str__ (   self)
String form of self

Definition at line 553 of file VarParsing.py.

00554                       :
00555         """String form of self"""
00556         maxLen = min (self._maxLength, 20)
00557         form     = "  %%-%ds: %%s" % maxLen
00558         formInfo = "  %%%ds  - %%s" % (maxLen - 2)
00559         formItem = "  %%%ds    %%s" % (maxLen - 1)
00560         retval = ""
00561         if len (self._singletons.keys()):
00562             retval = retval + "Singletons:\n"
00563         for varName, value in sorted (self._singletons.iteritems()):
00564             retval = retval + form % (varName, value) + "\n";
00565             if self._info.get(varName):
00566                 retval = retval + formInfo % ('', self._info[varName]) + "\n"
00567         if len (self._singletons.keys()):
00568             retval = retval +  "Lists:\n"
00569         for varName, value in sorted (self._lists.iteritems()):
00570             stringValue = "%s" % value
00571             if len (stringValue) < 76 - maxLen:
00572                 retval = retval + form % (varName, value) + "\n"
00573             else:
00574                 varLength = len (value)
00575                 for index, item in enumerate (value):
00576                     if index == 0:
00577                         retval = retval + form % (varName, "['" + item)
00578                     else:
00579                         retval = retval + formItem % ('',"'" + item)
00580                     if index == varLength - 1:
00581                         retval = retval + "' ]\n"
00582                     else:
00583                         retval = retval + "',\n"
00584             if self._info.get(varName):
00585                 retval = retval + formInfo % ('', self._info[varName]) + "\n"
00586         return retval
00587 

def VarParsing::VarParsing::_convert (   self,
  name,
  inputVal 
) [private]
Converts inputVal to the type required by name

Definition at line 502 of file VarParsing.py.

00503                                        :
00504         """Converts inputVal to the type required by name"""
00505         inputVal = str (inputVal)
00506         if self._types[name] == VarParsing.varType.bool:
00507             if VarParsing.trueRE.match (inputVal) or '1' == inputVal:
00508                 return True
00509             elif VarParsing.falseRE.match (inputVal) or '0' == inputVal:
00510                 return False
00511             # if we're still here, then we don't have 'true' or 'false'
00512             raise RuntimeError, "Unknown bool value '%s'.  Must be 'true' or 'false'" % inputVal
00513         if self._types[name] == VarParsing.varType.string or \
00514            self._types[name] == VarParsing.varType.tagString:
00515             return inputVal
00516         elif self._types[name] == VarParsing.varType.int:
00517             return int (inputVal, 0)
00518         elif self._types[name] == VarParsing.varType.float:
00519             return float (inputVal)
00520         else:
00521             raise RuntimeError, "Unknown varType"
00522         

def VarParsing::VarParsing::_withTags (   self,
  name 
) [private]

Definition at line 523 of file VarParsing.py.

00524                               :
00525         if not self._register.has_key (name):
00526             print "Error:  '%s' not registered." \
00527                   % name
00528             raise RuntimeError, "Unknown variable"
00529         if self._register[name] == VarParsing.multiplicity.list:
00530             print "Error: '%s' is a list" % name
00531             raise RuntimeError, "withTags() only works on singletons"
00532         retval = self._singletons[name]
00533         if retval.endswith ('.root'):
00534             retval, garbage = os.path.splitext (retval)
00535         reverseOrder = self._tagOrder
00536         reverseOrder.reverse()
00537         for tag in reverseOrder:
00538             tagDict = self._tags[tag]
00539             ifCond = tagDict['ifCond']
00540             if ifCond.count('%'):
00541                 pass
00542             else:
00543                 ifCond = "self." + ifCond
00544             boolValue = eval (ifCond)
00545             tagArg = tagDict.get ('tagArg')
00546             if tagArg:
00547                 evalString = "'%s' %% self.%s" % (tag, tagArg)
00548                 tag = eval (evalString)
00549             if boolValue:
00550                 retval = retval + "_" + tag        
00551         return retval + ".root"
00552             

def VarParsing::VarParsing::clearList (   self,
  name 
)
Empties all entries from list

Definition at line 301 of file VarParsing.py.

00302                               :
00303         """Empties all entries from list"""
00304         if not self._register.has_key (name):
00305             print "Error:  '%s' not registered." \
00306                   % name
00307             raise RuntimeError, "Unknown variable"
00308         if self._register[name] != VarParsing.multiplicity.list:
00309             print "Error: '%s' is not a list" % name
00310             raise RuntimeError, "Faulty 'clear' command"
00311         # if we're still here, do what we came to do
00312         self._lists[name] = []
00313 

def VarParsing::VarParsing::has_key (   self,
  key 
)
Returns true if a key is registered

Definition at line 432 of file VarParsing.py.

00433                            :
00434         """Returns true if a key is registered"""
00435         return self._register.has_key (key)
00436 

def VarParsing::VarParsing::help (   self)
Prints out help information and exits

Definition at line 361 of file VarParsing.py.

00362                    :
00363         """Prints out help information and exits"""
00364         print self
00365         print """Options:
00366         help           : This screen
00367         multipleAssign : Allows singletons to have multiple assigments
00368         print          : Prints out current values
00369         XXX_clear      : Clears list named 'XXX'
00370         """    
00371         sys.exit (0)
00372 

def VarParsing::VarParsing::loadFromFile (   self,
  name,
  filename 
)
Loads a list from file

Definition at line 339 of file VarParsing.py.

00340                                            :
00341         """Loads a list from file"""
00342         if not self._register.has_key (name):
00343             print "Error:  '%s' not registered." \
00344                   % name
00345             raise RuntimeError, "Unknown variable"
00346         if self._register[name] != VarParsing.multiplicity.list:
00347             print "Error: '%s' is not a list" % name
00348             raise RuntimeError, "'load' only works for lists"
00349         filename = os.path.expanduser (filename)
00350         if not os.path.exists (filename):
00351             print "Error: '%s' file does not exist."
00352             raise RuntimeError, "Bad filename"
00353         source = open (filename, 'r')        
00354         for line in source.readlines():
00355             line = re.sub (r'#.+$', '', line) # remove comment characters
00356             line = line.strip()
00357             if len (line):
00358                 self._lists[name].append( self._convert (name, line ) )
00359         source.close()
00360 

def VarParsing::VarParsing::parseArguments (   self)
Parses command line arguments.  Parsing starts just after
the name of the configuration script.  Parsing will fail if
there is not 'xxxx.py'

Definition at line 164 of file VarParsing.py.

00165                              :
00166         """Parses command line arguments.  Parsing starts just after
00167         the name of the configuration script.  Parsing will fail if
00168         there is not 'xxxx.py'"""
00169         self._currentlyParsing = True
00170         foundPy      = False
00171         printStatus  = False
00172         help         = False
00173         singleAssign = True 
00174         for arg in sys.argv:
00175             if not foundPy and arg.endswith ('.py'):
00176                 foundPy = True
00177                 continue
00178             if not foundPy:
00179                 continue
00180             # If we're here, then we can parse to our hearts content.
00181             # So, is this a command or a declaration?
00182             if arg.count('='):
00183                 # declaration
00184                 name, value = arg.split ('=', 1)
00185                 if name.count('_'):
00186                     # name with command
00187                     name, command = name.split ('_', 1)
00188                     command = command.lower()
00189                     if command == 'load':
00190                         self.loadFromFile (name, value)
00191                         continue
00192                     if command == 'clear':
00193                         self.clearList (name)
00194                         continue
00195                     # If we're here, then I don't recognize this command
00196                     print "Unknown command '%s' in '%s_%s" % \
00197                           (command, name, command)
00198                     raise RuntimeError, "Illegal parsing command"
00199                 else:
00200                     # just a name and value
00201                     if not self._register.has_key (name):
00202                         print "Error:  '%s' not registered." \
00203                               % name
00204                         raise RuntimeError, "Unknown variable"
00205                     if VarParsing.multiplicity.singleton == \
00206                            self._register[name]:
00207                         # singleton
00208                         if self._beenSet.get (name) and singleAssign:
00209                             print "Variable '%s' assigned multiple times. Use" \
00210                                   , "'multipleAssign' command to avoid"
00211                             raise RuntimeError, "Multiple assignment"
00212                         self._beenSet[name] = True
00213                         self.setDefault (name, value)
00214                     else:
00215                         # list
00216                         self.setDefault (name, value)
00217             else:
00218                 # commands
00219                 if arg.count('_'):
00220                     # name modifier
00221                     name, command = arg.split ('_', 1)
00222                     command = command.lower()
00223                     if not self._register.has_key (name):
00224                         print "Error:  '%s' not registered." \
00225                               % name
00226                         raise RuntimeError, "Unknown variable"
00227                     if command == 'clear':
00228                         self.clearList (name)
00229                         continue
00230                     # if we're still here, complain that we don't
00231                     # understand this command:
00232                     print "Do not understand '%s' in '%s'" % (command, arg)
00233                     raise RuntimeError, "Unknown command"
00234                 else:
00235                     # simple command
00236                     command = arg.lower()
00237                     if command == 'help' or command == '--help':
00238                         help = True
00239                     elif command == 'print' or command == '--print':
00240                         printStatus = True
00241                     elif command == 'noprint' or command == '--noprint':
00242                         printStatus = False
00243                     else:
00244                         # We don't understand this command
00245                         print "Do not understand command '%s'" % (arg)
00246                         raise RuntimeError, "Unknown command"
00247             # else if declaration
00248         ###########################
00249         # Post-loading processing #
00250         ###########################
00251         # sections
00252         if self._register.has_key ('totalSections') and \
00253            self._register.has_key ('section') and \
00254            self._register.has_key ('inputFiles') and \
00255            self.totalSections and self.section:
00256             # copy list
00257             oldInputFiles = self.inputFiles
00258             # clear list
00259             self.clearList ('inputFiles')
00260             # used old list to make list
00261             self.inputFiles = sectionNofTotal (oldInputFiles,
00262                                                self.section,
00263                                                self.totalSections)
00264         # storePrepend
00265         if self._register.has_key ('storePrepend') and \
00266            self._register.has_key ('inputFiles') and \
00267            self.storePrepend:
00268             storeRE = re.compile (r'^/store/')
00269             newFileList = []
00270             for filename in self.inputFiles:
00271                 if storeRE.match (filename):
00272                     filename = self.storePrepend + filename
00273                 newFileList.append (filename)
00274             # clear old list
00275             self.clearList ('inputFiles')
00276             # set new list as list
00277             self.inputFiles = newFileList
00278         # filePrepend
00279         if self._register.has_key ('filePrepend') and \
00280            self._register.has_key ('inputFiles') and \
00281            self.filePrepend:
00282             newFileList = []
00283             for filename in self.inputFiles:
00284                 filename = self.filePrepend + filename
00285                 newFileList.append (filename)
00286             # clear old list
00287             self.clearList ('inputFiles')
00288             # set new list as list
00289             self.inputFiles = newFileList
00290         # make sure found the py file
00291         if not foundPy:
00292             print "VarParsing.parseArguments() Failure: No configuration " + \
00293                   "file found ending in .py."
00294             raise RuntimeError, "Invalid configuration ending"
00295         if help:
00296             self.help()
00297         if printStatus:
00298             print self
00299         self._currentlyParsing = False
00300 

def VarParsing::VarParsing::register (   self,
  name,
  default = "",
  mult = multiplicity.singleton,
  mytype = varType.int,
  info = "",
  kwargs 
)
Register a variable

Definition at line 373 of file VarParsing.py.

00379                            :
00380         """Register a variable"""
00381         # is type ok?
00382         if not VarParsing.multiplicity.isValidValue (mult):
00383             print "Error: VarParsing.register() must use ",\
00384                   "VarParsing.multiplicity."
00385             raise RuntimeError, "Improper 'mult' value"
00386         if not VarParsing.varType.isValidValue (mytype):
00387             print "Error: VarParsing.register() must use ",\
00388                   "VarParsing.varType."
00389             raise RuntimeError, "Improper 'type' value %s" % mytype
00390         if VarParsing.multiplicity.list == mult and \
00391            VarParsing.varType.tagString == mytype:
00392             print "Error: 'tagString' can only be used with 'singleton'"
00393             raise RuntimeError, "Improper registration"
00394         # is the name ok
00395         if name.count ("_"):
00396             print "Error: Name can not contain '_': %s" % name
00397             raise RuntimeError, "Improper 'name'"
00398         # has this been registered before?
00399         if self._register.has_key (name):
00400             # Uh oh
00401             print "Error: You can not register a name twice, '%s'" \
00402                   % name
00403             raise RuntimeError, "Attempt to re-register variable"
00404         self._register[name] = mult
00405         self._beenSet[name]  = False
00406         self._info[name]     = info
00407         self._types[name]    = mytype
00408         if len (name) > self._maxLength:
00409             self._maxLength = len (name)
00410         if VarParsing.multiplicity.singleton == mult:
00411             self._singletons[name] = default
00412         else:
00413             self._lists[name] = []
00414             # if it's a list, we only want to use the default if it
00415             # does exist.
00416             if len (default):
00417                 self._lists[name].append (default)
00418         #######################################
00419         ## Process any additional directives ##
00420         #######################################
00421         # do we want to tell the list to not split command line
00422         # arguments by commas?
00423         if kwargs.get ('noCommaSplit'):
00424             self._noCommaSplit[name] = bool( kwargs['noCommaSplit'] )
00425             del kwargs['noCommaSplit']
00426         if kwargs.get ('noDefaultClear'):
00427             self._noDefaultClear[name] = bool( kwargs['noDefaultClear'] )
00428             del kwargs['noDefaultClear']
00429         if len (kwargs):
00430             raise RuntimeError, "register() Unknown arguments %s" % kwargs
00431 

def VarParsing::VarParsing::setDefault (   self,
  name,
  args 
)
Used to set or change the default of an already registered
name

Definition at line 448 of file VarParsing.py.

00449                                       :
00450         """Used to set or change the default of an already registered
00451         name"""
00452         # has this been registered?
00453         if not self._register.has_key (name):
00454             print "Error: VarParsing.setDefault '%s' not already registered." \
00455                   % name
00456             raise RuntimeError, "setDefault without registration"
00457         if VarParsing.multiplicity.singleton == self._register[name]:
00458             # make sure we only have one value
00459             if len (args) != 1:
00460                 print "Error: VarParsing.setDefault needs exactly 1 ",\
00461                       "value for '%s'" % name
00462                 raise RuntimeError, "setDefault args problem"
00463             self._singletons[name] = self._convert (name, args[0])
00464         else:
00465             # If:
00466             #   - We have a list (which we do)
00467             #   - We are now processing command line parsing
00468             #   - It has not yet been set after parsing
00469             #   - We have not explicitly asked for it to be NOT cleared
00470             # Then:
00471             #   - We clear the list
00472             if self._currentlyParsing and \
00473                not self._setDuringParsing.get(name) and \
00474                not self._noDefaultClear.get(name):
00475                 # All four conditions have been satisfied, so let's go
00476                 # ahead and clear this.
00477                 self.clearList (name)
00478             # IF we are currently parsing, then tell people I've set
00479             # this:
00480             if self._currentlyParsing:
00481                 self._setDuringParsing[name] = True
00482             # if args is a tuple and it only has one entry, get rid of
00483             # the first level of tupleness:
00484             if isinstance (args, tuple) and len (args) == 1:
00485                 args = args[0]
00486             # is this still a tuple
00487             if isinstance (args, tuple):
00488                 mylist = list (args)
00489             elif isinstance (args, list):
00490                 mylist = args
00491             else:
00492                 mylist = []
00493                 mylist.append (args)
00494             if not self._noCommaSplit.get (name):
00495                 oldList = mylist
00496                 mylist = []
00497                 for item in oldList:
00498                     mylist.extend( VarParsing.commaRE.split( item ) )
00499             for item in mylist:
00500                 self._lists[name].append( self._convert (name, item ) )
00501 

def VarParsing::VarParsing::setNoCommaSplit (   self,
  name,
  value = True 
)
Tells lists to not split up values by commas.

Definition at line 327 of file VarParsing.py.

00328                                                 :
00329         """Tells lists to not split up values by commas."""
00330         if not self._register.has_key (name):
00331             print "Error:  '%s' not registered." \
00332                   % name
00333             raise RuntimeError, "Unknown variable"
00334         if self._register[name] != VarParsing.multiplicity.list:
00335             print "Error: '%s' is not a list" % name
00336             raise RuntimeError, "Faulty 'setNoCommaSplit' command"
00337         self._noCommaSplit[name] = bool (value)
00338 

def VarParsing::VarParsing::setNoDefaultClear (   self,
  name,
  value = True 
)
Tells lists to not clear default list values when set from
command line.

Definition at line 314 of file VarParsing.py.

00315                                                   :
00316         """Tells lists to not clear default list values when set from
00317         command line."""
00318         if not self._register.has_key (name):
00319             print "Error:  '%s' not registered." \
00320                   % name
00321             raise RuntimeError, "Unknown variable"
00322         if self._register[name] != VarParsing.multiplicity.list:
00323             print "Error: '%s' is not a list" % name
00324             raise RuntimeError, "Faulty 'setNoDefaultClear' command"
00325         self._noDefaultClear[name] = bool (value)
00326 

def VarParsing::VarParsing::setType (   self,
  name,
  mytype 
)
Change the type of 'name' to 'mytype'

Definition at line 437 of file VarParsing.py.

00438                                     :
00439         """Change the type of 'name' to 'mytype'"""
00440         if not VarParsing.varType.isValidValue (mytype):
00441             print "Error: VarParsing.setType() must use ",\
00442                   "VarParsing.varType."
00443             raise RuntimeError, "Improper 'type' value"
00444         oldVal = self.__getattr__ (name, noTags = True)
00445         self._types[name] = mytype
00446         self.setDefault (name, oldVal)
00447         

def VarParsing::VarParsing::setupTags (   self,
  kwargs 
)
Sets up information for tags for output names

Definition at line 140 of file VarParsing.py.

00141                                   :
00142         """Sets up information for tags for output names"""
00143         necessaryKeys = set (['ifCond', 'tag'])
00144         allowedKeys   = set (['tagArg'])
00145         for key in kwargs.keys():
00146             if key in allowedKeys:
00147                 continue
00148             if key in necessaryKeys:
00149                 necessaryKeys.remove (key)
00150                 continue
00151             # if we're here, then we have a key that's not understood
00152             print "Unknown option '%s'" % key
00153             raise RuntimeError, "Unknown option"
00154         if necessaryKeys:
00155             # if this is not empty, then we didn't have a key that was
00156             # necessary.
00157             print "Missing keys: %s" % necessaryKeys
00158             raise runtimeError, "Missing keys"
00159         tag = kwargs.get('tag')
00160         del kwargs['tag']
00161         self._tags[tag] = kwargs
00162         self._tagOrder.append (tag)
00163 


Member Data Documentation

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

Definition at line 20 of file VarParsing.py.

tuple VarParsing::VarParsing::commaRE = re.compile(r',') [static]

Definition at line 15 of file VarParsing.py.

tuple VarParsing::VarParsing::falseRE = re.compile(r'^false$', re.IGNORECASE) [static]

Definition at line 17 of file VarParsing.py.

Post-loading processing #.

sections

Definition at line 170 of file VarParsing.py.

tuple VarParsing::VarParsing::multiplicity = Enumerate("singleton list", "multiplicity") [static]

Definition at line 13 of file VarParsing.py.

tuple VarParsing::VarParsing::trueRE = re.compile(r'^true$', re.IGNORECASE) [static]

Definition at line 16 of file VarParsing.py.

tuple VarParsing::VarParsing::varType = Enumerate("bool int float string tagString") [static]

Definition at line 14 of file VarParsing.py.