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

Python six.str函数代码示例

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

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



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

示例1: test_prev

    def test_prev(self, simple):
        """ Test prev property """
        # self.TEI.parse()
        # Normal passage checking
        p = self.TEI.getTextualNode(["2", "40", "8"], simple=simple)
        self.assertEqual(str(p.prev.reference), "2.40.7")
        p = self.TEI.getTextualNode(["2", "40"], simple=simple)
        self.assertEqual(str(p.prev.reference), "2.39")
        p = self.TEI.getTextualNode(["2"], simple=simple)
        self.assertEqual(str(p.prev.reference), "1")

        # test failing passage
        p = self.TEI.getTextualNode(["1", "pr", "1"], simple=simple)
        self.assertEqual(p.prev, None)
        p = self.TEI.getTextualNode(["1", "pr"], simple=simple)
        self.assertEqual(p.prev, None)
        p = self.TEI.getTextualNode(["1"], simple=simple)
        self.assertEqual(p.prev, None)

        # First child should get to parent's prev last child
        p = self.TEI.getTextualNode(["1", "1", "1"], simple=simple)
        self.assertEqual(str(p.prev.reference), "1.pr.22")

        # Beginning of lowest level passage and beginning of parent level
        p = self.TEI.getTextualNode(["2", "pr", "sa"], simple=simple)
        self.assertEqual(str(p.prev.reference), "1.39.8")
开发者ID:Capitains,项目名称:MyCapytain,代码行数:26,代码来源:commonTests.py


示例2: config_string

 def config_string(self):
     """Generate a '|' delimited string of instance attributes, for saving to config.ini."""
     return '|'.join([
         self.name, self.url, self.api_key, self.cat_ids, str(int(self.enabled)),
         self.search_mode, str(int(self.search_fallback)),
         str(int(self.enable_daily)), str(int(self.enable_backlog)), str(int(self.enable_manualsearch))
     ])
开发者ID:pymedusa,项目名称:SickRage,代码行数:7,代码来源:newznab.py


示例3: select

 def select(self, query, format="sparql"):
     # FIXME: workaround for the fact that rdflib select uses FROM
     # <%s> differently than Sesame/Fuseki. We remove the 'FROM
     # <%s>' part from the query and instead get a context graph
     # for the same URI.
     re_fromgraph = re.compile(r" FROM <(?P<graphuri>[^>]+)> ")
     graphuri = None
     m = re_fromgraph.search(query)
     if m:
         graphuri = m.group("graphuri")
         query = re_fromgraph.sub(" ", query)
     try:
         res = self._getcontextgraph(graphuri).query(query)
     except pyparsing.ParseException as e:
         raise errors.SparqlError(e)
     if format == "sparql":
         return res.serialize(format="xml")
     elif format == "json":
         return res.serialize(format="json")
     else:
         # or just
         # return self._sparql_results_to_list(res.serialize(format="xml"))
         l = []
         for r in res.bindings:
             d = {}
             for (key, val) in r.items():
                 d[str(key)] = str(val)
             l.append(d)
         return l
开发者ID:h4ck3rm1k3,项目名称:ferenda,代码行数:29,代码来源:triplestore.py


示例4: test_scan_video_invalid_extension

def test_scan_video_invalid_extension(movies, tmpdir, monkeypatch):
    monkeypatch.chdir(str(tmpdir))
    movie_name = os.path.splitext(movies['man_of_steel'].name)[0] + '.mp3'
    tmpdir.ensure(movie_name)
    with pytest.raises(ValueError) as excinfo:
        scan_video(movie_name)
    assert str(excinfo.value) == '.mp3 is not a valid video extension'
开发者ID:fernandog,项目名称:subliminal,代码行数:7,代码来源:test_video.py


