Exemple #1
0
    def process(self, instance):
        # in  = thedeal/dev/conceptArt/characters/ben/ben_model.png
        # out = thedeal/asset/model/characters/ben/conceptArt
        input_path = instance.data("path")

        self.log.info("Conforming %s" % input_path)
        self.log.info("Assuming environment variable: PROJECTROOT")

        if "PROJECTROOT" not in os.environ:
            raise Exception("Missing environment variable \"PROJECTROOT\"")

        schema = pyblish_magenta.schema.load()
        data, template = schema.parse(input_path)

        self.log.info("Schema successfully parsed")
        new_name = template.name.replace('dev', 'asset')
        asset_template = schema.get_template(new_name)
        output_path = asset_template.format(data)
        self.log.info("Output path successfully generated: %s" % output_path)

        self.log.info("Conforming %s to %s" %
                      (instance, "..." + output_path[-35:]))

        if not os.path.exists(output_path):
            os.makedirs(output_path)

        try:
            shutil.copy(input_path, output_path)
        except:
            raise pyblish.api.ConformError("Could not conform %s" % instance)
        else:
            self.log.info("Successfully conformed %s!" % instance)
Exemple #2
0
    def compute_publish_directory(self, path):
        """Given the current file, determine where to publish

        Arguments:
            path (str): Absolute path to the current working file

        """

        self.log.debug("Loading schema..")
        schema = pyblish_magenta.schema.load()

        self.log.debug("Parsing with current file: %s" % path)
        data, template = schema.parse(path)

        # TOPICS are a space-separated list of user-supplied topics
        # E.g. "thedeal seq01 1000 animation"
        task = os.environ["TOPICS"].split()[-1]
        assert task == data["task"], (
            "Task set in environment ({env}) is not the same as "
            "the one parsed ({data})".format(env=task, data=data["task"]))

        self.log.info("Retrieving template from schema..")
        pattern = schema.get(template.name.rsplit(".work", 1)[0] + ".publish")

        self.log.info("Got \"%s\": formatting with %s" % (pattern, data))
        return pattern.format(data)
    def compute_publish_directory(self, path):
        """Given the current file, determine where to publish

        Arguments:
            path (str): Absolute path to the current working file

        """

        self.log.debug("Loading schema..")
        schema = pyblish_magenta.schema.load()

        self.log.debug("Parsing with current file: %s" % path)
        data, template = schema.parse(path)

        # TOPICS are a space-separated list of user-supplied topics
        # E.g. "thedeal seq01 1000 animation"
        task = os.environ["TOPICS"].split()[-1]
        assert task == data["task"], (
            "Task set in environment ({env}) is not the same as "
            "the one parsed ({data})".format(env=task, data=data["task"])
        )

        self.log.info("Retrieving template from schema..")
        pattern = schema.get(template.name.rsplit(".work", 1)[0] + ".publish")

        self.log.info('Got "%s": formatting with %s' % (pattern, data))
        return pattern.format(data)
    def process(self, context):
        from maya import cmds

        if "origin" not in context:
            context.create_instance("origin", family="metadata")

        fname = cmds.file(query=True, expandName=True)
        instance = context["origin"]
        instance.set_data("metadata", {
            "filename": fname
        })

        self.log.debug("Loading schema..")
        schema = pyblish_magenta.schema.load()
        self.log.info("Collecting references..")

        references = dict()
        for reference in cmds.ls(type="reference"):
            if reference in ("sharedReferenceNode",):
                continue

            # Only consider top-level references
            reference = cmds.referenceQuery(reference,
                                            referenceNode=True,
                                            topReference=True)

            filename = cmds.referenceQuery(
                reference,
                filename=True,
                withoutCopyNumber=True)  # Exclude suffix {1}

            if filename in references:
                continue

            data, template = schema.parse(filename)
            project = os.path.basename(data["root"])

            self.log.info("Parsed with schema %s" % data)

            references[filename] = {
                "filename": filename,
                "project": project,
                "task": data["task"],
                "item": data["asset"]
            }

            self.log.info("Collecting %s" % references[filename])

        instance[:] = references.values()
Exemple #5
0
    def process(self, context):
        from maya import cmds

        if "origin" not in context:
            context.create_instance("origin", family="metadata")

        instance = context["origin"]

        self.log.debug("Loading schema..")
        schema = pyblish_magenta.schema.load()
        self.log.info("Collecting references..")

        references = dict()
        for reference in cmds.ls(type="reference"):
            if reference in ("sharedReferenceNode", ):
                continue

            # Only consider top-level references
            reference = cmds.referenceQuery(reference,
                                            referenceNode=True,
                                            topReference=True)

            filename = cmds.referenceQuery(
                reference, filename=True,
                withoutCopyNumber=True)  # Exclude suffix {1}

            if filename in references:
                continue

            data, template = schema.parse(filename)
            project = os.path.basename(data["root"])

            self.log.info("Parsed with schema %s" % data)

            references[filename] = {
                "filename": filename,
                "project": project,
                "task": data["task"],
                "item": data["asset"]
            }

            self.log.info("Collecting %s" % references[filename])

        instance[:] = references.values()