def remove_reference(self, reference): ''' Remove the given reference, if it exists, and return True. Otherwise do nothing, and return False. ''' try: self._datadict[Body.REFERENCES].remove(reference) return True except ValueError: return False pipeline_io.writefile(self._pipeline_file, self._datadict)
def _create_user(self, username): workspace = os.path.join(self._project_dir, os.path.join(self.get_users_dir(), username)) if not os.path.exists(workspace): if not pipeline_io.mkdir(workspace): print("failed to create workspace") user_pipeline_file = os.path.join(workspace, User.PIPELINE_FILENAME) if not os.path.exists(user_pipeline_file): datadict = User.create_new_dict(username) pipeline_io.writefile(user_pipeline_file, datadict)
def add_reference(self, reference): ''' Add the given reference to this body. If it already exists, do nothing. If reference is not a valid body, raise an EnvironmentError. ''' ref_asset_path = os.path.join(self._env.get_assets_dir(), reference, Body.PIPELINE_FILENAME) ref_shot_path = os.path.join(self._env.get_shots_dir(), reference, Body.PIPELINE_FILENAME) ref_crowd_path = os.path.join(self._env.get_crowds_dir(), reference, Body.PIPELINE_FILENAME) if not os.path.exists(ref_asset_path) and not os.path.exists(ref_shot_path) and not os.path.exists(ref_crowd_path): raise EnvironmentError(reference + ' is not a valid body') if reference not in self._datadict[Body.REFERENCES]: self._datadict[Body.REFERENCES].append(reference) pipeline_io.writefile(self._pipeline_file, self._datadict)
def create_element(self, department, name): ''' create an element for this body from the given department and return the resulting element object. Raises EnvironmentError if the element already exists. department -- the department to create the element for name -- the name of the element to create ''' dept_dir = os.path.join(self._filepath, department) if not os.path.exists(dept_dir): pipeline_io.mkdir(dept_dir) empty_element = Element() datadict = empty_element.create_new_dict(name, department, self.get_name()) if os.path.exists(os.path.join(dept_dir, empty_element.PIPELINE_FILENAME)): print("element already exists: " + dept_dir) return None pipeline_io.writefile(os.path.join(dept_dir, empty_element.PIPELINE_FILENAME), datadict) return self.set_app_ext(department, dept_dir)
def update_fullname(self, new_name): self._datadict[self.NAME] = new_name pipeline_io.writefile(self._pipeline_file, self._datadict)
def update_email(self, new_email): self._datadict[self.EMAIL] = new_email pipeline_io.writefile(self._pipeline_file, self._datadict)
def update_type(self, new_type): self._datadict[Body.TYPE] = new_type pipeline_io.writefile(self._pipeline_file, self._datadict)
def update_description(self, description): self._datadict[Body.DESCRIPTION] = description pipeline_io.writefile(self._pipeline_file, self._datadict)
def set_camera_number(self, num): self._datadict[Body.CAMERA_NUMBER] = num pipeline_io.writefile(self._pipeline_file, self._datadict)
def update_frame_range(self, frame_range): self._datadict[Body.FRAME_RANGE] = frame_range pipeline_io.writefile(self._pipeline_file, self._datadict)