This sealer returns an equivalent of a ``namedtuple``.
359204
def tuple_sealer(fields, defaults):
    
    baseclass_name = 'FieldsBase_for__{0}'.format('__'.join(fields))
    global_namespace, local_namespace = make_init_func(
        fields, defaults, baseclass_name,
        header_name='__new__',
        header_start='def {func_name}(cls',
        header_end='):\n',
        super_call_start='return tuple.__new__(cls, (',
        super_call_end='))\n',
        super_call_pass_kwargs=False, set_attributes=False,
    )

    def __getnewargs__(self):
        return tuple(self)

    def __repr__(self):
        return "{0}({1})".format(
            self.__class__.__name__,
            ", ".join(a + "=" + repr(getattr(self, a)) for a in fields)
        )

    return type(baseclass_name, (tuple,), dict(
        [(name, property(itemgetter(i))) for i, name in enumerate(fields)],
        __new__=local_namespace['__new__'],
        __getnewargs__=__getnewargs__,
        __repr__=__repr__,
        __slots__=(),
    ))
1319933
def as_tuple(obj):
    "  "

    if not obj:
        return tuple()

    if isinstance(obj, (tuple, set, list)):
        return tuple(obj)

    if hasattr(obj, '__iter__') and not isinstance(obj, dict):
        return obj

    return obj,
112816
def get_train_fns(self) -> Tuple[List[str], List[str]]:
        
        return self.prefixes_to_fns(self.train_prefixes)
378185
def get_unique_named_object(root, name):
    
    a = get_children(lambda x: hasattr(x, 'name') and x.name == name, root)
    assert len(a) == 1
    return a[0]
146406
def namedModule(name):
    """"""
    topLevel = __import__(name)
    packages = name.split(".")[1:]
    m = topLevel
    for p in packages:
        m = getattr(m, p)
    return m
346142
def namespace(self, prefix=None):
        
        ns = self.schema.tns
        if ns[0] is None:
            ns = (prefix, ns[1])
        return ns
530922
def named_relations(self, name, neg=False):
        '''
        '''
        if self.internalLinks and not neg:

            if isinstance(name, six.string_types):
                return filter(lambda x: x.name == name,
                              self.internalLinks)

            elif isinstance(name, list):
                return filter(lambda x: x.name in name,
                              self.internalLinks)
            else:
                return None #should rise error

        elif self.internalLinks and neg:

            if isinstance(name, six.string_types):
                return filter(lambda x: x.name != name,
                              self.internalLinks)

            elif isinstance(name, list):
                return filter(lambda x: x.name not in name,
                              self.internalLinks)
            else:
                return None #should rise error
      
        else:
            return []
757070
def get_list_w_id2nts(ids, id2nts, flds, dflt_null=""):
    """"""
    combined_nt_list = []
    # 1. Instantiate namedtuple object
    ntobj = cx.namedtuple("Nt", " ".join(flds))
    # 2. Fill dict with namedtuple objects for desired ids
    for item_id in ids:
        # 2a. Combine various namedtuples into a single namedtuple
        nts = [id2nt.get(item_id) for id2nt in id2nts]
        vals = _combine_nt_vals(nts, flds, dflt_null)
        combined_nt_list.append(ntobj._make(vals))
    return combined_nt_list
700132
def to_tuple(self, iterable, surround="()", joiner=", "):
    """"""
    return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1])
953353
def _namedtupleload(l: Loader, value: Dict[str, Any], type_) -> Tuple:
    
    if not hasattr(type_, '__dataclass_fields__'):
        fields = set(type_._fields)
        optional_fields = set(getattr(type_, '_field_defaults', {}).keys())
        type_hints = type_._field_types
    else:
        #dataclass
        import dataclasses
        fields = set(type_.__dataclass_fields__.keys())
        optional_fields = {k for k,v in type_.__dataclass_fields__.items() if not (isinstance(getattr(v, 'default', dataclasses._MISSING_TYPE()), dataclasses._MISSING_TYPE) and isinstance(getattr(v, 'default_factory', dataclasses._MISSING_TYPE()), dataclasses._MISSING_TYPE))}
        type_hints = {k: v.type for k,v in type_.__dataclass_fields__.items()}

        #Name mangling

        # Prepare the list of the needed name changes
        transforms = []  # type: List[Tuple[str, str]]
        for field in fields:
            if type_.__dataclass_fields__[field].metadata:
                name = type_.__dataclass_fields__[field].metadata.get('name')
                if name:
                    transforms.append((field, name))
        # Do the needed name changes
        if transforms:
            value = value.copy()
            for pyname, dataname in transforms:
                if dataname in value:
                    tmp = value[dataname]
                    del value[dataname]
                    value[pyname] = tmp

    necessary_fields = fields.difference(optional_fields)
    try:
        vfields = set(value.keys())
    except AttributeError as e:
        raise TypedloadAttributeError(str(e), value=value, type_=type_)

    if necessary_fields.intersection(vfields) != necessary_fields:
        raise TypedloadValueError(
            'Value does not contain fields: %s which are necessary for type %s' % (
                necessary_fields.difference(vfields),
                type_
            ),
            value=value,
            type_=type_,
        )

    fieldsdiff = vfields.difference(fields)
    if l.failonextra and len(fieldsdiff):
        extra = ', '.join(fieldsdiff)
        raise TypedloadValueError(
            'Dictionary has unrecognized fields: %s and cannot be loaded into %s' % (extra, type_),
            value=value,
            type_=type_,
        )

    params = {}
    for k, v in value.items():
        if k not in fields:
            continue
        params[k] = l.load(
            v,
            type_hints[k],
            annotation=Annotation(AnnotationType.FIELD, k),
        )
    return type_(**params)
1359998
def prefix(cls, name):
        
        attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
        return TreeModelMeta(
            '_'.join([name, cls.__name__]),
            (TreeModel,), attrs)
173210
def get_named_unicode(self, i):
        """"""

        index = i.index
        value = []
        try:
            if next(i) != '{':
                raise SyntaxError("Named Unicode missing '{'' at %d!" % (i.index - 1))
            c = next(i)
            while c != '}':
                value.append(c)
                c = next(i)
        except StopIteration:
            raise SyntaxError("Unmatched '}' at %d!" % index)

        return ''.join(value)
1015802
def named_function(name):
    """"""
    name_parts = name.split('.')
    module = named_object('.'.join(name_parts[:-1]))
    func = getattr(module, name_parts[-1])
    if hasattr(func, 'original_func'):
        func = func.original_func
    return func
5494
def mapper(mapping, _nt_name='NT'):
    
    if isinstance(mapping, Mapping) and not isinstance(mapping, AsDict):
        for key, value in list(mapping.items()):
            mapping[key] = mapper(value)
        return namedtuple_wrapper(_nt_name, **mapping)
    elif isinstance(mapping, list):
        return [mapper(item) for item in mapping]
    return mapping
1085450
def is_namedtuple(val):
    
    val_type = type(val)
    bases = val_type.__bases__
    if len(bases) != 1 or bases[0] != tuple:
        return False
    fields = getattr(val_type, '_fields', None)
    return all(isinstance(n, str) for n in fields)
950027
def LookupNamespace(self, prefix):
        
        ret = libxml2mod.xmlTextReaderLookupNamespace(self._o, prefix)
        return ret
690286
def get_namedtuple(cls, field_mappings, name="Record"):
    """"""
    return namedtuple(name, [fm.destination_name for fm in field_mappings])