def from_filepath(cls, filepath): if not os.path.exists(filepath): logging.warning("No Tape found in: {} ".format(filepath)) return asset_parse = parse.search(templates.ASSET_WORKAREA, filepath) if asset_parse: return AssetTape(asset_parse.named.get("asset"), asset_type=asset_parse.named.get("asset_type", None), task=asset_parse.named.get("task", None), workfile=os.path.splitext(os.path.basename(filepath))[0]) shot_parse = parse.search(templates.SHOT_WORKAREA, filepath) if shot_parse: return ShotTape(shot_parse.named.get("instance"), task=shot_parse.named.get("task", None))
def from_filepath(cls, filepath): parsed = parse.search(templates.SHOT, filepath) if not parsed: logger.warning( "Invalid filepath: {} Expected: {}".format(filepath, templates.SHOT) ) else: return cls( parsed.named.get("shot"), task=parsed.named.get("task"), project_root=jukebox.project.find_project_from_path(os.path.dirname(filepath)), )
def from_filepath(cls, filepath): parsed = parse.search(templates.ASSET_WORKAREA, filepath) if not parsed: logger.warning( "Invalid filepath: {} Expected: {}".format(filepath, templates.ASSET) ) else: return cls( parsed.named.get("asset"), asset_type=parsed.named.get("asset_type"), task=parsed.named.get("task"), project_root=jukebox.project.find_project_from_path(os.path.dirname(filepath)), workfile=os.path.splitext(os.path.basename(filepath))[0] )
def from_filepath(cls, filepath): if not os.path.exists(filepath): logging.warning("No Song found in: {} ".format(filepath)) return asset_parse = parse.search(templates.ASSET_OUTPUT, filepath) if asset_parse: return cls( filepath, asset=asset_parse.named.get("asset"), datatype=asset_parse.named.get("datatype"), asset_type=asset_parse.named.get("asset_type"), name=asset_parse.named.get("name"), ) shot_parse = parse.search(templates.SHOT_OUTPUT, filepath) if shot_parse: return cls( filepath, datatype=asset_parse.named.get("datatype"), shot=asset_parse.named.get("shot"), identifier=asset_parse.named.get("identifier"), name=asset_parse.named.get("name"), )
def remap_template(target=templates.ASSET_WORKAREA): # source = r"{DCC_ROOT}\scenes\assets\{asset_type}\city\assembly\{asset}\\" # # Get all 'paths' in {DCC_ROOT}/scenes/assets folder # root = r"C:\Users\their\Documents\AJ_source\MAYA\scenes\assets\sets\city\assembly" asset_folders = [ os.path.join(root, x[0]) for x in next(os.walk(root)) if (not os.path.isfile(os.path.join(root, x[0])) and not x[0].endswith( (".mayaSwatches"))) ] for _, dirs, _ in os.walk(root): for dirName in dirs: if (not os.path.isfile(os.path.join(root, dirName)) and not dirName.endswith((".mayaSwatches", "archive"))): asset_folders.append(os.path.join(root, dirName)) break #prevent descending into subfolders print(asset_folders) for asset_folder in asset_folders[1:]: # print("asset folder", asset_folder) try: path = [ os.path.join(asset_folder, x[0]) for x in os.walk(asset_folder) ][0] except IndexError: continue # print(path) # Parse path to match source template and get fields fields = parse.search(source, path + r"\\").named # print(fields) fields.update({ "DCC_ROOT": r"C:\Users\their\Documents\AJ_source\MAYA", "task": "model", }) # fields.update({"asset_type":"env"}) # for second set of ROOT SOURCE # print(target) formatted_target = target.format(**fields) print("Copying {} to {}".format(path, formatted_target)) dir_util.copy_tree(path, formatted_target) print("Removing {}".format(path)) shutil.rmtree(path)