r""" Retrieve mapping from English letters to l33t like E => 3 or A => /\ or /-\ or @
501962
def get_leet_map():
     """
    df = get_longest_table(
        'https://sites.google.com/site/inhainternetlanguage/different-internet-languages/l33t/list-of-l33ts', header=None)
    df = df.drop(index=0).iloc[:, :2]
    df.columns = ['eng', 'l33t']
    df['l33t'] = df['l33t'].str.split(',')
    table = []
    for i, row in df.iterrows():
        for s in row['l33t']:
            table.append((row['eng'].strip(), s.strip()))
    table = pd.DataFrame(table, columns=df.columns)
    leet_path = os.path.join(DATA_PATH, 'l33t.csv')
    logger.info('Saving l33t dictionary (character mapping) to {}'.format(leet_path))
    table.to_csv(leet_path)
    return table
1083650
def _remap_pair(self, operation, src, dst, *args, **kw):
        """"""
        return (
            self._remap_input(operation + '-from', src, *args, **kw),
            self._remap_input(operation + '-to', dst, *args, **kw)
        )
891210
def get_colmap(fns, pattern, single_col=False, antipattern=False):
    """"""
    colmap = {}
    for fn in fns:
        header = tsvreader.get_tsv_header(fn)
        basefn = os.path.basename(fn)
        cols = tsvreader.get_cols_in_file(pattern, header, single_col)
        if antipattern:
            anticols = tsvreader.get_cols_in_file(antipattern, header,
                                                  single_col)
            cols = [col for col in cols if col not in anticols]
        if cols:
            colmap[basefn] = cols
    return colmap
558019
def extract_translations(self, string):
        """"""

        trans = []
        for t in Lexer(string.decode("utf-8"), None).tokenize():
            if t.token_type == TOKEN_BLOCK:
                if not t.contents.startswith(
                        (self.tranz_tag, self.tranzchoice_tag)):
                    continue

                is_tranzchoice = t.contents.startswith(
                    self.tranzchoice_tag +
                    " ")
                kwargs = {
                    "id": self._match_to_transvar(id_re, t.contents),
                    "number": self._match_to_transvar(number_re, t.contents),
                    "domain": self._match_to_transvar(domain_re, t.contents),
                    "locale": self._match_to_transvar(locale_re, t.contents),
                    "is_transchoice": is_tranzchoice, "parameters": TransVar(
                        [x.split("=")[0].strip() for x in properties_re.findall(t.contents) if x],
                        TransVar.LITERAL
                    ),
                    "lineno": t.lineno,
                }

                trans.append(Translation(**kwargs))
        return trans
63489
def alphanumeric(text):
    """"""
    return "".join([c for c in text if re.match(r'\w', c)])
1026896
def b(s):
    """"""
    if sys.version < '3':
        if isinstance(s, unicode): #pylint: disable=undefined-variable
            return s.encode('utf-8')
    else:
        return s
1116292
def full_process(s, force_ascii=False):
    """"""

    if force_ascii:
        s = asciidammit(s)
    # Keep only Letters and Numbers (see Unicode docs).
    string_out = StringProcessor.replace_non_letters_non_numbers_with_whitespace(s)
    # Force into lowercase.
    string_out = StringProcessor.to_lower_case(string_out)
    # Remove leading and trailing whitespaces.
    string_out = StringProcessor.strip(string_out)
    return string_out
1337660
def get_regex(resolver_or_pattern):
    """"""
    try:
        regex = resolver_or_pattern.regex
    except AttributeError:
        regex = resolver_or_pattern.pattern.regex
    return regex
738343
def s_rec2latex(r, empty=""):
    """"""
    latex = ""
    names = r.dtype.names
    def translate(x):
        if x is None or str(x).lower == "none":
            x = empty
        return latex_quote(x)
    latex += r"\begin{tabular}{%s}" % ("".join(["c"]*len(names)),) + "\n"  # simple c columns
    latex += r"\hline"+"\n"
    latex += " & ".join([latex_quote(x) for x in names])+r"\\"+"\n"
    latex += r"\hline"+"\n"
    for data in r:
        latex += " & ".join([translate(x) for x in data])+r"\\"+"\n"
    latex += r"\hline"+"\n"
    latex += r"\end{tabular}"+"\n"
    return latex