示例5: build_uri

    def build_uri(self, base, matches):
        if not base:
            return None
        if self.uriTemplate:
            expanded = str(self.uriTemplate)
        elif self.fragmentTemplate:
            if "#" in base:
                base += self.space.fragmentSeparator
            else:
                base += "#"
            expanded = base + str(self.fragmentTemplate)
        else:
            return None

        expanded = expanded.replace("{+base}", base)
        for var, value in matches.items():
            slug = self.transform_value(value)
            expanded = expanded.replace("{%s}" % var, slug)
        # if base is eg "http://localhost/res/" and expanded is a
        # /-prefixed relative uri like "/sfs/9999:998", urljoin
        # results in "http://localhost/sfs/9999:998/", not
        # "http://localhost/res/" like you'd expect. So we work
        # around.
        if expanded[0] == "/":
            expanded = expanded[1:]
            
        if expanded.startswith("http://") or expanded.startswith("https://"):
            return urljoin(base, expanded)
        else:
            # see the test integrationLegalURI.CustomCoinstruct.test_1845_50_s.1
            return "%s/%s" % (base, expanded)
开发者ID:staffanm,项目名称:ferenda,代码行数:31,代码来源:coin.py


示例6: getprevnext

def getprevnext(passage, request_urn, output=XML):
    _prev = ""
    _next = ""

    if passage.prev:
        _prev = URN("{}:{}".format(passage.urn.upTo(URN.VERSION), str(passage.prev)))
    if passage.next:
        _next = URN("{}:{}".format(passage.urn.upTo(URN.VERSION), str(passage.next)))

    if output == XML:
        return """
            <GetPrevNext xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns="http://chs.harvard.edu/xmlns/cts">
                <request>
                    <requestName>GetPrevNext</requestName>
                    <requestUrn>{request_urn}</requestUrn>
                </request>
                <reply>
                    <urn>{full_urn}</urn>
                    <prevnext>
                        <prev><urn>{prev}</urn></prev>
                        <next><urn>{next}</urn></next>
                    </prevnext>
                </reply>
            </GetPrevNext>""".format(
            request_urn=request_urn,
            full_urn=str(passage.urn),
            prev=str(_prev),
            next=str(_next)
        )
开发者ID:Capitains,项目名称:Nautilus,代码行数:29,代码来源:response.py


示例7: test_first_list

    def test_first_list(self):
        passage = self.text.getPassage(MyCapytain.common.reference.Reference("2.39"))
        self.assertEqual(str(passage.firstId), "2.39.1", "First reff should be the first")
        self.assertEqual(str(passage.lastId), "2.39.2", "Last reff should be the last")

        passage = self.text.getPassage(MyCapytain.common.reference.Reference("2.39-2.40"))
        self.assertEqual(str(passage.firstId), "2.39.1", "First reff should be the first")
        self.assertEqual(str(passage.lastId), "2.40.8", "Last reff should be the last")
开发者ID:Capitains,项目名称:MyCapytain,代码行数:8,代码来源:commonTests.py


示例8: test_prevnext_on_close_to_last_passage

 def test_prevnext_on_close_to_last_passage(self):
     passage = self.text.getPassage(MyCapytain.common.reference.Reference("2.39.2-2.40.5"))
     self.assertEqual(
         str(passage.nextId),
         "2.40.6-2.40.8",
         "Next reff should finish at the end of the text, no matter the length of the reference",
     )
     self.assertEqual(str(passage.prevId), "2.37.9-2.39.1", "Prev reff should be the same length as sibling")
开发者ID:Capitains,项目名称:MyCapytain,代码行数:8,代码来源:commonTests.py


示例9: test_prevnext_on_close_to_first_passage

 def test_prevnext_on_close_to_first_passage(self):
     passage = self.text.getPassage(MyCapytain.common.reference.Reference("1.pr.10-1.2.1"))
     self.assertEqual(str(passage.nextId), "1.2.2-1.4.1", "Next reff should be the same length as sibling")
     self.assertEqual(
         str(passage.prevId),
         "1.pr.1-1.pr.9",
         "Prev reff should start at the beginning of the text, no matter the length of the reference",
     )
开发者ID:Capitains,项目名称:MyCapytain,代码行数:8,代码来源:commonTests.py


