How to use the six.u function in six

To help you get started, we’ve selected a few six examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marl / jams / tests / test_ns.py View on Github external
             ['B#:locrian', six.u('A:minor'), 'N', 'E',
              xfail('asdf', raises=SchemaError),
              xfail('A&:phrygian', raises=SchemaError),
              xfail(11, raises=SchemaError),
              xfail('', raises=SchemaError),
              xfail(':dorian', raises=SchemaError),
              xfail(None, raises=SchemaError)])
def test_ns_key_mode(value):

    ann = Annotation(namespace='key_mode')
    ann.append(time=0, duration=0, value=value, confidence=None)
    ann.validate()
github Backblaze / b2-sdk-python / test / v1 / test_sync.py View on Github external
six.u('//'),
            six.u('///'),
            six.u('/..'),
            six.u('/../'),
            six.u('/.../'),
            six.u('/../.'),
            six.u('/../..'),
            six.u('/a.txt'),
            six.u('/folder/a.txt'),
            six.u('./folder/a.txt'),  # current dir relative path
            six.u('folder/./a.txt'),
            six.u('folder/folder/.'),
            six.u('a//b/'),  # double-slashes
            six.u('a///b'),
            six.u('a////b'),
            six.u('../test'),  # start with parent dir
            six.u('../../test'),
            six.u('../../abc/../test'),
            six.u('../../abc/../test/'),
            six.u('../../abc/../.test'),
            six.u('a/b/c/../d'),  # parent dir embedded
            six.u('a//..//b../..c/'),
            six.u('..a/b../..c/../d..'),
            six.u('a/../'),
            six.u('a/../../../../../'),
            six.u('a/b/c/..'),
            six.u(r'\\'),  # backslash filenames
            six.u(r'\z'),
            six.u(r'..\\'),
            six.u(r'..\..'),
            six.u(r'\..\\'),
            six.u(r'\\..\\..'),
