def test_mkdir_for_non_existing_path(self): """testing if mkdir will create the given path without any error """ # create a temp path tempdir = tempfile.mktemp() # create the dir utils.mkdir(tempdir) # now check if the path exists self.assertTrue(os.path.exists(tempdir)) # clean the test os.rmdir(tempdir)
def test_mkdir_for_existing_path(self): """testing if mkdir will greacefuly handle the exception if the given path already exists """ # create a temp path tempdir = tempfile.mktemp() # create the dir os.makedirs(tempdir) # create the dir with mkdir # it should handle the error utils.mkdir(tempdir) # clean the test os.rmdir(tempdir)
def set_playblast_file_name(self, version): """sets the playblast file name """ playblast_path = os.path.join(version.output_path, "Playblast") # use project name and sequence name if available playblast_filename = version.version_of.project.code if version.type.type_for == "Shot": playblast_filename += "_" + version.version_of.sequence.code playblast_filename += "_" + os.path.splitext(version.filename)[0] playblast_full_path = os.path.join(playblast_path, playblast_filename).replace( '\\', '/') # create the folder utils.mkdir(playblast_path) pm.optionVar['playblastFile'] = playblast_full_path
def set_playblast_file_name(self, version): """sets the playblast file name """ playblast_path = os.path.join( version.output_path, "Playblast" ) # use project name and sequence name if available playblast_filename = version.version_of.project.code if version.type.type_for == "Shot": playblast_filename += "_" + version.version_of.sequence.code playblast_filename += "_" + os.path.splitext(version.filename)[0] playblast_full_path = os.path.join( playblast_path, playblast_filename ).replace('\\', '/') # create the folder utils.mkdir(playblast_path) pm.optionVar['playblastFile'] = playblast_full_path
def create(self): """Creates the project directory structure and saves the project, thus creates the ``.metadata.db`` file in the repository. """ # check if the folder already exists utils.mkdir(self.full_path) # create the structure if it is not present rendered_structure = jinja2.Template(self.structure).\ render(project=self) folders = rendered_structure.split("\n") if len(folders): for folder in rendered_structure.split("\n"): try: utils.createFolder(folder.strip()) except OSError: pass self._exists = True self.save()