示例10: test_highest

 def test_highest(self):
     self.assertEqual(
         str((Reference("1.1-1.2.8")).highest), "1.1",
         "1.1 is higher"
     )
     self.assertEqual(
         str((Reference("1.1-2")).highest), "2",
         "2 is higher"
     )
开发者ID:Capitains,项目名称:MyCapytain,代码行数:9,代码来源:test_reference.py


示例11: test_properties

 def test_properties(self):
     a = Reference("[email protected]@Atreus[3]")
     self.assertEqual(str(a.start), "[email protected]")
     self.assertEqual(a.start.list, ["1", "1"])
     self.assertEqual(a.start.subreference[0], "Achilles")
     self.assertEqual(str(a.end), "[email protected][3]")
     self.assertEqual(a.end.list, ["1", "10"])
     self.assertEqual(a.end.subreference[1], 3)
     self.assertEqual(a.end.subreference, ("Atreus", 3))
开发者ID:Capitains,项目名称:MyCapytain,代码行数:9,代码来源:test_reference.py


示例12: _load_resources

 def _load_resources(self, resource_path):
     # returns a mapping [resource label] => [resource uri]
     # resource_path is given relative to cwd
     graph = Graph()
     graph.load(resource_path, format='n3')
     d = {}
     for uri, label in graph.subject_objects(RDFS.label):
         d[str(label)] = str(uri)
     return d
开发者ID:h4ck3rm1k3,项目名称:ferenda,代码行数:9,代码来源:swedishlegalsource.py


示例13: test_Unicode_Support

 def test_Unicode_Support(self):
     a = Reference("[email protected]καὶ[0][email protected]Ἀλκιβιάδου[3]")
     self.assertEqual(str(a.start), "[email protected]καὶ[0]")
     self.assertEqual(a.start.list, ["1", "1"])
     self.assertEqual(a.start.subreference[0], "καὶ")
     self.assertEqual(str(a.end), "[email protected]Ἀλκιβιάδου[3]")
     self.assertEqual(a.end.list, ["1", "10"])
     self.assertEqual(a.end.subreference[1], 3)
     self.assertEqual(a.end.subreference, ("Ἀλκιβιάδου", 3))
开发者ID:Capitains,项目名称:MyCapytain,代码行数:9,代码来源:test_reference.py


示例14: test_xml_Work_GetItem

 def test_xml_Work_GetItem(self):
     """ Test access through getItem obj[urn] """
     TI = TextInventory(resource=self.getCapabilities, id="TestInv")
     tg = TI["urn:cts:latinLit:phi1294"]
     self.assertIsInstance(tg["urn:cts:latinLit:phi1294.phi002"], Work)
     self.assertEqual(str(tg["urn:cts:latinLit:phi1294.phi002"].urn), "urn:cts:latinLit:phi1294.phi002")
     self.assertIsInstance(tg["urn:cts:latinLit:phi1294.phi002.perseus-lat2"], Text)
     self.assertEqual(
         str(tg["urn:cts:latinLit:phi1294.phi002.perseus-lat2"].urn), "urn:cts:latinLit:phi1294.phi002.perseus-lat2"
     )
开发者ID:emmamorlock,项目名称:MyCapytain,代码行数:10,代码来源:test_inventory.py


示例15: mock_volume

def mock_volume(override=None):
    volume_model = {
        "id": str(uuid.uuid4()),
        "sizeInKb": (8 * constants.GIGABYTE) // constants.KILOBYTE,
        "storagePoolId": str(uuid.uuid4()),
        "useRmcache": False,
        "volumeType": constants.VOLUME_TYPE_THICK,
        "mappedSdcInfo": []
    }
    volume_model.update(override or {})
    return volume_model
开发者ID:gmmephisto,项目名称:pyscaleio,代码行数:11,代码来源:test_models.py


