예제 #1
0
	def do_append(self):
		""" """
		
		#debug
		'''
		self.debug('self.AppendingCollectionVariable is '+str(self.AppendingCollectionVariable))
		'''

		#TuplesList Case
		if SYS.getIsTuplesListBool(self.AppendingCollectionVariable):

			#debug
			'''
			self.debug('This is a tuples list')
			'''

			#Definition the KeyStrsList
			AppendedKeyStrsList=SYS.unzip(self.AppendingCollectionVariable,[0])

			#Look for an AppendingNodeCollectionStr
			try:
				NodeCollectionStrIndexInt=AppendedKeyStrsList.index(
					"NodeCollectionStr"
				)
				self.AppendedNodeCollectionStr=self.AppendingCollectionVariable[
					NodeCollectionStrIndexInt
				][1]
				
				'''
				#self.AppendedKeyStrKeyStr='Noded'+self.AppendedNodeCollectionStr+'KeyStr'
				try:
					AppendedKeyStrIndexInt=AppendedKeyStrsList.index(
						self.AppendedKeyStrKeyStr
					)
					self.AppendedKeyStr=self.AppendingCollectionVariable[KeyStrIndexInt][1]
				except:
					pass
				'''
				NodeKeyStrIndexInt=AppendedKeyStrsList.index(
					"NodeKeyStr"
				)
				self.AppendedNodeKeyStr=self.AppendingCollectionVariable[
					NodeKeyStrIndexInt
				][1]

			except:
				pass

		else:

			#Objects Case
			if "AppenderClass" in map(
							lambda __Class:
							__Class.__name__,
							type(self.AppendingCollectionVariable).__mro__
							):

				#debug
				'''
				self.debug('This is a derived object from an Appender')
				'''

				#set
				AppendedDict=self.AppendingCollectionVariable.__dict__

			#dict Case
			elif type(self.AppendingCollectionVariable) in [dict,collections.OrderedDict]:
				AppendedDict=self.AppendingCollectionVariable

			try:

				#set
				self.AppendedNodeCollectionStr=AppendedDict["NodeCollectionStr"]
				self.AppendedNodeKeyStr=AppendedDict[
						'NodeKeyStr'
				]
			
			except:
				pass

		#Init the SettingVariable and Add the NodifyingStr
		AppendedSettingKeyVariable=Noder.NodingPrefixGetStr+self.AppendedNodeCollectionStr+Noder.NodingSuffixGetStr+self.AppendedNodeKeyStr

		#debug
		self.debug([
						('self.',self,[
											'AppendedNodeCollectionStr',
											'AppendedNodeKeyStr'
										])
					]
				)

		#Then set
		if AppendedSettingKeyVariable!=Noder.NodingPrefixGetStr+Noder.NodingSuffixGetStr:
			self.__setitem__(
								AppendedSettingKeyVariable,
								self.AppendingCollectionVariable
							)
	def do_team(self):

		#debug
		'''
		self.debug(
			('self.',self,[
					'TeamingKeyStr',
					'TeamingValueVariable'
				])
		)
		'''

		#Check
		if self.TeamingValueVariable==None:

			#try to get
			try:

				#get
				self.TeamedValueVariable=self.TeamDict[
					self.TeamingKeyStr
				]

				#set
				self.TeamedIsBool=True
			
			except KeyError:

				#init
				self.TeamedValueVariable=self.TeamingValueClass()

				#set
				self.TeamedIsBool=False

		else:

			#init
			self.TeamedIsBool=False

			#alias
			self.TeamedValueVariable=self.TeamingValueVariable

		#Check
		if self.TeamedIsBool==False:

			#/####################/#
			# Case where it is a dict or tuples list like
			# we wrap then in a manager new object

			#Check
			if hasattr(
				self.TeamedValueVariable,
				'items'
			) or SYS.getIsTuplesListBool(self.TeamedValueVariable):

				#init
				self.TeamedValueVariable=Manager.ManagerClass(
					)['#map@set'](
						self.TeamedValueVariable
					)

			#set in the __dict__
			self.__setattr__(
					self.TeamingKeyStr+type(
						self.TeamedValueVariable
					).NameStr,
					self.TeamedValueVariable
				)

			#put in the dict
			self.TeamDict[
				self.TeamingKeyStr
			]=self.TeamedValueVariable

			##########################
			#give some team attributes
			#

			#debug
			'''
			self.debug(
				'We make point the teamed instance to self'
			)
			'''

			#set
			'''
			self.TeamedValueVariable.point(
					self,
					'TeamPointDeriveTeamer'
				)
			'''
			self.TeamedValueVariable.TeamPointDeriveTeamer=self
				
			#debug
			'''
			self.debug(
				'Ok it is pointed'
			)	
			'''

			#set
			self.TeamedValueVariable.__setattr__(
				'TeamTagStr',
				self.TeamingKeyStr
			)
	def mimic_set(self):

		#Check
		if type(self.SettingKeyVariable)==str:

			#Check
			if self.SettingKeyVariable.startswith(ConnectGetSetPrefixStr):

				if type(
					self.SettingValueVariable
				)==list and SYS.getIsTuplesListBool(self.SettingValueVariable
				)==False and len(self.SettingValueVariable)==2:

					#debug
					'''
					self.debug(
							[
								'We set connect here',
								('self.',self,['SettingKeyVariable'])
							]
						)
					'''

					#connect
					self.connect(
							SYS.deprefix(
								self.SettingKeyVariable,
								ConnectGetSetPrefixStr
							),
							self.SettingValueVariable[0],
							self.SettingValueVariable[1]
						)

					#return
					return {'HookingIsBool':False}

				else:

					#debug
					'''
					self.debug(
							[
								'We set connect back here',
								('self.',self,['SettingKeyVariable'])
							]
						)
					'''

					#connect
					self.connect(
							SYS.deprefix(
								self.SettingKeyVariable,
								ConnectGetSetPrefixStr
							),
							self.SettingValueVariable
						) 

					#return
					return {'HookingIsBool':False}

		#set
		BaseClass.set(self)
