parameters: (self, name, default=None, value=None, doc=None)
docstring: Add 'arg' to existing context. Args are only valid for their immediate context.
docstring_summary: Add 'arg' to existing context. Args are only valid for their immediate context.
docstring_tokens: Add arg to existing context . Args are only valid for their immediate context .
function: def add_arg(self, name, default=None, value=None, doc=None):
          """
          Add 'arg' to existing context. Args are only valid for their immediate context.
          """
          if name in self.arg_names:
              # Ignore the duplication if pass_all_args was set
              if not self.pass_all_args:
                  raise LoadException("arg '%s' has already been declared"%name)
          else:
              self.arg_names.append(name)
  
          resolve_dict = self.resolve_dict if self.include_resolve_dict is None else self.include_resolve_dict
  
          if not 'arg' in resolve_dict:
              resolve_dict['arg'] = {}
          arg_dict = resolve_dict['arg']
  
          # args can only be declared once. they must also have one and
          # only value at the time that they are declared.
          if value is not None:
              # value is set, error if declared in our arg dict as args
              # with set values are constant/grounded.
              # But don't error if pass_all_args was used to include this
              # context; rather just override the passed-in value.
              if name in arg_dict and not self.pass_all_args:
                  raise LoadException("cannot override arg '%s', which has already been set"%name)
              arg_dict[name] = value
          elif default is not None:
              # assign value if not in context
              if name not in arg_dict:
                  arg_dict[name] = default
          else:
              # no value or default: appending to arg_names is all we
              # need to do as it declares the existence of the arg.
              pass
  
          # add arg documentation string dict if it doesn't exist yet and if it can be used
          if not 'arg_doc' in resolve_dict:
              resolve_dict['arg_doc'] = {}
          arg_doc_dict = resolve_dict['arg_doc']
  
          if not value:
              # store the documentation for this argument
              arg_doc_dict[name] = (doc, default)
function_tokens: def add_arg ( self , name , default = None , value = None , doc = None ) : if name in self . arg_names : # Ignore the duplication if pass_all_args was set if not self . pass_all_args : raise LoadException ( "arg '%s' has already been declared" % name ) else : self . arg_names . append ( name ) resolve_dict = self . resolve_dict if self . include_resolve_dict is None else self . include_resolve_dict if not 'arg' in resolve_dict : resolve_dict [ 'arg' ] = { } arg_dict = resolve_dict [ 'arg' ] # args can only be declared once. they must also have one and # only value at the time that they are declared. if value is not None : # value is set, error if declared in our arg dict as args # with set values are constant/grounded. # But don't error if pass_all_args was used to include this # context; rather just override the passed-in value. if name in arg_dict and not self . pass_all_args : raise LoadException ( "cannot override arg '%s', which has already been set" % name ) arg_dict [ name ] = value elif default is not None : # assign value if not in context if name not in arg_dict : arg_dict [ name ] = default else : # no value or default: appending to arg_names is all we # need to do as it declares the existence of the arg. pass # add arg documentation string dict if it doesn't exist yet and if it can be used if not 'arg_doc' in resolve_dict : resolve_dict [ 'arg_doc' ] = { } arg_doc_dict = resolve_dict [ 'arg_doc' ] if not value : # store the documentation for this argument arg_doc_dict [ name ] = ( doc , default )