• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python six.u函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中six.u函数的典型用法代码示例。如果您正苦于以下问题:Python u函数的具体用法?Python u怎么用?Python u使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了u函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: frozenset_string

def frozenset_string(value, seen):
    if value:
        return u('frozenset({%s})') % (u(', ').join(sorted(
            show(c, seen) for c in value
        )))
    else:
        return repr(value)
开发者ID:rbtcollins,项目名称:hypothesis,代码行数:7,代码来源:show.py


示例2: info

 def info(self):
     if self.project is not None:
         return six.u("join project '%s'") % self.project.pid
     elif self.name:
         return six.u("create project '%s'") % self.name
     else:
         return six.u("create/join a project")
开发者ID:brianmay,项目名称:karaage,代码行数:7,代码来源:models.py


示例3: test_non_bytes

 def test_non_bytes(self):
     padder = padding.PKCS7(128).padder()
     with pytest.raises(TypeError):
         padder.update(six.u("abc"))
     unpadder = padding.PKCS7(128).unpadder()
     with pytest.raises(TypeError):
         unpadder.update(six.u("abc"))
开发者ID:CThaw90,项目名称:SDNHeaderAuthentication,代码行数:7,代码来源:test_padding.py


示例4: check_username_for_new_account

def check_username_for_new_account(person, username, machine_category):
    """ Check the new username for a new account. If the username  is
    in use, raises :py:exc:`UsernameTaken`.

    :param person: Owner of new account.
    :param username: Username to validate.
    :param machine_category: Machine category for new account.
    """

    query = Account.objects.filter(
        username__exact=username,
        machine_category=machine_category,
        date_deleted__isnull=True)

    if query.count() > 0:
        raise UsernameTaken(
            six.u('Username already in use on machine category %s.')
            % machine_category)

    if machine_category_account_exists(username, machine_category):
        raise UsernameTaken(
            six.u('Username is already in datastore for machine category %s.')
            % machine_category)

    return username
开发者ID:Karaage-Cluster,项目名称:karaage-debian,代码行数:25,代码来源:utils.py


示例5: parseBalance

 def parseBalance(cls_, statement, stmt_ofx, bal_tag_name, bal_attr, bal_date_attr, bal_type_string):
     bal_tag = stmt_ofx.find(bal_tag_name)
     if hasattr(bal_tag, "contents"):
         balamt_tag = bal_tag.find('balamt')
         dtasof_tag = bal_tag.find('dtasof')
         if hasattr(balamt_tag, "contents"):
             try:
                 setattr(statement, bal_attr, decimal.Decimal(
                     balamt_tag.contents[0].strip()))
             except (IndexError, decimal.InvalidOperation):
                 ex = sys.exc_info()[1]
                 statement.warnings.append(
                     six.u("%s balance amount was empty for %s") % (bal_type_string, stmt_ofx))
                 if cls_.fail_fast:
                     raise OfxParserException("Empty %s balance" % bal_type_string)
         if hasattr(dtasof_tag, "contents"):
             try:
                 setattr(statement, bal_date_attr, cls_.parseOfxDateTime(
                     dtasof_tag.contents[0].strip()))
             except IndexError:
                 statement.warnings.append(
                     six.u("%s balance date was empty for %s") % (bal_type_string, stmt_ofx))
                 if cls_.fail_fast:
                     raise
             except ValueError:
                 statement.warnings.append(
                     six.u("%s balance date was not allowed for %s") % (bal_type_string, stmt_ofx))
                 if cls_.fail_fast:
                     raise
开发者ID:an613,项目名称:ofxparse,代码行数:29,代码来源:ofxparse.py


示例6: __init__

   def __init__(self, authid = None, authrole = None, authmethod = None, authprovider = None):
      """
      Ctor.

      :param authid: The authentication ID the client is assigned, e.g. `"joe"` or `"[email protected]"`.
      :type authid: str
      :param authrole: The authentication role the client is assigned, e.g. `"anonymous"`, `"user"` or `"com.myapp.user"`.
      :type authrole: str
      :param authmethod: The authentication method that was used to authenticate the client, e.g. `"cookie"` or `"wampcra"`.
      :type authmethod: str
      :param authprovider: The authentication provider that was used to authenticate the client, e.g. `"mozilla-persona"`.
      :type authprovider: str
      """
      if six.PY2:
         if type(authid) == str:
            authid = six.u(authid)
         if type(authrole) == str:
            authrole = six.u(authrole)
         if type(authmethod) == str:
            authmethod = six.u(authmethod)
         if type(authprovider) == str:
            authprovider = six.u(authprovider)

      assert(authid is None or type(authid) == six.text_type)
      assert(authrole is None or type(authrole) == six.text_type)
      assert(authmethod is None or type(authmethod) == six.text_type)
      assert(authprovider is None or type(authprovider) == six.text_type)

      self.authid = authid
      self.authrole = authrole
      self.authmethod = authmethod
      self.authprovider = authprovider