github opentok / Opentok-Python-SDK / tests / test_archive_api.py View on Github external
"status" : "available",
                                            "hasAudio": true,
                                            "hasVideo": true,
                                            "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2F5350f06f-0166-402e-bc27-09ba54948512%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                          } ]
                                        }""")),
                               status=200,
                               content_type=u('application/json'))

        archive_list = self.opentok.get_archives(count=2)

        validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
        expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
        expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json')))
        expect(httpretty.last_request()).to(have_property(u('querystring'), {
            u('count'): [u('2')]
        }))
        expect(archive_list).to(be_an(ArchiveList))
        expect(archive_list).to(have_property(u('count'), 6))
        expect(list(archive_list.items)).to(have_length(2))
        # TODO: we could inspect each item in the list
github opentok / Opentok-Python-SDK / tests / test_archive_api.py View on Github external
archive = self.opentok.start_archive(self.session_id, name=u('ARCHIVE NAME'), output_mode=OutputModes.composed)

        validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
        expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
        expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json')))
        # non-deterministic json encoding. have to decode to test it properly
        if PY2:
            body = json.loads(httpretty.last_request().body)
        if PY3:
            body = json.loads(httpretty.last_request().body.decode('utf-8'))
        expect(body).to(have_key(u('sessionId'), u('SESSIONID')))
        expect(body).to(have_key(u('name'), u('ARCHIVE NAME')))
        expect(archive).to(be_an(Archive))
        expect(archive).to(have_property(u('id'), u('30b3ebf1-ba36-4f5b-8def-6f70d9986fe9')))
        expect(archive).to(have_property(u('name'), ('ARCHIVE NAME')))
        expect(archive).to(have_property(u('status'), u('started')))
        expect(archive).to(have_property(u('session_id'), u('SESSIONID')))
        expect(archive).to(have_property(u('partner_id'), 123456))
        if PY2:
            created_at = datetime.datetime.fromtimestamp(1395183243, pytz.UTC)
        if PY3:
            created_at = datetime.datetime.fromtimestamp(1395183243, datetime.timezone.utc)
        expect(archive).to(have_property(u('created_at'), created_at))
        expect(archive).to(have_property(u('size'), 0))
        expect(archive).to(have_property(u('duration'), 0))
        expect(archive).to(have_property(u('has_audio'), True))
        expect(archive).to(have_property(u('has_video'), True))
        expect(archive).to(have_property(u('output_mode'), OutputModes.composed))
        expect(archive).to(have_property(u('url'), None))
github GoVanguard / legion / app / auxiliary.py View on Github external
def readStdOutput(self):
        output = str(self.readAllStandardOutput())
        self.display.appendPlainText(unicode(output).strip())

        if self.name == 'hydra':  # check if any usernames/passwords were found (if so emit a signal so that the gui can tell the user about it)
            found, userlist, passlist = checkHydraResults(output)
            if found:  # send the brutewidget object along with lists of found usernames/passwords
                self.sigHydra.emit(self.display.parentWidget(), userlist, passlist)

        stderror = str(self.readAllStandardError())

        if len(stderror) > 0:
            self.display.appendPlainText(unicode(stderror).strip())  # append standard error too
github scrapy / w3lib / w3lib / html.py View on Github external
# -*- coding: utf-8 -*-
"""
Functions for dealing with markup text
"""

import warnings
import re
import six
from six import moves

from w3lib.util import to_bytes, to_unicode
from w3lib.url import safe_url_string

_ent_re = re.compile(r'&((?P[a-z\d]+)|#(?P\d+)|#x(?P[a-f\d]+))(?P;?)', re.IGNORECASE)
_tag_re = re.compile(r'<[a-zA-Z\/!].*?>', re.DOTALL)
_baseurl_re = re.compile(six.u(r']*href\s*=\s*[\"\']\s*([^\"\'\s]+)\s*[\"\']'), re.I)
_meta_refresh_re = re.compile(six.u(r']*http-equiv[^>]*refresh[^>]*content\s*=\s*(?P["\'])(?P(\d*\.)?\d+)\s*;\s*url=\s*(?P.*?)(?P=quote)'), re.DOTALL | re.IGNORECASE)
_cdata_re = re.compile(r'((?P.*?)(?P\]\]>))', re.DOTALL)

HTML5_WHITESPACE = ' \t\n\r\x0c'


def remove_entities(text, keep=(), remove_illegal=True, encoding='utf-8'):
    r"""

    .. warning::

        This function is deprecated and will be removed in future.
        Please use :func:`replace_entities` instead.
    """

    warnings.warn(
github anchore / anchore-engine / anchore_engine / clients / policy_engine / generated / api_client.py View on Github external
def __deserialize_primitive(self, data, klass):
        """Deserializes string to primitive type.

        :param data: str.
        :param klass: class literal.

        :return: int, long, float, str, bool.
        """
        try:
            return klass(data)
        except UnicodeEncodeError:
            return six.u(data)
        except TypeError:
            return data
github freakboy3742 / pyxero / xero / basemanager.py View on Github external
def _prepare_data_for_save(self, data):
        if isinstance(data, list) or isinstance(data, tuple):
            root_elm = Element(self.name)
            for d in data:
                sub_elm = SubElement(root_elm, self.singular)
                self.dict_to_xml(sub_elm, d)
        else:
            root_elm = self.dict_to_xml(Element(self.singular), data)

        # In python3 this seems to return a bytestring
        return six.u(tostring(root_elm))
github fnielsen / dasem / dasem / wikisource.py View on Github external
extracted_text : str
        Extracted text.

    """
    # Match  and just extract that.
    in_poem = re.findall(r'(.*?)', text,
                         flags=re.UNICODE | re.DOTALL)
    if in_poem:
        return u"\n\n".join(in_poem)

    # Ignore license information. This might be above or below the text.
    text = re.sub((r'Public domainPublic domain(.*?), '
                   'da det blev udgivet.{15,25}\.$'), '\n',
                  text, flags=re.UNICODE | re.DOTALL | re.MULTILINE)

    regex = r'Teksten\[redig' + u('\xe9') + r'r\](.*)'
    after_teksten = re.findall(regex, text, flags=re.UNICODE | re.DOTALL)
    if after_teksten:
        return u"\n\n".join(after_teksten)

    # Match bottom of infobox on some of the songs
    rest = re.findall(r'.*Wikipedia-link\s*(.*)', text,
                      flags=re.UNICODE | re.DOTALL)
    if rest:
        return u"\n\n".join(rest)

    return text
github nose-devs / nose2 / nose2 / plugins / junitxml.py View on Github external
RESTRICTED_RANGES += [(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF),
                          (0x3FFFE, 0x3FFFF), (0x4FFFE, 0x4FFFF),
                          (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
                          (0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF),
                          (0x9FFFE, 0x9FFFF), (0xAFFFE, 0xAFFFF),
                          (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
                          (0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF),
                          (0xFFFFE, 0xFFFFF), (0x10FFFE, 0x10FFFF)]

ILLEGAL_REGEX_STR = \
    six.u('[') + \
    six.u('').join(["%s-%s" % (six.unichr(l), six.unichr(h))
                    for (l, h) in ILLEGAL_RANGES]) + \
    six.u(']')
RESTRICTED_REGEX_STR = \
    six.u('[') + \
    six.u('').join(["%s-%s" % (six.unichr(l), six.unichr(h))
                    for (l, h) in RESTRICTED_RANGES]) + \
    six.u(']')

_ILLEGAL_REGEX = re.compile(ILLEGAL_REGEX_STR, re.U)
_RESTRICTED_REGEX = re.compile(RESTRICTED_REGEX_STR, re.U)


def string_cleanup(string, keep_restricted=False):
    if not issubclass(type(string), six.text_type):
        string = six.text_type(string, encoding='utf-8', errors='replace')

    string = _ILLEGAL_REGEX.sub(six.u('\uFFFD'), string)
    if not keep_restricted:
        string = _RESTRICTED_REGEX.sub(six.u('\uFFFD'), string)