Пример #1
0
    def test_import_examples(self):

        for cat in examples_paths:

            if not examples_paths.get(cat):
                info("Dir named: %s is empty", cat)
                continue

            info("Opening Dir named: %s", cat)

            examples_set = Path(examples_paths.get(cat))
            for listed_path in examples_set.iterdir():

                # cast from Path class to dumb string.
                path = str(listed_path)

                # assuming these are all jsons for now.
                name = basename(path)

                if name in UNITTEST_BLACKLIST:
                    info("Skipping (blacklisted) : %s to permit unit tests to continue", name)
                    continue

                with self.subTest(file=name):
                    # info("Importing: %s", name)
                    with self.temporary_node_tree("ImportedTree") as new_tree:
                        with self.assert_logs_no_errors():
                            # Do not try to process imported tree,
                            # that will just take time anyway
                            new_tree.sv_process = False
                            import_tree(new_tree, path)
                        for node in new_tree.nodes:
                            if is_old(node):
                                error_format = "This example contains deprecated node `{}' ({}). Please upgrade the example file." 
                                self.fail(error_format.format(node.name, node.bl_idname))
Пример #2
0
    def test_import_examples(self):

        for cat in examples_paths:

            if not examples_paths.get(cat):
                info("Dir named: %s is empty", cat)
                continue

            info("Opening Dir named: %s", cat)

            examples_set = Path(examples_paths.get(cat))
            for listed_path in examples_set.iterdir():

                # cast from Path class to dumb string.
                path = str(listed_path)

                # assuming these are all jsons for now.
                name = basename(path)

                if name in UNITTEST_BLACKLIST:
                    info("Skipping (blacklisted) : %s to permit unit tests to continue", name)
                    continue

                with self.subTest(file=name):
                    info("Importing: %s", name)
                    with self.temporary_node_tree("ImportedTree") as new_tree:
                        with self.assert_logs_no_errors():
                            # Do not try to process imported tree,
                            # that will just take time anyway
                            new_tree.sv_process = False
                            import_tree(new_tree, path)
                        for node in new_tree.nodes:
                            if is_old(node):
                                error_format = "This example contains deprecated node `{}' ({}). Please upgrade the example file." 
                                self.fail(error_format.format(node.name, node.bl_idname))
Пример #3
0
def draw_item(self, context, item):

    ntree = context.space_data.node_tree
    if not ntree:
        ntree = lambda: None
        ntree.name = '____make_new____'

    self.path_menu(searchpaths=[examples_paths.get(item)],
                   operator='node.tree_importer_silent',
                   props_default={"id_tree": ntree.name})