开发者ID:BanzaiMan,项目名称:AutobahnPython,代码行数:32,代码来源:types.py


示例7: _build_illegal_xml_regex

    def _build_illegal_xml_regex():
        """Constructs a regex to match all illegal xml characters.

        Expects to be used against a unicode string."""
        # Construct the range pairs of invalid unicode characters.
        illegal_chars_u = [
            (0x00, 0x08), (0x0B, 0x0C), (0x0E, 0x1F), (0x7F, 0x84),
            (0x86, 0x9F), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF)]

        # For wide builds, we have more.
        if sys.maxunicode >= 0x10000:
            illegal_chars_u.extend(
                [(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)])

        # Build up an array of range expressions.
        illegal_ranges = [
            "%s-%s" % (six.unichr(low), six.unichr(high))
            for (low, high) in illegal_chars_u]

        # Compile the regex
        return re.compile(six.u('[%s]') % six.u('').join(illegal_ranges))
开发者ID:llvm-project,项目名称:lldb,代码行数:26,代码来源:xunit.py


示例8: test_encode

 def test_encode(self):
     # _encode must encode unicode strings
     self.assertEqual(_encode(six.u('привет')),
                      six.u('привет').encode('utf-8'))
     # _encode must return byte strings unchanged
     self.assertEqual(_encode(six.u('привет').encode('utf-8')),
                      six.u('привет').encode('utf-8'))
开发者ID:alexanderlukanin13,项目名称:coolname,代码行数:7,代码来源:test_impl.py


示例9: test_unicode_names

 def test_unicode_names(self):
     """ Unicode field names for for read and write """
     self.assertArrayEqual(self.dset[six.u('a')], self.data['a'])
     self.dset[six.u('a')] = 42
     data = self.data.copy()
     data['a'] = 42
     self.assertArrayEqual(self.dset[six.u('a')], data['a'])
开发者ID:CaptainAL,项目名称:Spyder,代码行数:7,代码来源:test_slicing.py


示例10: test_wrong_encoding

 def test_wrong_encoding(self):
     string = String()
     unknown_char = u("\ufffd") * (2 if six.PY3 else 4)
     self.assert_equal(
         string.decode(u("ündecödäble").encode("utf-8"), "ascii"),
         u("%(u)sndec%(u)sd%(u)sble") % {"u": unknown_char}
     )
开发者ID:DasIch,项目名称:awwparse,代码行数:7,代码来源:positionals.py


示例11: address

 def address(self, qs, out):
     """simple single entry per line in the format of:
         "full name" <[email protected]>;
     """
     out.write(six.u("\n").join(six.u('"%s" <%s>;' % (full_name(**ent), ent['email']))
                                for ent in qs).encode(self.encoding))
     out.write("\n")
开发者ID:55minutes,项目名称:django-extensions,代码行数:7,代码来源:export_emails.py


示例12: load

    def load(self, name, package=__package__):
        if name in self.plugins:
            msg = u("Not loading already loaded plugin: {0}").format(name)
            self.logger.warn(msg)
            return msg

        try:
            fqplugin = "{0}.{1}".format(package, name)
            if fqplugin in sys.modules:
                reload(sys.modules[fqplugin])

            m = safe__import__(name, globals(), locals(), package)

            p1 = lambda x: isclass(x) and issubclass(x, BasePlugin)  # noqa
            p2 = lambda x: x is not BasePlugin  # noqa
            predicate = lambda x: p1(x) and p2(x)  # noqa
            plugins = getmembers(m, predicate)

            for name, Plugin in plugins:
                instance = Plugin(*self.init_args, **self.init_kwargs)
                instance.register(self)
                self.logger.debug(u("Registered Component: {0}").format(instance))
                if name not in self.plugins:
                    self.plugins[name] = set()
                self.plugins[name].add(instance)

            msg = u("Loaded plugin: {0}").format(name)
            self.logger.info(msg)
            return msg
        except Exception, e:
            msg = u("Could not load plugin: {0} Error: {1}").format(name, e)
            self.logger.error(msg)
            self.logger.error(format_exc())
            return msg
开发者ID:MrSwiss,项目名称:charla,代码行数:34,代码来源:__init__.py


示例13: test_unicode_password

 def test_unicode_password(self):
     j = jenkins.Jenkins('{0}'.format(self.base_url),
                         six.u('nonascii'),
                         six.u('\xe9\u20ac'))
     self.assertEqual(j.server, self.make_url(''))
     self.assertEqual(j.auth, b'Basic bm9uYXNjaWk6w6nigqw=')
     self.assertEqual(j.crumb, None)
