コード例 #1
0
 def test_next_reset_after_add(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file3", must_exist=False)
     next(d)
     next(d)
     d.add("/file4")
     self.assertEqual(next(d), "/file1")
コード例 #2
0
 def test_self_glob_dedups_when_many_files_match(self):
     glob.populate(Sequence.create("1-20").expand("/some/file.####.exr"))
     d = DependencyList()
     files = ["/some/file.*.exr", "/some/*.exr"]
     d.add(*files, must_exist=False)
     d.glob()
     self.assertEqual(len(d), 20)
コード例 #3
0
 def test_common_path_when_duplicate_entries_of_single_path(self):
     d = DependencyList()
     files = [
         "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/foo.txt"
     ]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/users/joebloggs/tmp/foo.txt")
コード例 #4
0
    def add_entries(self, entries):
        """Add a line item for each entry.

        Use DependencyList to deduplicate on the fly. As the addition of
        entries may completely change the list (grow or shrink) we
        delete and rebuild the list of entries each time.
        """
        if not entries:
            return

        root_item = self.get_root()

        deduped = DependencyList()
        for item in self.item_list:
            # no need to stat as we must have once already
            deduped.add(item.get_name(), must_exist=False)

        for entry in entries:
            deduped.add(entry)
        # clear existing list
        root_item.remove_children()
        del self.item_list[:]

        for entry in deduped:
            item = ix.api.GuiTreeItemBasic(root_item, entry)
            self.item_list.append(item)
        self.refresh()
コード例 #5
0
 def test_self_glob_when_files_dont_match(self):
     glob.populate(Sequence.create("1-20").expand("/other/file.####.exr"))
     d = DependencyList()
     file = "/some/file.*.exr"
     d.add(file, must_exist=False)
     d.glob()
     self.assertEqual(len(d), 0)
コード例 #6
0
    def add_entries(self, entries):
        """Add a line item for each entry.

        Use DependencyList to deduplicate on the fly. As the addition of
        entries may completely change the list (grow or shrink) we
        delete and rebuild the list of entries each time.
        """
        if not entries:
            return

        root_item = self.get_root()

        deduped = DependencyList()
        for item in self.item_list:
            # no need to stat as we must have once already
            deduped.add(item.get_name(), must_exist=False)

        for entry in entries:
            deduped.add(entry)
        # clear existing list
        root_item.remove_children()
        del self.item_list[:]

        for entry in deduped:
            item = ix.api.GuiTreeItemBasic(root_item, entry)
            self.item_list.append(item)
        self.refresh()
コード例 #7
0
 def test_common_path_when_one_path_is_the_common_path(self):
     d = DependencyList()
     files = [
         "/users/joebloggs/tmp", "/users/joebloggs/tmp/bolly/operation",
         "/users/joebloggs/tmp/stay/go"
     ]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
コード例 #8
0
 def test_dedup_contained_file(self):
     d = DependencyList()
     d.add("/dir1/",
           "/dir1/file1",
           "/dir2/file1",
           "file2",
           must_exist=False)
     self.assertEqual(len(d), 3)
コード例 #9
0
 def test_next_fails_after_last(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file3", must_exist=False)
     next(d)
     next(d)
     next(d)
     with self.assertRaises(StopIteration):
         next(d)
コード例 #10
0
 def test_common_path(self):
     d = DependencyList()
     files = [
         "/users/joebloggs/tmp/foobar/test",
         "/users/joebloggs/tmp/baz/fripp",
         "/users/joebloggs/tmp/elephant/corner"
     ]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
コード例 #11
0
 def test_common_path_when_common_prefix_in_filename(self):
     d = DependencyList()
     files = [
         "/users/joebloggs/tmp/dissention/perfect",
         "/users/joebloggs/tmp/disagreement/crimson",
         "/users/joebloggs/tmp/diatribe/belew"
     ]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
コード例 #12
0
 def test_common_path_when_lowest_path_is_the_common_path(self):
     d = DependencyList()
     files = [
         "/users/joebloggs/tmp/foo.txt",
         "/users/joebloggs/tmp/modelman.jpg",
         "/users/joebloggs/tmp/ration.cpp",
         "/users/joebloggs/tmp/bill.project"
     ]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
コード例 #13
0
    def _get_output_directory(self):
        """Get the common path for all image output paths.

        Also return the individual paths as they may need to be created.
        """
        out_paths = DependencyList()

        images = ix.api.OfObjectArray()
        self.node.get_attribute("images").get_values(images)

        for image in images:
            directory = os.path.dirname(
                image.get_attribute("save_as").get_string())
            out_paths.add(directory, must_exist=False)

        return {
            "common_path": out_paths.common_path(),
            "output_paths": list(out_paths)
        }
コード例 #14
0
ファイル: job.py プロジェクト: all-in-one-of/conductor_client
    def _get_output_directory(self):
        """Get the common path for all image output paths.

        Also return the individual paths as they may need to be created.
        """
        out_paths = DependencyList()

        images = ix.api.OfObjectArray()
        self.node.get_attribute("images").get_values(images)

        for image in images:
            directory = os.path.dirname(
                image.get_attribute("save_as").get_string())
            out_paths.add(directory, must_exist=False)

        return {
            "common_path": out_paths.common_path(),
            "output_paths": list(out_paths)
        }
コード例 #15
0
def collect(obj):
    """Collect all upload files.

    Always add any extra uploads the user has chosen. Then do a scan if
    the policy is not none.
    """

    policy = obj.get_attribute("dependency_scan_policy").get_long()

    result = DependencyList()

    result.add(
        "$CONDUCTOR_LOCATION/conductor/clarisse/bin/ct_cnode",
        must_exist=True)

    result.add(*_get_extra_uploads(obj), must_exist=True)

    result.add(*get_scan(obj, policy), must_exist=False)

    # tell the list to expand  any "*" or <UDIM> in place
    result.glob()
    return result
コード例 #16
0
def get_scan(obj, policy):
    """Make a dependencyList according to the policy."""
    result = DependencyList()
    result.add(*_resolve_file_paths(obj, policy), must_exist=False)
    result.add(*_get_references(obj, policy), must_exist=True)
    return result
コード例 #17
0
 def test_common_path_is_slash_when_root(self):
     d = DependencyList()
     files = ["/users/joebloggs/tmp/foo.txt", "/dev/joebloggs/tmp/foo.txt"]
     d.add(*files, must_exist=False)
     self.assertEqual(d.common_path(), "/")
コード例 #18
0
 def test_expand_tilde(self):
     d = DependencyList()
     d.add("~/file1", "~/file2", must_exist=False)
     self.assertIn("/users/joebloggs/file1", d)
コード例 #19
0
 def test_dedup_cleaned_on_access_next(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file3", must_exist=False)
     n = next(d)
     self.assertTrue(d._clean)
コード例 #20
0
 def test_dedup_cleaned_on_access_len(self):
     d = DependencyList()
     d.add("/file1", must_exist=False)
     ls = len(d)
     self.assertTrue(d._clean)
コード例 #21
0
 def test_dedup_dirtied_on_add(self):
     d = DependencyList()
     d.add("/file1", must_exist=False)
     self.assertFalse(d._clean)
コード例 #22
0
 def test_dedup_same_filenames(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file2", must_exist=False)
     self.assertEqual(len(d), 2)
     self.assertIn("/file1", d)
     self.assertIn("/file2", d)
コード例 #23
0
 def test_expand_envvar(self):
     d = DependencyList()
     d.add("$SHOT/file1", "$HOME/file2", must_exist=False)
     self.assertIn("/metropolis/shot01/file1", d)
     self.assertIn("/users/joebloggs/file2", d)
コード例 #24
0
 def test_next(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file3", must_exist=False)
     self.assertEqual(next(d), "/file1")
     self.assertEqual(next(d), "/file2")
コード例 #25
0
 def test_adds_files(self):
     d = DependencyList()
     d.add("file1", "file2", must_exist=False)
     self.assertEqual(len(d), 2)