From 16bb134a7f4fc88827190125a1250727de65481d Mon Sep 17 00:00:00 2001 From: wijnand Date: Fri, 9 Mar 2018 16:56:55 +0100 Subject: [PATCH] renamed module, removed unused kwarg --- colorbleed/scripts/fusion_switch_shot.py | 6 +- colorbleed/scripts/slapcomp_switch.py | 87 ------------------------ 2 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 colorbleed/scripts/slapcomp_switch.py diff --git a/colorbleed/scripts/fusion_switch_shot.py b/colorbleed/scripts/fusion_switch_shot.py index 6119862b42..43ad149ca5 100644 --- a/colorbleed/scripts/fusion_switch_shot.py +++ b/colorbleed/scripts/fusion_switch_shot.py @@ -116,7 +116,7 @@ def update_frame_range(comp, representations): fusion_lib.update_frame_range(start, end, comp=comp) -def switch(filepath, asset_name, new=True, fusion=None): +def switch(filepath, asset_name, new=True): """Switch the current containers of the file to the other asset (shot) Args: @@ -144,14 +144,12 @@ def switch(filepath, asset_name, new=True, fusion=None): assert asset, "Could not find '%s' in the database" % asset_name # Go to comp - if fusion is None: - fusion = _get_fusion_instance() + fusion = _get_fusion_instance() current_comp = fusion.LoadComp(filepath) assert current_comp is not None, "Fusion could not load '%s'" % filepath host = api.registered_host() - assert host is not None, "No host found! This is a bug" containers = list(host.ls()) assert containers, "Nothing to update" diff --git a/colorbleed/scripts/slapcomp_switch.py b/colorbleed/scripts/slapcomp_switch.py deleted file mode 100644 index 95270259aa..0000000000 --- a/colorbleed/scripts/slapcomp_switch.py +++ /dev/null @@ -1,87 +0,0 @@ -import logging -import argparse - -import avalon.io as io -import avalon.api as api -import avalon.fusion - - -log = logging.getLogger("UpdateSlapComp") - - -def switch(shot): - """Update comp loaders through the containers - - Args: - data (dict): collection if {asset: [subset, subset]} - """ - - host = api.registered_host() - containers = list(host.ls()) - - targets = [c["name"] for c in containers] - - representations = {} - - asset = io.find_one({"type": "asset", "name": shot}) - assert asset, ("Could not find asset in the database with the name " - "'%s'" % shot) - - subsets = io.find({"type": "subset", - "name": {"$in": targets}, - "parent": asset["_id"]}) - - if len(subsets) != len(targets): - log.warning("Could not find the same amount of subsets in '%s'" % shot) - - for subset in subsets: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[('name', -1)]) - - if not version: - log.error("Could not find a verison for {}.{}".format( - asset["name"], subset["name"] - )) - continue - - representation = io.find_one({"type": "representation", - "parent": version["_id"]}) - - representations[subset["name"]] = representation - - count = 0 - for i, container in enumerate(containers): - subsetname = container["name"] - if subsetname not in representations: - log.error("Subset '%s' not found in comp, skipping" % subsetname) - continue - - representation = representations[container["name"]] - api.switch(container, representation) - count += 1 - - log.info("Updated %i items" % count) - - -if __name__ == '__main__': - - parser = argparse.ArgumentParser() - - parser.add_argument("--shot", - help="Shotname to update the current comp to") - - parser.add_argument("--targets", - optional=True, - help="A list of target to update with given data") - - args = parser.parse_known_args() - if not args.shot: - raise RuntimeError("No data given, cannot update slap comp") - - if not isinstance(args.shot, dict): - raise ValueError("Expecting data in the form of a dict, got " - "%s" % type(args.shot)) - - api.install(avalon.fusion) - switch(shot=args.shot)