当前位置: 首页>>代码示例>>Python>>正文


Python six.str函数代码示例

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


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


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