Turns a coded string by code() into a NameID class instance.

    :param txt: The coded string
486413
def decode(txt):
    
    _nid = NameID()
    for part in txt.split(","):
        if part.find("=") != -1:
            i, val = part.split("=")
            try:
                setattr(_nid, ATTR[int(i)], unquote(val))
            except:
                pass
    return _nid
315010
def from_files(cls, directory: str) -> 'Vocabulary':
        
        logger.info("Loading token dictionary from %s.", directory)
        with codecs.open(os.path.join(directory, NAMESPACE_PADDING_FILE), 'r', 'utf-8') as namespace_file:
            non_padded_namespaces = [namespace_str.strip() for namespace_str in namespace_file]

        vocab = cls(non_padded_namespaces=non_padded_namespaces)

        # Check every file in the directory.
        for namespace_filename in os.listdir(directory):
            if namespace_filename == NAMESPACE_PADDING_FILE:
                continue
            if namespace_filename.startswith("."):
                continue
            namespace = namespace_filename.replace('.txt', '')
            if any(namespace_match(pattern, namespace) for pattern in non_padded_namespaces):
                is_padded = False
            else:
                is_padded = True
            filename = os.path.join(directory, namespace_filename)
            vocab.set_from_file(filename, is_padded, namespace=namespace)

        return vocab
309002
def check_dns_txt(domain, prefix, code):
    
    token = '{}={}'.format(prefix, code)
    try:
        for rr in dns.resolver.query(domain, 'TXT'):
            if token in rr.to_text():
                return True
    except:
        logger.debug('', exc_info=True)
    return False
873047
def from_text(name, ttl, rdclass, rdtype, *text_rdatas):
    

    return from_text_list(name, ttl, rdclass, rdtype, text_rdatas)
102658
def parse_text_to_table(txt):
	
	res = []                # resulting table
	delim = identify_delim(txt)
	print('txt to parse = ', txt, '\ndelim=',delim)
	if delim == '' or delim == ' ':
		fixed_split = identify_col_pos(txt)
		if fixed_split == []:
			res = []
		else:
			res = parse_text_by_col_pos(txt, fixed_split)
	else:
		res = parse_text_by_delim(txt, delim)


	return res
542515
def register_name(self, clsdict):
        
        if self.name is None:
            return
        clsdict[self.name] = self.value
692068
def cmd_add(self, txt):
        
        self.show_output('Adding ', txt)
        self.raw.add(txt)
        print(self.raw)
        return 'Added ' + txt
721910
def to_namedtuple(self):
        
        keys = filter(lambda x: not x.startswith("_"), self.__dict__)
        opt_nt = namedtuple(self.__class__.__name__, keys)
        filtered_dict = dict(map(lambda x: (x, self.__dict__[x]), keys))

        return opt_nt(**filtered_dict)
686772
def generate_filename(self, instance, filename):
        
        from unidecode import unidecode

        return super().generate_filename(instance, unidecode(force_text(filename)))
369200
def escape_identifier(text, reg=KWD_RE):
    """"""

    # see http://docs.python.org/reference/lexical_analysis.html#identifiers
    if not text:
        return "_"
    if text[0].isdigit():
        text = "_" + text
    return reg.sub(r"\1_", text)
1180352
def decode_name(name, barcodemap):
    
    for barcode in barcodemap:
        if barcode in name:
            return barcodemap[barcode]

    return name
796467
private static String encode(final String txt) {
        try {
            return URLEncoder.encode(
                txt, Charset.defaultCharset().name()
            );
        } catch (final UnsupportedEncodingException ex) {
            throw new IllegalStateException(ex);
        }
    }
1051900
def _printable_id_code(self):
        
        code = str(self.id_code)
        while len(code) < self._code_size:
            code = '0' + code

        return code
665584
def _from_string(cls, serialized):
        
        parse = cls.URL_RE.match(serialized)
        if not parse:
            raise InvalidKeyError(cls, serialized)

        parse = parse.groupdict()
        if parse['definition_id']:
            parse['definition_id'] = cls.as_object_id(parse['definition_id'])

        return cls(**{key: parse.get(key) for key in cls.KEY_FIELDS})
742614
def normalize_text(self, txt):
        ""
        # - for TTF unicode fonts: unicode object (utf8 encoding)
        # - for built-in fonts: string instances (latin 1 encoding)
        if self.unifontsubset and isinstance(txt, str) and not PY3K:
            txt = txt.decode('utf8')
        elif not self.unifontsubset and isinstance(txt, unicode) and not PY3K:
            txt = txt.encode('latin1')
        return txt
16273
def class_from_string(name):
    '''
    
    '''
    module_name, class_name = name.rsplit('.', 1)
    __import__(module_name)
    module = sys.modules[module_name]
    return getattr(module, class_name)
1238596
def txt2mecab(text, **kwargs):
    '''  '''
    mecab_out = _internal_mecab_parse(text, **kwargs).splitlines()
    tokens = [MeCabToken.parse(x) for x in mecab_out]
    return MeCabSent(text, tokens)