Generated with typing.NamedTuple
335569
def is_namedtuple(type_: Type[Any]) -> bool:
    '''
    
    '''
    return _issubclass(type_, tuple) and hasattr(type_, '_field_types') and hasattr(type_, '_fields')
1045556
private static Collection<Tuple> getTuples( List<VarDef> varDefs, int varStart, int varEnd, int tupleSize)
    {
    Collection<Tuple> tuples = new ArrayList<Tuple>();

    // For each variable up to the last included...
    for( int i = varStart; i < varEnd; i++)
      {
      // Combine each valid value...
      VarDef                nextVar   = varDefs.get(i);
      Iterator<VarValueDef> values    = nextVar.getValidValues();
      if( !values.hasNext())
        {
        throw new IllegalStateException( "Can't complete tuples -- no valid values defined for var=" + nextVar);
        }

      // With all subtuples from the remaining variables.
      Collection<Tuple> subTuples =
        tupleSize==1
        ? null
        : getTuples( varDefs, i + 1, varEnd + 1, tupleSize - 1);

      // Only one variable to combine?
      if( subTuples == null)
        {
        // Yes, return list of 1-tuples for this variable.
        while( values.hasNext())
          {
          tuples.add( new Tuple( new VarBindingDef( nextVar, values.next())));
          }
        }

      // Any compatible subtuples for remaining variables?
      else if( !subTuples.isEmpty())
        {
        // Yes, add all compatible combinations with values for this variable.
        while( values.hasNext())
          {
          VarBindingDef nextBinding = new VarBindingDef( nextVar, values.next());
          for( Tuple subTuple : subTuples)
            {
            Tuple nextTuple = new Tuple( nextBinding).addAll( subTuple);
            if( nextTuple.isCompatible())
              {
              tuples.add( nextTuple);
              }
            }
          }
        }
      }
    
    return tuples;
    }
1075331
def _prep_obj(self, obj, parent, parents_ids=EMPTY_FROZENSET, is_namedtuple=False):
        """"""
        original_type = type(obj)
        try:
            if is_namedtuple:
                obj = obj._asdict()
            else:
                obj = obj.__dict__
        except AttributeError:
            try:
                obj = {i: getattr(obj, i) for i in obj.__slots__}
            except AttributeError:
                self[UNPROCESSED].append(obj)
                return unprocessed

        result = self._prep_dict(obj, parent=parent, parents_ids=parents_ids,
                                 print_as_attribute=True, original_type=original_type)
        result = "nt{}".format(result) if is_namedtuple else "obj{}".format(result)
        return result
355100
def namedlist(objname, fieldnames):
    ''
    class NamedListTemplate(list):
        __name__ = objname
        _fields = fieldnames

        def __init__(self, L=None, **kwargs):
            if L is None:
                L = [None]*len(fieldnames)
            super().__init__(L)
            for k, v in kwargs.items():
                setattr(self, k, v)

        @classmethod
        def length(cls):
            return len(cls._fields)

    for i, attrname in enumerate(fieldnames):
        # create property getter/setter for each field
        setattr(NamedListTemplate, attrname, property(operator.itemgetter(i), itemsetter(i)))

    return NamedListTemplate
1272505
def types(cls, **kwargs):
    """"""
    named = {name: factory(Arguments._fields.index(name), name)
             for name, factory in six.iteritems(kwargs)}
    return cls(**named)
800328
def get_named_by_definition(cls, element_list, string_def):
        """"""
        try:
            return next(
                (
                    st.value
                    for st in element_list
                    if st.definition == string_def
                )
            )
        except Exception:
            return None
634298
def get_type_name(t):
    
    # Lookup in the mapping
    try:
        return __type_names[t]
    except KeyError:
        # Specific types
        if issubclass(t, six.integer_types):
            return _(u'Integer number')

        # Get name from the Type itself
        return six.text_type(t.__name__).capitalize()
824730
@Override
	public Tuple createTuple(EntityKeyMetadata entityKeyMetadata, OperationContext operationContext) {
		return identityColumnAwareGridDialect.createTuple( entityKeyMetadata, operationContext );
	}