예제 #4
0
	def do_array(self):
		
		#debug
		'''
		self.debug(
				[
					'we array here',
					('self.',self,['ArrayingKeyVariablesList'])
				]
			)
		'''
		
		#Check
		if len(self.ArrayingKeyVariablesList)>0:

			
			#/####################/#
			# Is it going to be a set with several layers
			#

			#debug
			'''
			self.debug(
					[
						'Is it going to be a set with several layers ?',
						('self.',self,[
							'ArrayingKeyVariablesList',
							'ArrayingValueVariable'
						])
					]
				)
			'''

			#Check
			if SYS.getIsListsListBool(self.ArrayingKeyVariablesList):

				#debug
				'''
				self.debug(
					[
						'set with several layers',
						('self.',self,['ArrayingValueVariable'])
					]
				)
				'''

				#/####################/#
				# Adapt the shape of the ValueVariable
				#

				#list default
				ArrayedLocalValueVariablesList=[]
				ArrayedDeepValueVariable=[]

				#Check
				if self.ArrayingValueVariable!=None:

					#Check
					if len(
						self.ArrayingValueVariable
					)==1 and len(self.ArrayingKeyVariablesList[0])>1:

						#listify
						self.ArrayingValueVariable=[self.ArrayingValueVariable]

					#Check
					if type(self.ArrayingValueVariable)!=list:
						

						#debug
						'''
						self.debug(
							[
								'This is a total same setting',
								('self.',self,[
									'ArrayingKeyVariablesList',
									'ArrayingValueVariable'
								])
							]
						)
						'''
						
						#list
						ArrayedLocalValueVariablesList=[self.ArrayingValueVariable]*len(
							self.ArrayingKeyVariablesList[0]
						)
						ArrayedDeepValueVariable=self.ArrayingValueVariable

					elif len(self.ArrayingValueVariable)>0:

						#Check
						if SYS.getIsTuplesListBool(self.ArrayingValueVariable[0]) or hasattr(
							self.ArrayingValueVariable[0],'items'
						):

						 	#debug
						 	'''
						 	self.debug('This is an identical layered array setting')
						 	'''

						 	#list
						 	ArrayedLocalValueVariablesList=[self.ArrayingValueVariable[0]]*len(
						 		self.ArrayingKeyVariablesList
						 	)
						 	ArrayedDeepValueVariable=self.ArrayingValueVariable[1:]

						else:

							#debug
							'''
						 	self.debug('This is an original layered setting')
						 	'''

						 	#split
							ArrayedLocalValueVariablesList=self.ArrayingValueVariable[0]
							ArrayedDeepValueVariable=self.ArrayingValueVariable[1:]
				 	

				#debug
				'''
				self.debug(
					[
						'ArrayedLocalValueVariablesList is '+str(
							ArrayedLocalValueVariablesList),
						'ArrayedDeepValueVariable is '+str(
							ArrayedDeepValueVariable)
					]
				)
				'''

				#/####################/#
				# Case where we have to set and then array deeper
				#

				#Check
				if len(self.ArrayingKeyVariablesList)>1:

					#debug
					'''
					self.debug(
						[
							'self.ArrayingKeyVariablesList[0] is '+str(self.ArrayingKeyVariablesList[0]),
							'ArrayedLocalValueVariablesList is '+str(ArrayedLocalValueVariablesList),
							'first we set this layer'
						]
					)
					'''

					#map
					ArrayedGetValueVariablesList=map(
							lambda __ArrayingKeyVariable,__ArrayingLocalValueVariable:
							self.set(
									__ArrayingKeyVariable,
									__ArrayingLocalValueVariable
									if __ArrayingLocalValueVariable!=None
									else {}
								)[__ArrayingKeyVariable],
							self.ArrayingKeyVariablesList[0],
							ArrayedLocalValueVariablesList
						)

					#debug
					'''
					self.debug(
						[
							'Now we array further',
							'ArrayedDeepValueVariable'+str(ArrayedDeepValueVariable)
						]
					)
					'''
					
					#map the next array
					map(
							lambda __ArrayedGetValueVariable:
							__ArrayedGetValueVariable.array(
									self.ArrayingKeyVariablesList[1:],
									ArrayedDeepValueVariable
									if type(ArrayedDeepValueVariable)!=list or len(ArrayedDeepValueVariable)>0
									else None,
									False
								),
							ArrayedGetValueVariablesList
						)
					

				#/####################/#
				# Case where we have just to set
				#

				else:

					#debug
					'''
					self.debug(
							[
								'ArrayedLocalValueVariablesList is',
								str(ArrayedLocalValueVariablesList),
								('self.',self,['ArrayingKeyVariablesList'])
							]
						)
					'''
					
					#map
					map(
							lambda __ArrayingKeyVariable,__ArrayingLocalValueVariable:
							self.set(
									__ArrayingKeyVariable,
									__ArrayingLocalValueVariable
									if __ArrayingLocalValueVariable!=None
									else {}
								),
							self.ArrayingKeyVariablesList[0],
							ArrayedLocalValueVariablesList
						)

			#/####################/#
			# It is just one layer
			#

			else:

				#/####################/#
				# Adapt the shape of the ValueVariable
				#

				#list default
				ArrayedLocalValueVariablesList=[]

				#Check
				if self.ArrayingValueVariable==None:

					
					#just a map get
					self['#map@get'](*self.ArrayingKeyVariablesList)
				
				#Check
				elif type(self.ArrayingValueVariable)==list:

					#debug
					self.debug('This is an identical non layered setting')

					#map set
					self['#map@set'](
							zip(
								self.ArrayingKeyVariablesList,
								self.ArrayingValueVariable
							)
						)

				else:
	
					#map set
					self['#map@set'](
							zip(
								self.ArrayingKeyVariablesList,
								[self.ArrayingValueVariable]*len(self.ArrayingKeyVariablesList)
							)
						)

					#debug
					'''
예제 #5
0
	def do_manage(self):

		#debug
		'''
		self.debug(
			('self.',self,[
					'ManagingKeyStr',
					'ManagingValueRigidVariable',
					'ManagingWrapBool'
				])
		)
		'''
		
		#/###################/#
		# Force the repr with the ManagementDict
		#

		#Check
		if self.ManagedOnceBool==False:

			#extend
			self.PrintingInstanceForceKeyStrsList.extend(
				[
					'ManagementDict',
					#'TeamTagStr'
				]
			)

			#set
			self.ManagedOnceBool=True

		#reset
		self.TeamingValueClass=self.__class__.TeamingValueClass

		#/###################/#
		# Is it a new managed value
		#

		#in
		self.ManagedInBool=self.ManagingKeyStr in self.ManagementDict

		#debug
		'''
		self.debug(
				[
					'Is it a new managed value ?',
					('self.',self,[
						'ManagingKeyStr',
						'ManagedInBool'
					])
				]
			)
		'''
		
		#Check
		if self.ManagedInBool==False:

			#debug
			'''
			self.debug(
				[
					'This is a new managed value',
					('self.',self,['ManagingKeyStr'])
				]
			)
			'''

			#/####################/#
			# Check if there is a special type for this
			# 

			#debug
			'''
			self.debug(
					[
						'Is there a special type for this',
						('self.',self,['ManagingClassesDict','ManagingKeyStr'])
					]
				)
			'''

			#Check
			if self.ManagingKeyStr in self.ManagingClassesDict:

				#get
				self.ManagingValueClass=self.ManagingClassesDict[
					self.ManagingKeyStr
				]

				#debug
				'''
				self.debug(
						[
							'There is a special type for this',
							('self.',self,['ManagingValueClass'])
						]
					)
				'''

			#/####################/#
			# do we have to init 
			#

			#debug
			'''
			self.debug(
				[
					'This is a new managed value',
					('self.',self,[
							'ManagingKeyStr',
							'ManagingValueRigidVariable'
						]
					),
					'Check first if this managingkey str is known'
				]
			)
			'''
			
			#Check
			if self.ManagingValueRigidVariable==None:

				#init
				self.ManagedValueVariable=self.ManagingValueClass()

			else:

				#alias
				self.ManagedValueVariable=self.ManagingValueRigidVariable

			#/####################/#
			# Case where it is a dict or tuples list like
			# we wrap then in a teamer new object and ManagingWrapBool

			#temp
			ManagedTempValueVariable=None

			#Check
			if self.ManagingWrapBool and (
				hasattr(
					self.ManagedValueVariable,
					'items'
				) or SYS.getIsTuplesListBool(self.ManagedValueVariable)
			):

				#debug
				'''
				self.debug(
						[
							'This is a manage with a value dict',
							'We wrap into an instance',
							('self.',self,[
								'ManagingKeyStr',
								'ManagingValueClass',
								'ManagingClassesDict'
								])
						]
					)
				'''

				#Check
				if self.ManagingKeyStr in self.ManagingClassesDict:

					#get
					self.ManagingValueClass=self.ManagingClassesDict[
						self.ManagingKeyStr
					]

					#debug
					'''
					self.debug(
							[
								'There is a special type for this',
								('self.',self,['ManagingValueClass'])
							]
						)
					'''
				
				#temp and init
				ManagedTempValueVariable=self.ManagedValueVariable
				self.ManagedValueVariable=self.ManagingValueClass()
				
				#debug
				'''
				self.debug(
						[
							'Ok the wrapped dict has been setted',
							('self.',self,['ManagedValueVariable']),
							'ManagedTempValueVariable is ',
							SYS._str(ManagedTempValueVariable)
						]
					)
				'''

			#/####################/#
			# Set different way to access it in the object
			# 

			#Check
			if self.ManagingIndexInt>-1:

				#debug
				'''
				self.debug(
					[
						'We manage by inserting',
						('self.',self,[
								'ManagingIndexInt'
							])
					]
				)
				'''

				#insert
				self.ManagementDict.insert(
					self.ManagingIndexInt,
					self.ManagedValueVariable,
					self.ManagingKeyStr,
					"Management"
				)

			else:

				#debug
				'''
				self.debug(
					[
						'We manage by just setting'
					]
				)
				'''

				#put in the dict
				self.ManagementDict[
					self.ManagingKeyStr
				]=self.ManagedValueVariable


			#put in the dict
			self.ManagementDict[
				self.ManagingKeyStr
			]=self.ManagedValueVariable

			#Check
			if self.ManagingWrapBool:

				#debug
				'''
				self.debug(
					[
						'We set also in the __dict__...'
					]
				)
				'''

				#define the keystr to define in the dict
				ManagedKeyStr=self.ManagingKeyStr+type(
							self.ManagedValueVariable
						).NameStr

				#set in the __dict__
				self.__setattr__(
						ManagedKeyStr,
						self.ManagedValueVariable
					)

				#add in the RepresentingSkipKeyStrsList to not be seen in the repr
				self.PrintingInstanceSkipKeyStrsList.append(ManagedKeyStr)

				#/########################/#
				# give some manage attributes
				#

				#set
				self.ManagedValueVariable.ManagementTagStr=self.ManagingKeyStr

				#index
				if self.ManagingIndexInt>-1:
					self.ManagedValueVariable.ManagementIndexInt=self.ManagingIndexInt
				else:
					self.ManagedValueVariable.ManagementIndexInt=len(self.ManagementDict)-1

				#/##########################/
				# If there are shared before set values
				#

				#debug
				'''
				self.debug(
					[
						'The Manager has something before for the managed value ?',
						('self.',self,['ManagingBeforeSetVariable'])
					]
				)
				'''

				#Check
				if self.ManagingBeforeSetVariable!=None:

					#debug
					'''
					self.debug(
							[
								'The Manager has something before for the managed value',
								('self.',self,['ManagingBeforeSetVariable'])
							]
						)
					'''
					
					#map set
					self.ManagedValueVariable['#map@set'](
						self.ManagingBeforeSetVariable	
					)


				#/##########################/
				# If the value itself was a set variable
				#

				#debug
				'''
				self.debug(
						[
							'There was a ManagedTempValueVariable here',
							'ManagedTempValueVariable!=None is',
							str(ManagedTempValueVariable!=None)
						]
					)
				'''

				#Check
				if ManagedTempValueVariable!=None:

					#debug
					'''
					self.debug(
							[
								'We manage with a ManagedValueVariable',
								'ManagedTempValueVariable is ',
								SYS._str(ManagedTempValueVariable)
							]
						)
					'''

					#set with the value
					self.ManagedValueVariable['#map@set'](
							ManagedTempValueVariable
						)

				#/##########################/
				# If there are shared after set values
				#
				

				#Check
				if self.ManagingAfterSetVariable!=None:

					#debug
					'''
					self.debug(
							[
								'The Manager has something after for the managed value',
								('self.',self,['ManagingAfterSetVariable'])
							]
						)
					'''

					#map set
					self.ManagedValueVariable['#map@set'](
						self.ManagingAfterSetVariable	
					)

		else:

			#/########################/#
			# just get and update 
			#

			#debug
			'''
			self.debug(
					[
						'Ok we just get'
					]
				)
			'''

			#get
			self.ManagedValueVariable=self.ManagementDict[
				self.ManagingKeyStr
			]
			
			#debug
			'''
			self.debug(
					[
						'We maybe update',
						('self.',self,['ManagingValueRigidVariable'])
					]
				)
			'''

			#Check
			if hasattr(
				self.ManagingValueRigidVariable,
				'items'
			) or SYS.getIsTuplesListBool(self.ManagingValueRigidVariable):

				#Check
				if self.ManagingWrapBool:

					#set
					self.ManagedValueVariable['#map@set'](
							self.ManagingValueRigidVariable
						)

		#/###################/#
		# reset rigid variable
		#

		#debug
		'''
		self.debug(
			[
				'We reset the ManagingValueRigidVariable',
				('self.',self,['ManagingValueRigidVariable'])
			]
		)
		'''
		
		#set
		self.ManagingValueRigidVariable=None
예제 #6
0
	def do_instance(self):
		""" """
		
		#Check
		if self.InstancingIsBool:

			#Init
			InstancingClass=None

			#TuplesList Case
			if SYS.getIsTuplesListBool(self.InstancingVariable):

				#debug
				'''
				self.debug('This is a tuples list')
				'''

				if self.InstancingClass==None:

					#debug
					'''
					self.debug('Find the instancing class')
					'''

					#Definition the KeyStrsList
					KeyStrsList=SYS.unzip(self.InstancingVariable,[0])

					try:
						InstancingClass=self.InstancingVariable[KeyStrsList.index('InstancingClass')][1]
					except:
						pass

				else:
					InstancingClass=self.InstancingClass

				#Check
				if InstancingClass!=None:

					#Init
					self.InstancedVariable=InstancingClass()

					#Map
					map(
							lambda __ItemTuple:
							self.InstancedVariable.__setattr__(*__ItemTuple),
							self.InstancingVariable
						)

					#debug
					'''
					self.debug(('vars ',vars(),['InstancedVariable']))
					'''

			elif hasattr(self.InstancingVariable,'items'):

				#debug
				'''
				self.debug('This is an itemizing thing')
				'''

				if self.InstancingClass==None:

					#debug
					'''
					self.debug('Find the instancing class')
					'''

					try:
						InstancingClass=self.InstancingVariable['InstancingClass']
					except:
						pass
				else:

					#Definition
					InstancingClass=self.InstancingClass

				if InstancingClass!=None:

					#Init
					self.InstancedVariable=InstancingClass()

					#Map
					map(
							lambda __ItemTuple:
							self.InstancedVariable.__setattr__(*__ItemTuple),
							self.InstancingVariable.items()
						)
		
			elif hasattr(self.InstancingVariable,'__dict__'):

				#Check
				if self.InstancingClass!=None:

					#Init
					self.InstancedVariable=self.InstancingClass()