示例16: test_str

 def test_str(self):
     a = Citation(name="book", xpath="/tei:div[@n=\"?\"]", scope="/tei:TEI/tei:body/tei:text/tei:div")
     self.assertEqual(
         str(a),"<tei:cRefPattern n=\"book\" matchPattern=\"(\\w+)\" replacementPattern=\"#xpath(/tei:TEI/tei:body/tei:text/tei:div/tei:div[@n=\"$1\"])\"><tei:p>This pointer pattern extracts book</tei:p></tei:cRefPattern>"
     )
     b = Citation(name="chapter", xpath="/tei:div[@n=\"?\"]", scope="/tei:TEI/tei:body/tei:text/tei:div/tei:div[@n=\"?\"]")
     self.assertEqual(
         str(b),"<tei:cRefPattern n=\"chapter\" matchPattern=\"(\\w+)\.(\\w+)\" replacementPattern=\"#xpath(/tei:TEI/tei:body/tei:text/tei:div/tei:div[@n=\"$1\"]/tei:div[@n=\"$2\"])\"><tei:p>This pointer pattern extracts chapter</tei:p></tei:cRefPattern>"
     )
     a = Citation()
     self.assertEqual(str(a), "")
开发者ID:Capitains,项目名称:MyCapytain,代码行数:11,代码来源:test_encoding.py


示例17: __init__

 def __init__(self, resource):
     self.base = str(resource.value(COIN.base))
     self.fragmentSeparator = str(resource.value(COIN.fragmentSeparator))
     self.slugTransform = SlugTransformer(resource.value(COIN.slugTransform))
     self.templates = [Template(self, template_resource)
                       for template_resource in resource.objects(
                               COIN.template)]
     # primary sort order by :priority
     # secondary sort by type specificity (wether a self.forType is specified)
     # tertiary sort order by specificity (number of vars per template)
     self.templates.sort(key=lambda x: (x.priority, x.forType, len(x.bindings)),
                         reverse=True) 
开发者ID:staffanm,项目名称:ferenda,代码行数:12,代码来源:coin.py


示例18: test_run_revsort

 def test_run_revsort(self):
     outDir = self._createTempDir()
     self._tester('src/toil/test/cwl/revsort.cwl',
                  'src/toil/test/cwl/revsort-job.json',
                  outDir, {
         # Having unicode string literals isn't necessary for the assertion but makes for a
         # less noisy diff in case the assertion fails.
         u'output': {
             u'location': "file://" + str(os.path.join(outDir, 'output.txt')),
             u'basename': str("output.txt"),
             u'size': 1111,
             u'class': u'File',
             u'checksum': u'sha1$b9214658cc453331b62c2282b772a5c063dbd284'}})
开发者ID:chapmanb,项目名称:toil,代码行数:13,代码来源:cwlTest.py


示例19: test_particle

def test_particle():
    assert str(Eun) == u'은(는)'
    assert str(Eul) == u'을(를)'
    assert str(Ida) == u'(이)'
    if PY2:
        try:
            __import__('unidecode')
        except ImportError:
            assert repr(Ida) == u"<Particle: u'(\\uc774)'>"
        else:
            assert repr(Ida) == u'<Particle: (i)>'
    else:
        assert repr(Ida) == u'<Particle: (이)>'
开发者ID:what-studio,项目名称:tossi,代码行数:13,代码来源:test.py


示例20: test_get_parent

    def test_get_parent(self):
        a = Reference("1.1")
        b = Reference("1")
        c = Reference("1.1-2.3")
        d = Reference("1.1-1.2")
        e = Reference("[email protected][0][email protected][2]")
        f = Reference("1-2")

        self.assertEqual(str(a.parent), "1")
        self.assertEqual(b.parent, None)
        self.assertEqual(str(c.parent), "1-2")
        self.assertEqual(str(d.parent), "1")
        self.assertEqual(str(e.parent), "[email protected][0][email protected][2]")
        self.assertEqual(f.parent, None)
开发者ID:Capitains,项目名称:MyCapytain,代码行数:14,代码来源:test_reference.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python six.text_type函数代码示例发布时间:2022-05-27
下一篇:
Python six.six_next函数代码示例发布时间: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