本文整理汇总了Python中collector.Collector.file_for_path方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.file_for_path方法的具体用法?Python Collector.file_for_path怎么用?Python Collector.file_for_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collector.Collector
的用法示例。
在下文中一共展示了Collector.file_for_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_enhance_file_elements
# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import file_for_path [as 别名]
def test_enhance_file_elements(self):
c = Collector()
aa_c = c.file_for_path("a/a/aa.c")
ab_c = c.file_for_path("a/b/ab.c")
b_c = c.file_for_path("b/b.c")
baa_c = c.file_for_path("b/a/a/baa.c")
a = c.folder_for_path("a")
aa = c.folder_for_path("a/a")
ab = c.folder_for_path("a/b")
b = c.folder_for_path("b")
ba = c.folder_for_path("b/a")
baa = c.folder_for_path("b/a/a")
self.assertEqual("a", a[collector.NAME])
self.assertEqual("a", aa[collector.NAME])
self.assertEqual("aa.c", aa_c[collector.NAME])
self.assertEqual("b", ab[collector.NAME])
self.assertEqual("ab.c", ab_c[collector.NAME])
self.assertEqual("b", b[collector.NAME])
self.assertEqual("b.c", b_c[collector.NAME])
self.assertEqual("a", ba[collector.NAME])
self.assertEqual("a", baa[collector.NAME])
self.assertEqual("baa.c", baa_c[collector.NAME])
c.enhance_file_elements()
crf = list(c.collapsed_root_folders())
self.assertItemsEqual([aa, ab, b], crf)
self.assertEqual(a, aa[collector.ROOT])
self.assertEqual(a, ab[collector.ROOT])
self.assertEqual(b, ba[collector.ROOT])
self.assertEqual(b, baa[collector.ROOT])
self.assertItemsEqual([aa, ab], a[collector.SUB_FOLDERS])
self.assertItemsEqual([], aa[collector.SUB_FOLDERS])
self.assertItemsEqual([], ab[collector.SUB_FOLDERS])
self.assertItemsEqual([ba], b[collector.SUB_FOLDERS])
self.assertItemsEqual([baa], ba[collector.SUB_FOLDERS])
self.assertItemsEqual([], baa[collector.SUB_FOLDERS])
self.assertItemsEqual([], a[collector.FILES])
self.assertItemsEqual([aa_c], aa[collector.FILES])
self.assertItemsEqual([ab_c], ab[collector.FILES])
self.assertItemsEqual([b_c], b[collector.FILES])
self.assertItemsEqual([], ba[collector.FILES])
self.assertItemsEqual([baa_c], baa[collector.FILES])
self.assertEqual("a", a[collector.COLLAPSED_NAME])
self.assertEqual("a/a", aa[collector.COLLAPSED_NAME])
self.assertEqual("a/b", ab[collector.COLLAPSED_NAME])
self.assertEqual("b", b[collector.COLLAPSED_NAME])
self.assertEqual("a", ba[collector.COLLAPSED_NAME])
self.assertEqual("a/a", baa[collector.COLLAPSED_NAME])
self.assertItemsEqual([aa, ab], a[collector.COLLAPSED_SUB_FOLDERS])
self.assertItemsEqual([], aa[collector.COLLAPSED_SUB_FOLDERS])
self.assertItemsEqual([], ab[collector.COLLAPSED_SUB_FOLDERS])
self.assertItemsEqual([baa], b[collector.COLLAPSED_SUB_FOLDERS])
self.assertItemsEqual([baa], ba[collector.COLLAPSED_SUB_FOLDERS])
self.assertItemsEqual([], baa[collector.COLLAPSED_SUB_FOLDERS])