本文整理汇总了Python中normalize.selector.MultiFieldSelector.from_path方法的典型用法代码示例。如果您正苦于以下问题:Python MultiFieldSelector.from_path方法的具体用法?Python MultiFieldSelector.from_path怎么用?Python MultiFieldSelector.from_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类normalize.selector.MultiFieldSelector
的用法示例。
在下文中一共展示了MultiFieldSelector.from_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mfs_marshal
# 需要导入模块: from normalize.selector import MultiFieldSelector [as 别名]
# 或者: from normalize.selector.MultiFieldSelector import from_path [as 别名]
def test_mfs_marshal(self):
mfs = MultiFieldSelector(
["rakkk", None, "awkkkkkk"],
["rakkk", None, "zgruppp"],
["cr_r_a_a_ck", "rip"],
["cr_r_a_a_ck", "aiieee"],
)
path = mfs.path
new_mfs = MultiFieldSelector.from_path(path)
for fs in mfs:
self.assertIn(fs, new_mfs)
parts = list(fs)
self.assertIsNotNone(parts[-1])
for fs in new_mfs:
self.assertIn(fs, mfs)
self.assertEqual(len(mfs.path), len(new_mfs.path))
for path in (".foo", ".foo[*]", ".foo.bar[*]"):
mfs = MultiFieldSelector.from_path(path)
self.assertEqual(mfs.path, path)
for mfs_fs in (
((),),
(("foo",),),
((1,), (2,)),
((None,)),
(("foo", "bar", None),),
):
mfs = MultiFieldSelector(*mfs_fs)
path = mfs.path
mfs_loop = MultiFieldSelector.from_path(path)
self.assertEqual(mfs_loop.path, path)
self.assertEqual(list(fs.path for fs in mfs),
list(fs.path for fs in mfs_loop))
示例2: test_mfs_marshal
# 需要导入模块: from normalize.selector import MultiFieldSelector [as 别名]
# 或者: from normalize.selector.MultiFieldSelector import from_path [as 别名]
def test_mfs_marshal(self):
mfs = MultiFieldSelector(
["rakkk", None, "awkkkkkk"],
["rakkk", None, "zgruppp"],
["cr_r_a_a_ck", "rip"],
["cr_r_a_a_ck", "aiieee"],
)
path = mfs.path
new_mfs = MultiFieldSelector.from_path(path)
for fs in mfs:
self.assertIn(fs, new_mfs)
for fs in new_mfs:
self.assertIn(fs, mfs)
self.assertEqual(len(mfs.path), len(new_mfs.path))