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


Python BytesIO.strip方法代码示例

本文整理汇总了Python中six.BytesIO.strip方法的典型用法代码示例。如果您正苦于以下问题:Python BytesIO.strip方法的具体用法?Python BytesIO.strip怎么用?Python BytesIO.strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.BytesIO的用法示例。


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

示例1: test_numeric

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import strip [as 别名]
    def test_numeric(self):

        graph = Graph()
        graph.load("tests/data/numeric_unsorted.ttl", format="turtle")
        ots = OrderedTurtleSerializer(graph)
        out = BytesIO()
        ots.serialize(out)
        out = "\n".join([x for x in out.getvalue().decode("utf-8").split("\n") if x.startswith("<")])

        ref = open("tests/data/numeric_sorted.ttl").read()
        ref = "\n".join([x for x in ref.split("\n") if x.startswith("<")])

        assert ref.strip() == out.strip()
开发者ID:scriptotek,项目名称:otsrdflib,代码行数:15,代码来源:ots_test.py

示例2: test_custom_sorter

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import strip [as 别名]
    def test_custom_sorter(self):

        graph = Graph()
        graph.load("tests/data/group_unsorted.ttl", format="turtle")
        ots = OrderedTurtleSerializer(graph)

        ots.sorters = [("(.*?)([0-9]+)$", lambda x: self.xhash(x[0]) + int(x[1]))]

        out = BytesIO()
        ots.serialize(out)
        out = "\n".join([x for x in out.getvalue().decode("utf-8").split("\n") if x.startswith("<")])

        ref = open("tests/data/group_sorted.ttl").read()
        ref = "\n".join([x for x in ref.split("\n") if x.startswith("<")])

        assert ref.strip() == out.strip()
开发者ID:scriptotek,项目名称:otsrdflib,代码行数:18,代码来源:ots_test.py

示例3: test_dewey_sorter

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import strip [as 别名]
    def test_dewey_sorter(self):

        graph = Graph()
        graph.load("tests/data/dewey_unsorted.ttl", format="turtle")
        ots = OrderedTurtleSerializer(graph)

        ots.sorters = [
            ("/([0-9A-Z\-]+)\-\-([0-9.\-;:]+)/e", lambda x: "T{0}--{0}".format(x[0], x[1])),  # table numbers
            ("/([0-9.\-;:]+)/e", lambda x: "A" + x[0]),  # standard schedule numbers
        ]

        out = BytesIO()
        ots.serialize(out)
        out = "\n".join([x for x in out.getvalue().decode("utf-8").split("\n") if x.startswith("<")])

        ref = open("tests/data/dewey_sorted.ttl").read()
        ref = "\n".join([x for x in ref.split("\n") if x.startswith("<")])

        assert ref.strip() == out.strip()
开发者ID:scriptotek,项目名称:otsrdflib,代码行数:21,代码来源:ots_test.py


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