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")
    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()
 def test_dedup_contained_file(self):
     d = DependencyList()
     d.add("/dir1/",
           "/dir1/file1",
           "/dir2/file1",
           "file2",
           must_exist=False)
     self.assertEqual(len(d), 3)
 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)
 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")
 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")
 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")
 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")
Пример #9
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)
        }
Пример #10
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)
        }
 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)
 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)
    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()
 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")
Пример #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
 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)
 def test_common_path_is_none_when_no_entries(self):
     d = DependencyList()
     self.assertIsNone(d.common_path())
 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(), "/")
 def test_init_empty(self):
     d = DependencyList()
     self.assertEqual(list(d), [])
Пример #20
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
 def test_next(self):
     d = DependencyList()
     d.add("/file1", "/file2", "/file3", must_exist=False)
     self.assertEqual(next(d), "/file1")
     self.assertEqual(next(d), "/file2")
 def test_adds_files(self):
     d = DependencyList()
     d.add("file1", "file2", must_exist=False)
     self.assertEqual(len(d), 2)
 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)
 def test_dedup_cleaned_on_access_len(self):
     d = DependencyList()
     d.add("/file1", must_exist=False)
     ls = len(d)
     self.assertTrue(d._clean)
 def test_dedup_dirtied_on_add(self):
     d = DependencyList()
     d.add("/file1", must_exist=False)
     self.assertFalse(d._clean)
 def test_expand_tilde(self):
     d = DependencyList()
     d.add("~/file1", "~/file2", must_exist=False)
     self.assertIn("/users/joebloggs/file1", d)
 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)