Used to override the pprint format method to get rid of unicode prefixes.

    E.g.: 'John' instead of u'John'.
336572
def _non_unicode_repr(objekt, context, maxlevels, level):
    
    repr_string, isreadable, isrecursive = pprint._safe_repr(objekt, context,
                                                             maxlevels, level)
    if repr_string.startswith('u"') or repr_string.startswith("u'"):
        repr_string = repr_string[1:]
    return repr_string, isreadable, isrecursive
456057
def remove_diacritics(self_or_cls, identifier):
        
        chars = ''
        for c in identifier:
            replacement = unicodedata.normalize('NFKD', c).encode('ASCII', 'ignore')
            if replacement != '':
                chars += bytes_to_unicode(replacement)
            else:
                chars += c
        return chars
211444
def _unicode_output(cursor, name, default_type, size, precision, scale):
    '''
    
    '''
    if default_type in (cx_Oracle.STRING, cx_Oracle.LONG_STRING,
                        cx_Oracle.FIXED_CHAR, cx_Oracle.CLOB):
        return cursor.var(six.text_type, size, cursor.arraysize)
1001136
def _clean_characters(x):
    
    if not isinstance(x, six.string_types):
        x = str(x)
    else:
        if not all(ord(char) < 128 for char in x):
            msg = "Found unicode character in input YAML (%s)" % (x)
            raise ValueError(repr(msg))
    for problem in [" ", ".", "/", "\\", "[", "]", "&", ";", "#", "+", ":", ")", "("]:
        x = x.replace(problem, "_")
    return x
1322406
def normalize(self, text):
        
        # Normalize to canonical unicode (using NFKC by default)
        if self.form is not None:
            text = unicodedata.normalize(self.form, text)

        # Strip out any control characters (they occasionally creep in somehow)
        for control in CONTROLS:
            text = text.replace(control, '')

        # Normalize unusual whitespace not caught by unicodedata
        text = text.replace('\u000b', ' ').replace('\u000c', ' ').replace(u'\u0085', ' ')
        text = text.replace('\u2028', '\n').replace('\u2029', '\n').replace('\r\n', '\n').replace('\r', '\n')

        # Normalize all hyphens, minuses and dashes to ascii hyphen-minus and remove soft hyphen entirely
        if self.hyphens:
            # TODO: Better normalization of em/en dashes to '--' if surrounded by spaces or start/end?
            for hyphen in HYPHENS | MINUSES:
                text = text.replace(hyphen, '-')
            text = text.replace('\u00ad', '')

        # Normalize all quotes and primes to ascii apostrophe and quotation mark
        if self.quotes:
            for double_quote in DOUBLE_QUOTES:
                text = text.replace(double_quote, '"')  # \u0022
            for single_quote in (SINGLE_QUOTES | APOSTROPHES | ACCENTS):
                text = text.replace(single_quote, "'")  # \u0027
            text = text.replace('′', "'")     # \u2032 prime
            text = text.replace('‵', "'")     # \u2035 reversed prime
            text = text.replace('″', "''")    # \u2033 double prime
            text = text.replace('‶', "''")    # \u2036 reversed double prime
            text = text.replace('‴', "'''")   # \u2034 triple prime
            text = text.replace('‷', "'''")   # \u2037 reversed triple prime
            text = text.replace('⁗', "''''")  # \u2057 quadruple prime

        if self.ellipsis:
            text = text.replace('…', '...').replace(' . . . ', ' ... ')  # \u2026

        if self.slashes:
            for slash in SLASHES:
                text = text.replace(slash, '/')

        if self.tildes:
            for tilde in TILDES:
                text = text.replace(tilde, '~')

        if self.strip:
            text = text.strip()

        # Collapse all whitespace down to a single space
        if self.collapse:
            text = ' '.join(text.split())
        return text
656977
def pprint(self, stream=None, indent=1, width=80, depth=None):
    
    pp.pprint(to_literal(self), stream, indent, width, depth)
128556
def strip_accents(string):
    
    return u''.join(
        (character for character in unicodedata.normalize('NFD', string)
         if unicodedata.category(character) != 'Mn'))
1056826
def sanitize_jid(s):
    """"""
    jid = unicode_to_ascii(s).lower()
    jid = WHITESPACE.sub('-', jid)
    jid = INVALID_JID_CHARS.sub('', jid)
    return jid.strip()[:256]
457118
def format(self, name=False, formatter=None, **kwargs):
        
        header = []
        if name:
            header.append(pprint_thing(self.name,
                                       escape_chars=('\t', '\r', '\n')) if
                          self.name is not None else '')

        if formatter is not None:
            return header + list(self.map(formatter))

        return self._format_with_header(header, **kwargs)
1291654
def sanitize_string(string_or_unicode):
    
    if isinstance(string_or_unicode, unicode):
        return string_or_unicode.strip()
    elif isinstance(string_or_unicode, str):
        return string_or_unicode.decode('utf-8').strip()
    else:  # e.g. if input is None
        return u''
956689
def pformat_codepoints(codepoints):
    
    printable = string.printable.replace("\n", "").replace("\r", "")
    line = []
    strings = ""
    for codepoint in codepoints:
        char = chr(codepoint)
        if char in printable:
            strings += char
        else:
            if strings != "":
                line.append(strings)
                strings = ""
            line.append(char)
    return line
1094930
def pp_hex(raw, reverse=True):
    
    if not reverse:
        return ''.join(['{:02x}'.format(v) for v in bytearray(raw)])
    return ''.join(reversed(['{:02x}'.format(v) for v in bytearray(raw)]))
246428
def _normalize_custom_param_name(name):
    

    replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D", '"'))
    for orig, replacement in replacements:
        name = name.replace(orig, replacement)
    return name
91444
def pprint(self):
        """"""

        items = sorted(self.items())
        return u"\n".join(u"%s=%s" % (k, v.pprint()) for k, v in items)
956524
def safe_print(ustring, errors='replace', **kwargs):
    
    encoding = sys.stdout.encoding or 'utf-8'
    if sys.version_info[0] == 3:
        print(ustring, **kwargs)
    else:
        bytestr = ustring.encode(encoding, errors=errors)
        print(bytestr, **kwargs)
348982
def u2b(string):
    
    if ((PY2 and isinstance(string, unicode)) or
        ((not PY2) and isinstance(string, str))):
        return string.encode('utf-8')
    return string
586907
def _remove_accents_(filename):
    
    if isinstance(filename, type(six.u(''))):
        unicode_filename = filename
    else:
        unicode_filename = six.u(filename)
    valid_characters = bytes(b'-_.() 1234567890abcdefghijklmnopqrstuvwxyz')
    cleaned_filename = unicodedata.normalize('NFKD', unicode_filename).encode('ASCII', 'ignore')

    new_filename = six.u('')

    for char_int in bytes(cleaned_filename):
        char_byte = bytes([char_int])
        if char_byte in valid_characters:
            new_filename += char_byte.decode()

    return new_filename