Ejemplo n.º 1
0
    def load(self, context, name=None, namespace=None, data=None):
        """Plugin entry point.

        Args:
            context (:class:`pyblish.api.Context`): Context.
            name (str, optional): Container name.
            namespace (str, optional): Container namespace.
            data (dict, optional): Additional data passed into loader.

        """
        # Load template.
        self_name = self.__class__.__name__
        temp_dir = tempfile.mkdtemp()
        zip_file = api.get_representation_path(context["representation"])
        template_path = os.path.join(temp_dir, "temp.tpl")
        with zipfile.ZipFile(zip_file, "r") as zip_ref:
            zip_ref.extractall(template_path)

        group_id = "{}".format(uuid.uuid4())

        container_group = harmony.send({
            "function":
            f"PypeHarmony.Loaders.{self_name}.loadContainer",
            "args": [
                template_path, context["asset"]["name"],
                context["subset"]["name"], group_id
            ]
        })["result"]

        # Cleanup the temp directory
        shutil.rmtree(temp_dir)

        # We must validate the group_node
        return harmony.containerise(name, namespace, container_group, context,
                                    self_name)
Ejemplo n.º 2
0
    def load(self, context, name=None, namespace=None, data=None):

        collections, remainder = clique.assemble(
            os.listdir(os.path.dirname(self.fname)))
        files = []
        if collections:
            for f in list(collections[0]):
                files.append(
                    os.path.join(os.path.dirname(self.fname),
                                 f).replace("\\", "/"))
        else:
            files.append(
                os.path.join(os.path.dirname(self.fname),
                             remainder[0]).replace("\\", "/"))

        name = context["subset"]["name"]
        name += "_{}".format(uuid.uuid4())
        read_node = harmony.send({
            "function": copy_files + import_files,
            "args": ["Top", files, name, 1]
        })["result"]

        return harmony.containerise(name,
                                    namespace,
                                    read_node,
                                    context,
                                    self.__class__.__name__,
                                    nodes=[read_node])
Ejemplo n.º 3
0
    def load(self, context, name=None, namespace=None, data=None):
        # Import template.
        temp_dir = tempfile.mkdtemp()
        zip_file = api.get_representation_path(context["representation"])
        template_path = os.path.join(temp_dir, "temp.tpl")
        with zipfile.ZipFile(zip_file, "r") as zip_ref:
            zip_ref.extractall(template_path)

        sig = harmony.signature("paste")
        func = """function %s(args)
        {
            var template_path = args[0];
            var drag_object = copyPaste.pasteTemplateIntoGroup(
                template_path, "Top", 1
            );
        }
        %s
        """ % (sig, sig)

        harmony.send({"function": func, "args": [template_path]})

        shutil.rmtree(temp_dir)

        subset_name = context["subset"]["name"]

        return harmony.containerise(subset_name, namespace, subset_name,
                                    context, self.__class__.__name__)

        def update(self, container, representation):
            pass

        def remove(self, container):
            pass
Ejemplo n.º 4
0
    def load(self, context, name=None, namespace=None, data=None):
        wav_file = api.get_representation_path(context["representation"])
        harmony.send({
            "function": func,
            "args": [context["subset"]["name"], wav_file]
        })

        subset_name = context["subset"]["name"]

        return harmony.containerise(subset_name, namespace, subset_name,
                                    context, self.__class__.__name__)
Ejemplo n.º 5
0
    def load(self, context, name=None, namespace=None, data=None):

        with open(self.fname) as json_file:
            data = json.load(json_file)

        layers = list()

        for child in data['children']:
            if child.get("filename"):
                layers.append(child["filename"])
            else:
                for layer in child['children']:
                    if layer.get("filename"):
                        layers.append(layer["filename"])

        bg_folder = os.path.dirname(self.fname)

        subset_name = context["subset"]["name"]
        # read_node_name += "_{}".format(uuid.uuid4())
        container_nodes = []

        for layer in sorted(layers):
            file_to_import = [
                os.path.join(bg_folder, layer).replace("\\", "/")
            ]

            read_node = harmony.send(
                {
                    "function": copy_files + import_files,
                    "args": ["Top", file_to_import, layer, 1]
                }
            )["result"]
            container_nodes.append(read_node)

        return harmony.containerise(
            subset_name,
            namespace,
            subset_name,
            context,
            self.__class__.__name__,
            nodes=container_nodes
        )
Ejemplo n.º 6
0
    def load(self, context, name=None, namespace=None, data=None):
        """Plugin entry point.

        Args:
            context (:class:`pyblish.api.Context`): Context.
            name (str, optional): Container name.
            namespace (str, optional): Container namespace.
            data (dict, optional): Additional data passed into loader.

        """
        fname = Path(self.fname)
        self_name = self.__class__.__name__
        collections, remainder = clique.assemble(
            os.listdir(fname.parent.as_posix()))
        files = []
        if collections:
            for f in list(collections[0]):
                files.append(fname.parent.joinpath(f).as_posix())
        else:
            files.append(fname.parent.joinpath(remainder[0]).as_posix())

        asset = context["asset"]["name"]
        subset = context["subset"]["name"]

        group_id = str(uuid.uuid4())
        read_node = harmony.send({
            "function":
            f"PypeHarmony.Loaders.{self_name}.importFiles",  # noqa: E501
            "args": [files, asset, subset, 1, group_id]
        })["result"]

        return harmony.containerise(f"{asset}_{subset}",
                                    namespace,
                                    read_node,
                                    context,
                                    self_name,
                                    nodes=[read_node])
Ejemplo n.º 7
0
    def load(self, context, name=None, namespace=None, data=None):
        name = self.load_palette(context["representation"])

        return harmony.containerise(name, namespace, name, context,
                                    self.__class__.__name__)