Return an element from ``inp`` or from scratch.
776358
def element(self, inp=None):
        """"""
        if inp is not None:
            s = str(inp)[:self.length]
            s += ' ' * (self.length - len(s))
            return s
        else:
            return ' ' * self.length
1002983
def gep(self, i):
        
        if not isinstance(i.type, IntType):
            raise TypeError(i.type)
        return self.element
30074
def from_element(self, element, defaults={}):
        """"""
        if isinstance(defaults, SvdElement):
            defaults = vars(defaults)
        for key in self.props:
            try:
                value = element.find(key).text
            except AttributeError:  # Maybe it's attribute?
                default = defaults[key] if key in defaults else None
                value = element.get(key, default)
            if value is not None:
                if key in self.props_to_integer:
                    try:
                        value = int(value)
                    except ValueError:  # It has to be hex
                        value = int(value, 16)
                elif key in self.props_to_boolean:
                    value = value.lower() in ("yes", "true", "t", "1")

            setattr(self, key, value)
311363
def elements(self):
        """"""
        offset = self.EXTRA_DIGITS
        if offset:
            return (self._id[:offset], self.company_prefix, self._reference,
                    self.check_digit)
        else:
            return (self.company_prefix, self._reference, self.check_digit)
484693
def inp(i):
    

    t=i['text']

    if con_encoding=='':
       x=sys.stdin.encoding
       if x==None: 
          b=t.encode()
       else:
          b=t.encode(x, 'ignore')
    else:
       b=t.encode(con_encoding, 'ignore') # pragma: no cover 

    if sys.version_info[0]>2:
       try: b=b.decode(sys.stdin.encoding)
       except Exception as e: 
         try: b=b.decode('utf8')
         except Exception as e: pass

    if sys.version_info[0]>2:
       s=input(b)
    else:
       x=sys.stdin.encoding
       if x==None:
          x='utf8'
       s=raw_input(b).decode(x).encode('utf8')

    return {'return':0, 'string':s}
575640
def node_from_nid(self, nid):
        """"""
        for node in self.iflat_nodes():
            if node.node_id == nid: return node
        raise ValueError("Cannot find node with node id: %s" % nid)
1298182
def from_raw(self, raw: RawScalar) -> Optional[bool]:
        """"""
        if isinstance(raw, bool):
            return raw
98077
def _ge_from_lt(self, other):
    """"""
    op_result = self.__lt__(other)
    if op_result is NotImplemented:
        return NotImplemented
    return not op_result
624303
def _return_object(self, container, item_name):
        """"""
        coll = container.get_collection()
        for item in coll:
            if item.name == item_name:
                return item
296624
def _elements_to_dict(data, position, obj_end, opts):
    """"""
    result = opts.document_class()
    pos = position
    for key, value, pos in _iterate_elements(data, position, obj_end, opts):
        result[key] = value
    if pos != obj_end:
        raise InvalidBSON('bad object or element length')
    return result
47521
def from_elements(cls, elts=None):
        
        node = cls()
        if elts is None:
            node.elts = []
        else:
            node.elts = [const_factory(e) if _is_const(e) else e for e in elts]
        return node
734211
def get(key, default=-1):
        """"""
        if isinstance(key, int):
            return DI(key)
        if key not in DI._member_map_:
            extend_enum(DI, key, default)
        return DI[key]
131693
def _get_object(data, position, obj_end, opts, dummy):
    """"""
    obj_size, end = _get_object_size(data, position, obj_end)
    if _raw_document_class(opts.document_class):
        return (opts.document_class(data[position:end + 1], opts),
                position + obj_size)

    obj = _elements_to_dict(data, position + 4, end, opts)

    position += obj_size
    if "$ref" in obj:
        return (DBRef(obj.pop("$ref"), obj.pop("$id", None),
                      obj.pop("$db", None), obj), position)
    return obj, position
1283605
def get_element_by_id(self, ident):
        """"""
        for group in list(self.toc.keys()):
            for name in list(self.toc[group].keys()):
                if self.toc[group][name].ident == ident:
                    return self.toc[group][name]
        return None
1310315
def getElementById(self, node, id, default=join):
        """"""
        attrget = self.getAttr
        ELEMENT_NODE = node.ELEMENT_NODE
        for child in node.childNodes:
            if child.nodeType == ELEMENT_NODE:
                if attrget(child, 'id') == id:
                    return child
        if default is not join:
            return default
        raise KeyError, name
497350
def getElements(self, node, name, nsuri=None):
        """"""
        nsmatch = self.nsUriMatch
        result = []
        ELEMENT_NODE = node.ELEMENT_NODE
        for child in node.childNodes:
            if child.nodeType == ELEMENT_NODE:
                if ((child.localName == name or name is None) and (
                    (nsuri is None) or nsmatch(child.namespaceURI, nsuri))):
                    result.append(child)
        return result
1190037
def get(key, default=-1):
        """"""
        if isinstance(key, int):
            return Parameter(key)
        if key not in Parameter._member_map_:
            extend_enum(Parameter, key, default)
        return Parameter[key]