Ejemplo n.º 1
0
	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)
Ejemplo n.º 2
0
	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)
Ejemplo n.º 3
0
	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)
		name = pipeline_io.alphanumeric(name)
		element_dir = os.path.join(dept_dir, name)
		if not pipeline_io.mkdir(element_dir):
			raise EnvironmentError('element already exists: ' + element_dir)
		empty_element = Registry().create_element(department)
		datadict = empty_element.create_new_dict(name, department, self.get_name())
		pipeline_io.writefile(os.path.join(element_dir, empty_element.PIPELINE_FILENAME), datadict)
		return Registry().create_element(department, element_dir)
Ejemplo n.º 4
0
	def update_description(self, description):

		self._datadict[Body.DESCRIPTION] = description
		pipeline_io.writefile(self._pipeline_file, self._datadict)
Ejemplo n.º 5
0
	def update_frame_range(self, frame_range):

		self._datadict[Body.FRAME_RANGE] = frame_range
		pipeline_io.writefile(self._pipeline_file, self._datadict)
Ejemplo n.º 6
0
	def update_type(self, new_type):

		self._datadict[Body.TYPE] = new_type
		pipeline_io.writefile(self._pipeline_file, self._datadict)