开发者ID:AssiNET,项目名称:python-jenkins,代码行数:7,代码来源:test_jenkins.py


示例14: test_unicode_deserialize

 def test_unicode_deserialize(self):
     """
     UnicodeAttribute.deserialize
     """
     attr = UnicodeAttribute()
     self.assertEqual(attr.deserialize('foo'), six.u('foo'))
     self.assertEqual(attr.deserialize(u'foo'), six.u('foo'))
开发者ID:BCVisin,项目名称:PynamoDB,代码行数:7,代码来源:test_attributes.py


示例15: set_bool

def set_bool(x):
    if isinstance(x, bool):
        return x
    elif isinstance(x, integer_types):
        return x != 0
    else:
        return text_type(x).strip().lower() not in {u('0'), b('0'), u('n'), b('n'), u('no'), b('no'), u('f'), b('f'), u('false'), b('false')}
开发者ID:jcking,项目名称:libucd,代码行数:7,代码来源:properties.py


示例16: test_generate_role_token

 def test_generate_role_token(self):
     session = Session(self.opentok, self.session_id, media_mode=MediaModes.routed, location=None)
     token = session.generate_token(role=Roles.moderator)
     assert isinstance(token, text_type)
     assert token_decoder(token)[u('session_id')] == self.session_id
     assert token_decoder(token)[u('role')] == u('moderator')
     assert token_signature_validator(token, self.api_secret)
开发者ID:Armin-Smailzade,项目名称:Opentok-Python-SDK,代码行数:7,代码来源:test_session.py


示例17: remove_objects_not_in

    def remove_objects_not_in(self, objects_to_keep, verbosity):
        """
        Deletes all the objects in the database that are not in objects_to_keep.
        - objects_to_keep: A map where the keys are classes, and the values are a
         set of the objects of that class we should keep.
        """
        for class_ in objects_to_keep.keys():
            current = class_.objects.all()
            current_ids = set([x.pk for x in current])
            keep_ids = set([x.pk for x in objects_to_keep[class_]])

            remove_these_ones = current_ids.difference(keep_ids)
            if remove_these_ones:
                for obj in current:
                    if obj.pk in remove_these_ones:
                        obj.delete()
                        if verbosity >= 2:
                            print("Deleted object: %s" % six.u(obj))

            if verbosity > 0 and remove_these_ones:
                num_deleted = len(remove_these_ones)
                if num_deleted > 1:
                    type_deleted = six.u(class_._meta.verbose_name_plural)
                else:
                    type_deleted = six.u(class_._meta.verbose_name)

                print("Deleted %s %s" % (str(num_deleted), type_deleted))
开发者ID:APSL,项目名称:django-extensions,代码行数:27,代码来源:syncdata.py


示例18: coerce_output

def coerce_output(s):
    if isinstance(s, ColoredString):
        return six.u(str(s))
    elif isinstance(s, six.binary_type):
        return six.u(s)
    else:
        return s
开发者ID:grindrllc,项目名称:blockade,代码行数:7,代码来源:test_integration.py


示例19: _format_final_exc_line

def _format_final_exc_line(etype, value):
    valuestr = _some_str(value)
    if value == 'None' or value is None or not valuestr:
        line = u("%s\n") % etype
    else:
        line = u("%s: %s\n") % (etype, valuestr)
    return line
开发者ID:testing-cabal,项目名称:traceback2,代码行数:7,代码来源:__init__.py


示例20: test_zero_byte_string

def test_zero_byte_string():
    # Tests hack to allow chars of non-zero length, but 0 bytes
    # make reader-like thing
    str_io = cStringIO()
    r = _make_readerlike(str_io, boc.native_code)
    c_reader = m5u.VarReader5(r)
    tag_dt = np.dtype([('mdtype', 'u4'), ('byte_count', 'u4')])
    tag = np.zeros((1,), dtype=tag_dt)
    tag['mdtype'] = mio5p.miINT8
    tag['byte_count'] = 1
    hdr = m5u.VarHeader5()
    # Try when string is 1 length
    hdr.set_dims([1,])
    _write_stream(str_io, tag.tostring() + b'        ')
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 1 length
    tag['byte_count'] = 0
    _write_stream(str_io, tag.tostring())
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 4 length
    str_io.seek(0)
    hdr.set_dims([4,])
    val = c_reader.read_char(hdr)
    assert_array_equal(val, [u(' ')] * 4)
开发者ID:jsren,项目名称:sdp-vision-env,代码行数:28,代码来源:test_mio5_utils.py



注:本文中的six.u函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python six.unichr函数代码示例发布时间:2022-05-27
下一篇:
Python six.text_type函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap