本文整理汇总了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()
示例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()
示例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()