Пример #1
0
 def _yield_formatted(self, values):
     for item in values:
         if VariableSplitter(item).is_dict_variable():
             yield item
         else:
             name, value = split_from_equals(item)
             if value is None:
                 raise DataError("Dictionary item '%s' does not contain "
                                 "'=' separator." % item)
             yield name, value
 def _is_named(self, arg, previous_named, variables=None):
     name, value = split_from_equals(arg)
     if value is None:
         return False
     if variables:
         name = variables.replace_scalar(name)
     argspec = self._argspec
     if previous_named or name in argspec.kwonlyargs or argspec.kwargs:
         return True
     return argspec.supports_named and name in argspec.positional
Пример #3
0
 def _is_named(self, arg, variables=None):
     if not (is_string(arg) and '=' in arg):
         return False
     name, value = split_from_equals(arg)
     if value is None:
         return False
     if self._argspec.kwargs:
         return True
     if not self._argspec.supports_named:
         return False
     if variables:
         name = variables.replace_scalar(name)
     return name in self._argspec.positional
Пример #4
0
 def resolve(self, arguments, variables=None):
     positional = []
     named = []
     for arg in arguments:
         if self._is_dict_var(arg):
             named.append(arg)
         elif self._is_named(arg, variables):
             named.append(split_from_equals(arg))
         elif named:
             self._raise_positional_after_named()
         else:
             positional.append(arg)
     return positional, named
Пример #5
0
 def _is_named(self, arg, variables=None):
     if not (is_string(arg) and '=' in arg):
         return False
     name, value = split_from_equals(arg)
     if value is None:
         return False
     if self._argspec.kwargs or self._argspec.kwonlyargs:
         return True
     if not self._argspec.supports_named:
         return False
     if variables:
         name = variables.replace_scalar(name)
     return name in self._argspec.positional
Пример #6
0
 def resolve(self, arguments, variables=None):
     positional = []
     named = []
     for arg in arguments:
         if self._is_dict_var(arg):
             named.append(arg)
         elif self._is_named(arg, variables):
             named.append(split_from_equals(arg))
         elif named:
             self._raise_positional_after_named()
         else:
             positional.append(arg)
     return positional, named