1337942
def ParseFromString(self, text, message):
    """"""
    if not isinstance(text, str):
      text = text.decode('utf-8')
    return self.ParseLines(text.split('\n'), message)
1328138
def native_(s, encoding='latin-1', errors='strict'):
    '''
    
    '''
    if PY3:
        out = s if isinstance(s, text_type) else str(s, encoding, errors)
    else:
        out = s.encode(encoding, errors) if isinstance(s, text_type) else str(s)

    return out
1299246
def get_string(self):
    """"""
    ostr = ''
    errtotal = self.deletions['total']+self.insertions['total']+self.mismatches
    ostr += 'from '+str(self.alignment_length)+' bp of alignment'+"\n"
    ostr += '  '+str(float(errtotal)/float(self.alignment_length))+" error rate\n"
    ostr += '    '+str(float(self.mismatches)/float(self.alignment_length))+ " mismatches\n"
    ostr += '    '+str(float(self.deletions['total'])/float(self.alignment_length))+ " deletions\n"
    ostr += '      '+str(float(self.deletions['specific'])/float(self.alignment_length))+ " total deletions\n"
    ostr += '      '+str(float(self.deletions['homopolymer'])/float(self.alignment_length))+ " homopolymer deletions\n"
    ostr += '    '+str(float(self.insertions['total'])/float(self.alignment_length))+ " insertions\n"
    ostr += '      '+str(float(self.insertions['specific'])/float(self.alignment_length))+ " total insertions\n"
    ostr += '      '+str(float(self.insertions['homopolymer'])/float(self.alignment_length))+ " homopolymer insertions\n"
    ostr += '  More specific errors'+"\n"
    poss = ['-','A','C','G','T']
    ostr += '  -    A    C    G    T'+"\n"
    t = 0
    for p1 in poss:
      ostr += p1
      for p2 in poss:
        val = float(self.matrix[p1][p2])/float(self.alignment_length)
        ostr += " "+str(round(val,3))
        t += val
      ostr += "\n"
    ostr += "\n"
    return ostr
718534
def map_rus_to_lat(char):
    
    map_dict = {
        u'Е': u'E',
        u'Т': u'T',
        u'У': u'Y',
        u'О': u'O',
        u'Р': u'P',
        u'А': u'A',
        u'Н': u'H',
        u'К': u'K',
        u'Х': u'X',
        u'С': u'C',
        u'В': u'B',
        u'М': u'M',
    }
    # если буква есть в списке русских сиволов, преобразуем ее в латинский двойник
    if char in map_dict:
        return map_dict[char]
    else:
        return char
661611
def parse_pseudo_lang(self, sel, m, has_selector):
        """"""

        values = m.group('values')
        patterns = []
        for token in RE_VALUES.finditer(values):
            if token.group('split'):
                continue
            value = token.group('value')
            if value.startswith(('"', "'")):
                parts = css_unescape(value[1:-1], True).split('-')
            else:
                parts = css_unescape(value).split('-')

            new_parts = []
            first = True
            for part in parts:
                if part == '*' and first:
                    new_parts.append('(?!x\b)[a-z0-9]+?')
                elif part != '*':
                    new_parts.append(('' if first else '(-(?!x\b)[a-z0-9]+)*?\\-') + re.escape(part))
                if first:
                    first = False
            patterns.append(re.compile(r'^{}(?:-.*)?$'.format(''.join(new_parts)), re.I))
        sel.lang.append(ct.SelectorLang(patterns))
        has_selector = True

        return has_selector
1307783
def unicode2str(content):
    """"""
    if isinstance(content, dict):
        result = {}
        for key in content.keys():
            result[unicode2str(key)] = unicode2str(content[key])
        return result
    elif isinstance(content, list):
        return [unicode2str(element) for element in content]
    elif isinstance(content, int) or isinstance(content, float):
        return content
    else:
        return content.encode("utf-8")
90705
def unicode_left(s, width):
    """"""
    i = 0
    j = 0
    for ch in s:
        j += __unicode_width_mapping[east_asian_width(ch)]
        if width < j:
            break
        i += 1
    return s[:i]
1107272
def translate(self, closed_regex=True):
        
        """
        if closed_regex:
            return self.regex
        else:
            return translate(self.pattern, closed_regex=False, **self.flags)