def test_relative_path_returns_a_path_with_env_var(self): """testing if the relative_path returns a path starting with $REPO """ test_value = "TEST/Seqs/Seq1/Shots/SH001/FX/SH001_Main_FX_v001_oy.hip" test_path = os.path.join(self.temp_projects_folder, test_value) expected = "$" + conf.repository_env_key + "/" + test_value repo = Repository() self.assertEqual(repo.relative_path(test_path), expected)
def reference(self, version): """References the given Version instance to the current Maya scene. :param version: The desired :class:`~oyProjectManager.models.version.Version` instance to be referenced. """ # use the file name without extension as the namespace namespace = os.path.basename(version.filename) repo = Repository() workspace_path = pm.workspace.path new_version_full_path = version.full_path if version.full_path.startswith(workspace_path): new_version_full_path = utils.relpath( workspace_path, version.full_path.replace("\\", "/"), "/", ".." ) # replace the path with environment variable new_version_full_path = repo.relative_path(new_version_full_path) ref = pm.createReference( new_version_full_path, gl=True, loadReferenceDepth='none', namespace=namespace, options='v=0' ) # replace external paths self.replace_external_paths(1) # set the reference state to loaded if not ref.isLoaded(): ref.load() # append the referenced version to the current versions references # attribute current_version = self.get_current_version() if current_version: current_version.references.append(version) current_version.save() return True
def reference(self, version): """References the given Version instance to the current Maya scene. :param version: The desired :class:`~oyProjectManager.models.version.Version` instance to be referenced. """ # use the file name without extension as the namespace namespace = os.path.basename(version.filename) repo = Repository() workspace_path = pm.workspace.path new_version_full_path = version.full_path if version.full_path.startswith(workspace_path): new_version_full_path = utils.relpath( workspace_path, version.full_path.replace("\\", "/"), "/", "..") # replace the path with environment variable new_version_full_path = repo.relative_path(new_version_full_path) ref = pm.createReference(new_version_full_path, gl=True, loadReferenceDepth='none', namespace=namespace, options='v=0') # replace external paths self.replace_external_paths(1) # set the reference state to loaded if not ref.isLoaded(): ref.load() # append the referenced version to the current versions references # attribute current_version = self.get_current_version() if current_version: current_version.references.append(version) current_version.save() return True