Exemplo n.º 1
0
 def __init__(self,
              name,
              type="",
              default="",
              description="",
              explanation="",
              valued=0,
              max_occur=None,
              auto_split=None,
              hide=0,
              range_delta=1,
              cook=None):
     self.__super.__init__ \
         ( name, type or self.default_type, default
         , description, explanation, cook
         )
     self.value = TFL.PL_List(undefined='')
     self.valued = valued or (self.type != "B")
     if max_occur is None:
         max_occur = [1, 0][auto_split is not None]
     self.max_occur = max_occur
     self.list_p = auto_split
     self.auto_split = auto_split or [",", None][self.type == "S"]
     self.hide = hide or name[:2] == "__"
     self.range_delta = range_delta
     if default:
         self._cook_default_opt(default)
Exemplo n.º 2
0
 def _setup_arg(self, arg_spec):
     self.argn = 0
     self.argument = TFL.PL_List(undefined=Arg())
     self.arg_dict = TFL.PL_Dict(undefined=Arg())
     self.argv = TFL.PL_List(undefined="")
     self.argd = TFL.PL_Dict(undefined="")
     for a in arg_spec:
         if isinstance(a, Arg):
             arg = a
         else:
             if self.arg_spec_pat.match(a):
                 match_group = self.arg_spec_pat.group
                 arg = Arg \
                     ( name        = match_group ("name")
                     , type        = match_group ("type")
                     , default     = match_group ("default")
                     , description = match_group ("help")
                     )
             else:
                 raise Cmd_Error("Invalid arg-spec: `%s'" % a)
         self.argument.append(arg)
         self.argv.append(arg.value)
         self.arg_dict[arg.name] = arg