Пример #1
0
	def _remove(self):
		""" Add a node or information to a node """
		try:
			if self._actions[1] == 'meta':
				_results									= []
				try:
					for _node in self._values[0]:
						try:
							_subresults						= []
							for _meta in self._values[0][_node]:
								_subresults.append(manager.call(_node,'remMeta',_meta))
							_results.append(_subresults)
						except IndexError:
							_results.append(False)
					return _results
				except:
					return `False`
			elif self._actions[1] == 'links':
				_results									= []
				try:
					# For each node we want to add new links to
					for _node in self._values[0]:
						try:
							_subresults						= []
							# For each destination node
							for _dest in self._values[0][_node]:
								_ssubresults				= []
								# For each link type
								for _type in self._values[0][_node][_dest]:
									_ssubresults.append(manager.call(_node,'remLink',_dest,_type))
								_subresults.append(_ssubresults)
							_results.append(_subresults)
						except IndexError:
							_results.append(False)
					return _results
				except:
					return `False`
			elif self._actions[1] == 'data':
				_ids										= []
				for i in self._values[0]:
					_ids.append(manager.call(i,'remData'))
				return _ids
		except:
			_ids											= []
			for i in self._values[0]:
				_ids.append(manager.remove(i))
			return _ids
Пример #2
0
	def _add(self):
		""" Add a node or information to a node """
		try:
			if self._actions[1] == 'meta':
				_results									= []
				try:
					for _node in self._values[0]:
						try:
							_subresults						= []
							for _meta in self._values[0][_node]:
								_subresults.append(manager.call(_node,'addMeta',_meta))
							_results.append(_subresults)
						except IndexError:
							_results.append(False)
					return _results
				except:
					return False
			elif self._actions[1] == 'links':
				_results									= []
				try:
					# For each node we want to add new links to
					for _node in self._values[0]:
						try:
							_subresults						= []
							# For each destination node
							for _dest in self._values[0][_node].keys():
								_ssubresults				= []
								# For each link type
								for _type in self._values[0][_node][_dest]:
									_ssubresults.append(manager.call(_node,'addLink',_dest,_type))
								_subresults.append(_ssubresults)
							_results.append(_subresults)
						except IndexError:
							_results.append(False)
					return _results
				except:
					return False
			elif self._actions[1] == 'data':
				_results									= []
				try:
					for _node in self._values[0].keys():
						try:
							_subresults						= []
							for _data in self._values[0][_node]:
								_subresults.append(manager.call(_node,'addData',_data))
							_results.append(_subresults)
						except IndexError:
							_results.append(False)
					return _results
				except:
					return False
			else:
				return False
		except:
			# We are adding nodes to the system, loop through the list
			_ids											= []
			for i in self._values[0]:
				_id											= manager.create()
				# Add the meta data
				try:
					for meta in i[0]:
						manager.call(_id, 'addMeta', meta)
				except:
					pass
				# Add links
				try:
					for _dest in i[1].keys():
						for _type in i[1][_dest]:
							manager.call(_id, 'addLink', _dest, _type)
				except:
					pass
				# Add Data
				result										= manager.call(_id, 'addData', i[2])
				# Commit the node
				_ids.append(_id)
			return _ids
Пример #3
0
	def _get(self):
		""" Get information from nodes """
		# Check what we are supposed to be getting
		try:
			if self._actions[1] == 'meta':
				_meta										= []
				try:
					for i in self._values[0]:
						try:
							_meta.append(manager.call(i,'getMeta'))
						except IndexError:
							_meta.append(False)
					return _meta
				except:
					return False
			elif self._actions[1] == 'links':
				# Check if we have a dictionary or a list
				if isinstance(self._values[0],list):
					_links									= []
					try:
						for i in self._values[0]:
							try:
								_links.append(manager.call(i,'getLinks'))
							except IndexError:
								_links.append(False)
						return _links
					except:
						return False
				elif isinstance(self._values[0],dict):
					_links									= []
					try:
						for i in self._values[0].keys():
							try:
								_links.append(manager.call(i,'getLinks',*tuple(self._values[0][i])))
							except IndexError:
								_links.append(False)
						return _links
					except:
						return False
				else:
					return False
			elif self._actions[1] == 'data':
				_data										= []
				try:
					for i in self._values[0]:
						try:
							_data.append(manager.call(i,'getData'))
						except IndexError:
							_data.append(False)
					return _data
				except:
					return False
			elif self._actions[1] == 'mime':
				_mimes										= []
				try:
					for i in self._values[0]:
						try:
							_mimes.append(manager.call(i,'getMime'))
						except IndexError:
							_mimes.append(False)
					return _mimes
				except:
					return False
			elif self._actions[1] == 'size':
				_sizes										= []
				try:
					for i in self._values[0]:
						try:
							_sizes.append(manager.call(i,'getSize'))
						except IndexError:
							_sizes.append(False)
					return _sizes
				except:
					return False
			elif self._actions[1] == 'created':
				_creations									= []
				try:
					for i in self._values[0]:
						try:
							_creations.append(manager.call(i,'getCreated'))
						except IndexError:
							_creations.append(False)
					return _creations
				except:
					return False
			elif self._actions[1] == 'modified':
				_modifies									= []
				try:
					for i in self._values[0]:
						try:
							_modifies.append(manager.call(i,'getModified'))
						except IndexError:
							_modifies.append(False)
					return _modifies
				except:
					return False
		except:
			# Fetch node information from the node list
			_ids											= []
			for i in self._values[0]:
				try:
					_ids.append(manager.call(i,'get'))
				except:
					_ids.append(None)
			return _ids