1020376
def _hijack_namedtuple():
    
    # hijack only one time
    if hasattr(collections.namedtuple, "__hijack"):
        return

    global _old_namedtuple  # or it will put in closure
    global _old_namedtuple_kwdefaults  # or it will put in closure too

    def _copy_func(f):
        return types.FunctionType(f.__code__, f.__globals__, f.__name__,
                                  f.__defaults__, f.__closure__)

    def _kwdefaults(f):
        # __kwdefaults__ contains the default values of keyword-only arguments which are
        # introduced from Python 3. The possible cases for __kwdefaults__ in namedtuple
        # are as below:
        #
        # - Does not exist in Python 2.
        # - Returns None in <= Python 3.5.x.
        # - Returns a dictionary containing the default values to the keys from Python 3.6.x
        #    (See https://bugs.python.org/issue25628).
        kargs = getattr(f, "__kwdefaults__", None)
        if kargs is None:
            return {}
        else:
            return kargs

    _old_namedtuple = _copy_func(collections.namedtuple)
    _old_namedtuple_kwdefaults = _kwdefaults(collections.namedtuple)

    def namedtuple(*args, **kwargs):
        for k, v in _old_namedtuple_kwdefaults.items():
            kwargs[k] = kwargs.get(k, v)
        cls = _old_namedtuple(*args, **kwargs)
        return _hack_namedtuple(cls)

    # replace namedtuple with the new one
    collections.namedtuple.__globals__["_old_namedtuple_kwdefaults"] = _old_namedtuple_kwdefaults
    collections.namedtuple.__globals__["_old_namedtuple"] = _old_namedtuple
    collections.namedtuple.__globals__["_hack_namedtuple"] = _hack_namedtuple
    collections.namedtuple.__code__ = namedtuple.__code__
    collections.namedtuple.__hijack = 1

    # hack the cls already generated by namedtuple.
    # Those created in other modules can be pickled as normal,
    # so only hack those in __main__ module
    for n, o in sys.modules["__main__"].__dict__.items():
        if (type(o) is type and o.__base__ is tuple
                and hasattr(o, "_fields")
                and "__reduce__" not in o.__dict__):
            _hack_namedtuple(o)
960229
def type_name(self, t, generate=True):
        
        # no Test case for these
        # elif isinstance(t, typedesc.Argument):
        # elif isinstance(t, typedesc.CvQualifiedType):
        # elif isinstance(t, typedesc.Variable):
        #   return "%s" % self.type_name(t.typ, generate)
        # elif isinstance(t, typedesc.Enumeration):
        #   return t.name

        if isinstance(t, typedesc.FundamentalType):
            return self.FundamentalType(t)
        elif isinstance(t, typedesc.ArrayType):
            return "%s * %s" % (self.type_name(t.typ, generate), t.size)
        elif isinstance(t, typedesc.PointerType):
            self.enable_pointer_type()
            return "POINTER_T(%s)" % (self.type_name(t.typ, generate))
        elif isinstance(t, typedesc.FunctionType):
            args = [
                self.type_name(
                    x,
                    generate) for x in [
                    t.returns] +
                list(
                    t.iterArgTypes())]
            if "__stdcall__" in t.attributes:
                return "ctypes.WINFUNCTYPE(%s)" % ", ".join(args)
            else:
                return "ctypes.CFUNCTYPE(%s)" % ", ".join(args)
        # elif isinstance(t, typedesc.Structure):
        # elif isinstance(t, typedesc.Typedef):
        # elif isinstance(t, typedesc.Union):
        return t.name
678056
function TupleTypeAnnotation(node, print) {
  this.push("[");
  print.join(node.types, { separator: ", " });
  this.push("]");
}
281379
def asTuple(self):
        
        t = []
        k = sorted(self.keys())
        for key in k:
            t.append((key, self[key]))
        return tuple(t)
169348
public static Tuple stringToTuple(String line) {
        // tokenize the line
        String nameParts[] = line.split("\t");

        // create the tuple, setting the first and last names
        Tuple tuple = new Tuple();
        tuple.set(TupleFields.LAST_NAME, nameParts[0]);
        tuple.set(TupleFields.FIRST_NAME, nameParts[1]);
        return tuple;
    }
945110
def p_typename(self,t):
    "'"
    t[0] = TypeX(t[1],None) if len(t) == 2 else TypeX(t[1],int(t[3]))
1141885
def generate(
        cls: Type[T], data: Generic, name: str = None, *, recursive: bool = True
    ) -> T:
        """"""
        if name is None:
            name = cls.__name__
        kls = make_class(name, {k: ib(default=None) for k in data}, bases=(cls,))
        data = {
            k: (
                cls.generate(v, k.title())
                if recursive and isinstance(v, Mapping)
                else v
            )
            for k, v in data.items()
        }
        return kls(**data)
927536
def _new_type(cls, args):
        

        fformat = ["%r" if f is None else "%s=%%r" % f for f in args]
        fformat = "(%s)" % ", ".join(fformat)

        class _ResultTuple(cls):
            __slots__ = ()
            _fformat = fformat
            if args:
                for i, a in enumerate(args):
                    if a is not None:
                        vars()[a] = property(itemgetter(i))
                del i, a

        return _ResultTuple
1013775
def nameTuple(s: Influence) -> Tuple[str, str]:
    
    return top_grounding(s.subj), top_grounding(s.obj)