Exemplo n.º 1
0
	def do_test(self):
		
		#Init in the classed Module
		if hasattr(self.Module,'TestingPrintIsBool')==False:
			self.Module.TestingPrintIsBool=True
		self.Module.TestedOrderedDict=collections.OrderedDict()

		#Debug
		'''
		print('Tester l 160')
		print('self.AttestingFolderPathStr is '+self.AttestingFolderPathStr)
		print('')
		'''

		#set the tests for each asserting function
		map(
				lambda __AttestedUnboundMethod:
				setTestFunctionWithFolderPathStrAndAttestUnboundMethod(
					self.AttestingFolderPathStr,
					__AttestedUnboundMethod
				),
				self.AttestedUnboundMethodsList
			)
			
		#Definition the TestClass
		class TestClass(unittest.TestCase):				

			#Bind with the Tested object
			TestedPointer=self

			#Bound the setUp function
			#locals().__setitem__(setUp.__name__,setUp)
			
			#Bound each testing function
			for __InstanceVariableedKeyStr,__InstanceVariableedMethod in self.Module.TestedOrderedDict.items():
				locals().__setitem__(__InstanceVariableedKeyStr,__InstanceVariableedMethod)

			try:
				del TestedKeyStr,TestedMethod
			except:
				pass

		#Give a name
		TestClass.__name__=SYS.getClassStrWithNameStr(self.NameStr+'Test')

		#set to the module of the classing class
		self.Module.TestedClass=TestClass

		#Definition
		def test():

			#Call to the unittest runner
			TestLoader=unittest.TestLoader().loadTestsFromTestCase(
				self.Module.TestedClass
			)
			unittest.TextTestRunner(verbosity=2).run(TestLoader)

		#Link to the module of the classing class
		self.Module.test=test
	def do_model(self):
		""" """

		#Debug
		self.debug('model start')
		
		#/###################/#
		# Define the ModeledKeyStr 
		#

		if self.ModeledDescriptionKeyStr=='':
			self.ModeledDescriptionKeyStr=self.ModelTagStr

		#/###################/#
		# Special case of hdf when we have to define Model Description class
		#

		#Check
		if self.ModelingHdfBool:

			#import 
			import tables

			#Definition the DescriptionClass
			class DescriptionClass(tables.IsDescription):

				#Add (just like a unique KEY in mysql...) 
				RowInt=tables.Int64Col()

			#debug
			self.debug(
				[
					'We add descriptions in the description Class',
					('self.',self,['ModelingDescriptionTuplesList'])
				]
			)
			
			#set the cols in the ModelClass
			map(
					lambda __ModelingColumnTuple:
					DescriptionClass.columns.__setitem__(
						__ModelingColumnTuple[1],
						__ModelingColumnTuple[2]
						),
					self.ModelingDescriptionTuplesList
				)

			#Give a name
			DescriptionClass.__name__=SYS.getClassStrWithNameStr(self.ModelTagStr)

			#set the ModelClass
			if self.ModeledDescriptionClassesOrderedDict==None:
				self.ModeledDescriptionClassesOrderedDict=collections.OrderedDict()
			self.ModeledDescriptionClassesOrderedDict[self.ModelTagStr]=DescriptionClass

			#set the ModeledDescriptionClass
			self.ModeledDescriptionClass=DescriptionClass
Exemplo n.º 3
0
	def test(_InstanceVariable):

		#Debug
		'''
		print('Tester l 62')
		print('_FolderPathStr is '+_FolderPathStr)
		print('AttestUnboundMethodStr is '+AttestUnboundMethodStr)
		print('')
		'''
		
		#Get the AssertedStr
		File=open(_FolderPathStr+AttestUnboundMethodStr+'.txt','r')
		AttestStr=File.read()
		File.close()

		#Call the attest function to get the TestVariable
		TestVariable=_AttestUnboundMethod(
						getattr(
							SYS,
							SYS.getClassStrWithNameStr(
								TestModule.__name__.split('.')[-1]
								if '.' in TestModule.__name__ else TestModule
							)
						)()
					)

		#Bind with TestStr setting
		Printer.RepresentingIdBool=False
		TestStr=Printer.getPrintStr(TestVariable)
		Printer.RepresentingIdBool=True

		#Represent maybe
		if TestModule.TestingPrintIsBool:

			#debug
			print("\n###########################################")
			print("")
			print('AttestStr is :')
			print(AttestStr)
			print("")

			#debug
			print('TestStr is :')
			print(TestStr)
			print("")

		#Assert
		#print("a",AssertingStr)
		#print("b",_InstanceVariable.TestedPointer.TestStr)

		#assert
		_InstanceVariable.assertEqual(
				#1,1
				AttestStr,
				TestStr
		)
Exemplo n.º 4
0
def getClass(_InstanceVariable,_ClassVariable=None):

	#Debug
	'''
	print('Classor l 35')
	print('_ClassVariable is ')
	print(_ClassVariable)
	print('')
	'''
	
	#Check
	if type(_ClassVariable) in SYS.StrTypesList:
		if _ClassVariable=="":
			return _InstanceVariable.__class__
		else:
			return getattr(SYS,SYS.getClassStrWithNameStr(_ClassVariable))
	elif _ClassVariable==None:
		return _InstanceVariable.__class__
	else:
		return _ClassVariable
    def do_model(self):
        """ """

        # Debug
        """
		self.debug(
				[
					'model start',
					('self.',self,[
						'ModelMongoBool',
						'ModelHdfBool'
					])
				]
			)
		"""

        # /###################/#
        # Mongo Case
        #

        # Check
        if self.ModelMongoBool:

            # debug
            """
			self.debug(
					'We model mongo here'
				)
			"""

            # set
            self.ModeledMongoSuffixStr = self.ModelTagStr + "Collection"

            # debug
            """
			self.debug(
				[
					('self.',self,[
							'PymongoneClientVariable',
							'ModeledMongoSuffixStr'
						]
					)
				]
			)
			"""

            # Check
            if self.ModelDeriveControllerVariable.PymongoneClientVariable == None:

                # debug
                """
				self.debug('We have to pymongo first...')
				"""

                # pymongo
                self.ModelDeriveControllerVariable.pymongo()

                # Link
            self.ModeledMongoTopClientVariable = self.ModelDeriveControllerVariable.PymongoneClientVariable

            # Check
            if self.ModeledMongoTopClientVariable != None:

                # debug
                """
				self.debug(
							[	
								'Looking for names of collections here',
								('self.',self,[
									'ModeledMongoTopClientVariable'
									]),
							]
						)
				"""

                # /#################/#
                # Check for the name
                #

                # Check
                if self.ModelDeriveControllerVariable.PymongoingDatabaseStr == "":

                    # set
                    self.ModeledMongoDatabaseKeyStr = self.ModelDeriveControllerVariable.ControlTagStr

                    # set
                    self.ModelDeriveControllerVariable.PymongoingDatabaseStr = self.ModeledMongoDatabaseKeyStr

                else:

                    # set
                    self.ModeledMongoDatabaseKeyStr = self.ModelDeriveControllerVariable.PymongoingDatabaseStr

                    # set
                self.ModeledMongoLocalDatabaseVariable = self.ModeledMongoTopClientVariable[
                    self.ModeledMongoDatabaseKeyStr
                ]

                # debug
                """
				self.debug(
						[
							('self.',self,[
								'ModeledMongoDatabaseKeyStr',
								'ModeledMongoLocalDatabaseVariable'
								]),
							"id(self.ModeledMongoLocalDatabaseVariable) is "+str(
								id(self.ModeledMongoLocalDatabaseVariable))
						]
					)
				"""

                # set
                self.ModeledMongoLocalDatabaseVariable.__dict__[
                    "ParentDerivePymongoer"
                ] = self.ModelDeriveControllerVariable

                # alias
                self.ModelDeriveControllerVariable.Database = self.ModeledMongoLocalDatabaseVariable

                # debug
                """
				self.debug(
							[	
								('self.',self,[
									'ModeledMongoLocalDatabaseVariable'
									]),
								"'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__",
								'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__
							]
						)
				"""

                # Get and sort
                self.ModeledMongoKeyStrsList = map(
                    str,
                    sorted(
                        filter(
                            lambda __KeyStr: __KeyStr.endswith(self.ModeledMongoSuffixStr),
                            self.ModeledMongoLocalDatabaseVariable.collection_names(),
                        )
                    ),
                )

                # debug
                """
				self.debug(
					[	
						('self.',self,[
							'ModeledMongoKeyStrsList'
							])
					]
				)
				"""

                # update
                self.ModeledMongoCollectionsOrderedDict.update(
                    map(
                        lambda __ModeledKeyStr: (
                            __ModeledKeyStr,
                            self.ModeledMongoLocalDatabaseVariable[__ModeledKeyStr],
                        ),
                        self.ModeledMongoKeyStrsList,
                    )
                )

                # debug
                """
				self.debug(("self.",self,[
											'ModeledMongoSuffixStr',
											'ModeledMongoKeyStrsList'
											]))
				"""

                # debug
            """
			self.debug(
						[
							'ModeledMongoKeyStrsList',
							'ModeledMongoSuffixStr',
							'ModeledMongoKeyStr'
						]
					)
			"""

            # Get the suffix Strs of all the tables and their index
            ModeledMongoList = SYS.unzip(
                map(
                    lambda __StrsList: (__StrsList[1], ModelOrderStr.join(__StrsList[2:])),
                    map(
                        lambda __ModeledMongoKeyStr: __ModeledMongoKeyStr.split(ModelOrderStr),
                        self.ModeledMongoKeyStrsList,
                    ),
                ),
                [0, 1],
            )

            # debug
            """
			self.debug(('vars ',vars(),['ModeledHdfList']))
			"""

            # Unpack if it is possible
            if len(ModeledMongoList) > 0:

                # Unpack
                [ModeledMongoIndexIntsTuple, ModeledMongoSuffixStrsList] = ModeledMongoList

                # debug
                """
				self.debug(
							[
								'There are already some tables',
								'ModeledMongoSuffixStrsList is '+str(ModeledMongoSuffixStrsList),
								"self.ModeledMongoSuffixStr is "+str(
									self.ModeledMongoSuffixStr)
							]
						)
				"""

                if self.ModeledMongoSuffixStr not in ModeledMongoSuffixStrsList:

                    # Increment the IndexStr
                    ModeledMongoIndexInt = max(map(int, ModeledMongoIndexIntsTuple)) + 1

                    # Strify
                    ModeledMongoIndexStr = str(ModeledMongoIndexInt)

                    # debug
                    """
					self.debug('IndexStr of this new table is '+str(IndexStr))
					"""

                else:

                    # Get the already setted one
                    ModeledMongoIndexStr = self.ModeledMongoKeyStrsList[
                        ModeledMongoSuffixStrsList.index(self.ModeledMongoSuffixStr)
                    ].split(ModelOrderStr)[1]

                    # Intify
                    ModeledMongoIndexInt = (int)(ModeledMongoIndexStr)

                    # debug
                    """
					self.debug('IndexStr of this not new table is '+str(IndexStr))
					"""

            else:

                # debug
                """
				self.debug('There are no tables here')
				"""

                # set to empty lists
                [ModeledMongoIndexIntsTuple, ModeledMongoSuffixStrsList] = [[], []]

                # Init the list
                ModeledMongoIndexInt = 0

                # Strify
                ModeledMongoIndexStr = "0"

                # Bind with ModeledHdfKeyStr setting
            self.ModeledMongoKeyStr = ModelOrderStr + ModeledMongoIndexStr + ModelOrderStr + self.ModeledMongoSuffixStr

            # set the ModeledInt
            self.ModeledMongoIndexInt = ModeledMongoIndexInt

            # debug
            """
			self.debug("self.ModeledMongoKeyStr is "+str(self.ModeledMongoKeyStr))
			"""

            # debug
            """
			self.debug(
						[
							'Here we create the collection or get it depending if it is new or not',
							'self.ModeledMongoKeyStr is '+self.ModeledMongoKeyStr,
							'self.ModeledTopFileVariable!=None is '+str(self.ModeledTopFileVariable!=None)
						]
					)
			"""

            # Check
            if self.ModeledMongoKeyStr != "" and self.ModeledMongoLocalDatabaseVariable != None:

                # debug
                """
				self.debug(
							[
								('self.',self,[
									'ModeledMongoKeyStr',
									'ModeledMongoKeyStrsList'
									]
								),
								'self.ModeledMongoLocalDatabaseVariable.collection_names() is ',
								str(self.ModeledMongoLocalDatabaseVariable.collection_names())
							]
						)
				"""

                # Create the collection if not already
                if self.ModeledMongoKeyStr not in self.ModeledMongoKeyStrsList:

                    # debug
                    """
					self.debug(
								[
									'The collection not exists',
								]
							)
					"""

                    # Create the collections
                    self.ModeledMongoCollection = self.ModeledMongoLocalDatabaseVariable.create_collection(
                        self.ModeledMongoKeyStr
                    )

                    # Append
                    self.ModeledMongoKeyStrsList.append(self.ModeledMongoKeyStr)

                else:

                    # debug
                    """
					self.debug(
						[
							'The collection exists',
						]
					)
					"""

                    # Else just get it
                    self.ModeledMongoCollection = self.ModeledMongoLocalDatabaseVariable[self.ModeledMongoKeyStr]

                    # set the in the ModeledMongoCollectionsOrderedDict
                self.ModeledMongoCollectionsOrderedDict[self.ModeledMongoKeyStr] = self.ModeledMongoCollection

                # debug
                """
				self.debug("self.ModeledMongoCollectionsOrderedDict is "+str(self.ModeledMongoCollectionsOrderedDict))
				"""

                # debug
            """
			self.debug(
						[
							'Table is done here for mongo...',
							('self.',self,[
								'ModeledMongoCollection',
								'ModeledMongoTopDatabaseVariable'
								]
							)
						]
					)
			"""

            # /###################/#
            # Hdf Case
            #

            # Check
        if self.ModelHdfBool:

            # /################/#
            # Model is to modify modeling description so keep an old version of this before
            #

            # debug
            """
			self.debug(
					[
						'Keep maybe a copy of ModelingDescriptionTuplesList',
						('self.',self,[
							'ModelingDescriptionTuplesList',
							'ModelDescriptionTuplesList'
						])
					]
				)
			"""

            # keep a memory
            if self.ModelDescriptionTuplesList == None:

                # copy
                self.ModelDescriptionTuplesList = copy.deepcopy(self.ModelingDescriptionTuplesList)

                # /################/#
                # Pick the shape ints and their get key strs
                #

                # debug
            """
			self.debug(
						[
							'We model shape here',
							("self.",self,['ModelDimensionTuplesList'])
						]
					)
			"""

            # Check
            if self.ModelDimensionTuplesList != None and len(self.ModelDimensionTuplesList) > 0:

                # set
                [self.ModeledDescriptionGetKeyStrsList, ModeledDescriptionDimensionGetTuplesList] = SYS.unzip(
                    self.ModelDimensionTuplesList, [0, 1]
                )

                # list
                self.ModeledDescriptionGetKeyStrsList = list(self.ModeledDescriptionGetKeyStrsList)

                # debug
                """
				self.debug(
					[
						'ModeledDescriptionDimensionGetTuplesList is ',
						str(ModeledDescriptionDimensionGetTuplesList)
					]
				)
				"""

                # unzip
                self.ModeledDescriptionDimensionGetKeyStrsListsList = SYS.unzip(
                    list(ModeledDescriptionDimensionGetTuplesList), [1]
                )

                # debug
                """
				self.debug(
					[
						('self.',self,['ModeledDescriptionDimensionGetKeyStrsListsList'])
					]
				)
				"""

                # /###################/#
                # Check the dimension that are not defined or equal to zero
                # set them to one

                # map map
                self.ModeledDescriptionDimensionIntsListsList = map(
                    lambda __ModeledDescriptionDimensionGetKeyStrsList: map(
                        lambda __ModeledDescriptionDimensionGetKeyStr, __ShapeInt: self.ModelDeriveControllerVariable.set(
                            __ModeledDescriptionDimensionGetKeyStr, __ShapeInt + 1
                        )[
                            __ModeledDescriptionDimensionGetKeyStr
                        ]
                        if __ShapeInt == 0
                        else __ShapeInt,
                        __ModeledDescriptionDimensionGetKeyStrsList,
                        map(
                            lambda __ModeledDescriptionDimensionGetKeyStr: self.ModelDeriveControllerVariable[
                                __ModeledDescriptionDimensionGetKeyStr
                            ],
                            __ModeledDescriptionDimensionGetKeyStrsList,
                        ),
                    ),
                    self.ModeledDescriptionDimensionGetKeyStrsListsList,
                )

                # get the corresponding real dimensions
                """
				self.ModeledDescriptionDimensionIntsListsList=map(
						lambda __ModeledDescriptionDimensionGetKeyStrsList:
						self.ModelDeriveControllerVariable[
							Getter.GetMapStr
						](
							*__ModeledDescriptionDimensionGetKeyStrsList
						).ItemizedMapValueVariablesList,
						self.ModeledDescriptionDimensionGetKeyStrsListsList
					)
				"""

                # debug
                """
				self.debug(
					[
						('self.',self,[
							'ModeledDescriptionDimensionIntsListsList'
						])
					]
				)
				"""

            else:

                # Default
                self.ModeledDescriptionGetKeyStrsList = []
                self.ModeledDimensionGetKeyStrsList = []
                self.ModeledDescriptionDimensionGetKeyStrsListsList = []

                # debug
            """
			self.debug(
				[
					("self.",self,[
										'ModeledDescriptionGetKeyStrsList',
										'ModeledDescriptionDimensionGetKeyStrsListsList',
										'ModeledDescriptionDimensionIntsListsList'
									])
				]
			)
			"""

            # /################/#
            # Find where in the description takes list it has to be modified
            #

            # Definition
            ModeledGetKeyStrsList = SYS.unzip(self.ModelingDescriptionTuplesList, [0])

            # set
            self.ModeledShapeIndexIntsList = map(
                lambda __ModeledDescriptionGetKeyStr: ModeledGetKeyStrsList.index(__ModeledDescriptionGetKeyStr),
                self.ModeledDescriptionGetKeyStrsList,
            )

            # debug
            """
			self.debug(
					[
						'We know the index of the shape description tuples',
						('self.',self,['ModeledShapeIndexIntsList'])
					]
				)
			"""

            # /################/#
            # set flat all the get key str for the shaping int
            #

            # Check
            if self.ModelDeriveControllerVariable != None:

                # debug
                """
				self.debug(
						[	
							'We flat the DimensionGetKeyStrsLists',
							('self.',self,[
								'ModeledDescriptionDimensionGetKeyStrsListsList'
								])
						]
					)
				"""

                # Flat and set
                self.ModeledDimensionGetKeyStrsList = list(
                    set(SYS.flat(self.ModeledDescriptionDimensionGetKeyStrsListsList))
                )

                # debug
                """
				self.debug(
						[
							('self.',self,[
								'ModeledDimensionGetKeyStrsList'
								])
						]
					)
				"""

                # Pick
                self.ModeledDimensionIntsList = self.ModelDeriveControllerVariable[Getter.GetMapStr](
                    *self.ModeledDimensionGetKeyStrsList
                ).ItemizedMapValueVariablesList

            else:

                # Default
                self.ModeledDimensionIntsList = []

                # /################/#
                # map a join str with this
                #

                # debug
            """
			self.debug(
				[
					'No we set the ModeledShapeStr',
					("self.",self,[
						'ModeledDimensionGetKeyStrsList',
						'ModeledDimensionIntsList'
					])
				]
			)
			"""

            # Bind with ModeledShapeStr setting
            self.ModeledShapeStr = ModelJoinStr.join(
                map(
                    lambda __ModeledDescriptionGetKeyStr, __ModeledDimensionVariable: ModelJoinStr
                    + str(__ModeledDescriptionGetKeyStr)
                    + ModelDimensionStr
                    + str(__ModeledDimensionVariable),
                    self.ModeledDimensionGetKeyStrsList,
                    self.ModeledDimensionIntsList,
                )
            )

            # debug
            """
			self.debug(
				[
					('self.',self,['ModeledShapeStr'])
				]
			)
			"""

            # /#################/#
            # Adapt the name of the description model given the shape
            #

            # debug
            """
			self.debug(
					[
						'Ok we have shaped',
						('self.',self,['ModeledShapeStr'])
					]
				)
			"""

            # Get the new ModeledKeyStr
            if self.ModeledShapeStr != "":

                # debug
                """
				self.debug(
							[
								'We set the new ModeledHdfSuffixStr',
								('self.',self,['ModeledShapeStr','ModelTagStr'])
							]
						)
				"""

                # set
                self.ModeledHdfSuffixStr = self.ModeledShapeStr + ModelJoinStr + self.ModelTagStr

            else:

                # set
                self.ModeledHdfSuffixStr = self.ModelTagStr

                # debug
            """
			self.debug(
						[
							'We have set the new ModeledHdfSuffixStr',
							('self.',self,[
								'ModeledShapeStr',
								'ModeledHdfSuffixStr'
							])
						]
					)	
			"""

            # /#################/#
            # Set the good format for the Description tuples list
            #

            # Unnzip
            ModeledGetKeyStrsList = SYS.unzip(self.ModelingDescriptionTuplesList, [0])

            # debug
            """
			self.debug(
						[
							('Now change the shape of the shaping cols'),
							('self.',self,[
								'ModelingDescriptionTuplesList',
								'ModeledShapeIndexIntsList'
								])
						]
					)	
			"""

            # map
            ModeledShapeDescriptionTuplesList = map(
                self.ModelingDescriptionTuplesList.__getitem__, self.ModeledShapeIndexIntsList
            )

            # debug
            """
			self.debug(
					[
						'ModeledShapeDescriptionTuplesList is '+str(
							ModeledShapeDescriptionTuplesList
						),
						('self.',self,['ModeledDescriptionDimensionIntsListsList'])
					]
				)
			"""

            # map
            ModeledShapeDescriptionTuplesList = map(
                lambda __ModeledShapeDescriptionTuple, __ModeledDescriptionDimensionIntsList: (
                    __ModeledShapeDescriptionTuple[0],
                    __ModeledShapeDescriptionTuple[1],
                    __ModeledShapeDescriptionTuple[2][0](shape=__ModeledDescriptionDimensionIntsList),
                ),
                ModeledShapeDescriptionTuplesList,
                self.ModeledDescriptionDimensionIntsListsList,
            )

            # debug
            """
			self.debug(
					[
						'ModeledShapeDescriptionTuplesList is '+str(
							ModeledShapeDescriptionTuplesList)
					]
				)
			"""

            # set the shaping cols
            map(
                lambda __ModeledIndexInt, __ModeledModelingDescriptionTuple: self.ModelingDescriptionTuplesList.__setitem__(
                    __ModeledIndexInt, __ModeledModelingDescriptionTuple
                ),
                self.ModeledShapeIndexIntsList,
                ModeledShapeDescriptionTuplesList,
            )

            # debug
            """
			self.debug(
				[
					"After the shape we check for the modeling description",
					('self.',self,[
							'ModelingDescriptionTuplesList',
							'ModelKeyStrsList'
						]
					)
				]
			)
			"""

            # /###################/#
            # Check maybe the Description was not yet done although there are ModelKeystrs
            #

            if len(self._ModelKeyStrsList) > len(self.ModelingDescriptionTuplesList):

                # bind
                self.propertize_setModelKeyStrsList(self._ModelKeyStrsList)

                # debug
            """
			self.debug(
				[
					"After the bind",
					('self.',self,[
							'ModelingDescriptionTuplesList',
							'ModelKeyStrsList'
						]
					)
				]
			)
			"""

            # /###################/#
            # Define the Description
            #

            # import
            import tables

            # Definition the DescriptionClass
            class DescriptionClass(tables.IsDescription):

                # Add (just like a unique KEY in mysql...)
                RowInt = tables.Int64Col()

                # debug

            """
			self.debug(
				[
					'We add descriptions in the description Class',
					('self.',self,['ModelingDescriptionTuplesList'])
				]
			)
			"""

            # set the cols in the ModelClass
            map(
                lambda __ModelingColumnTuple: DescriptionClass.columns.__setitem__(
                    __ModelingColumnTuple[1], __ModelingColumnTuple[2]
                ),
                self.ModelingDescriptionTuplesList,
            )

            # Give a name
            DescriptionClass.__name__ = SYS.getClassStrWithNameStr(self.ModelTagStr)

            # set the ModelClass
            if self.ModeledDescriptionClassesOrderedDict == None:
                self.ModeledDescriptionClassesOrderedDict = collections.OrderedDict()
            self.ModeledDescriptionClassesOrderedDict[self.ModelTagStr] = DescriptionClass

            # set the ModeledDescriptionClass
            self.ModeledDescriptionClass = DescriptionClass

            # /###################/#
            # Begin to set the hdf file
            # first look if we have to hdformat
            #

            # debug
            """
			self.debug(
				[
					'We tabular for hdf here...',
					'self.ModelDeriveControllerVariable.HdformatedFileVariable is ',
					str(self.ModelDeriveControllerVariable.HdformatedFileVariable)
				]
			)
			"""

            # set
            if self.ModeledHdfSuffixStr == "":
                self.ModeledHdfSuffixStr = self.ModelTagStr + "Table"

                # Check
            if self.ModelDeriveControllerVariable.HdformatedFileVariable == None:

                # /##################/#
                # If it is the top controller we have to hdformat
                #

                # debug
                """
				self.debug(
						[
							'Look if the controller is the top one',	
							'self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable==self.ModelDeriveControllerVariable',
							str(self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable==self.ModelDeriveControllerVariable)					
						]
					)
				"""

                # Check
                if (
                    self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable
                    == self.ModelDeriveControllerVariable
                ):

                    # /##################/#
                    # Set a default name
                    #

                    # Check
                    if self.ModelDeriveControllerVariable.HdformatingFileKeyStr == "":

                        # set
                        self.ModelDeriveControllerVariable.HdformatingFileKeyStr = (
                            self.ModelDeriveControllerVariable.ControlTagStr + ".hdf5"
                        )

                        # /##################/#
                        # hdformat
                        #

                        # debug
                    """
					self.debug(
						[
							'We have to make hdformat the controller first...',
							('self.ModelDeriveControllerVariable.',
								self.ModelDeriveControllerVariable,
							[
								'ControlTagStr'
							])
						]
					)
					"""

                    # Hdformat
                    self.ModelDeriveControllerVariable.hdformat()

                    # debug
                    """
					self.debug(
						[
							'Ok the top controller has hdformated',
							('self.ModelDeriveControllerVariable.',
								self.ModelDeriveControllerVariable,
							[
								'HdformatedFileVariable',
								'ControlTagStr'
							])
						]
					)
					"""

                else:

                    # /##################/#
                    # If it is not the top we have just
                    # to alias with the one of the top
                    #

                    # alias
                    self.ModelDeriveControllerVariable.HdformatedFileVariable = (
                        self.ParentTopDeriveTeamerVariable.HdformatedFileVariable
                    )

                    # /##################/#
                    # Set the group path str to trigger
                    # a set in the hdf

                    # debug
            """
			self.debug(
					[
						'We set in the hdf the group branch'
					]
				)
			"""

            # Set
            self.ModelDeriveControllerVariable.HdfGroupPathStr = self.ModelDeriveControllerVariable.ControlTagStr

            # debug
            """
			self.debug(
					[
						'Ok the group is setted'
					]
				)
			"""

            # Link
            self.ModeledHdfTopFileVariable = self.ModelDeriveControllerVariable.HdformatedFileVariable

            # debug
            """
			self.debug(
				[
					'Ok the hdf file is setted',
					('self.',self,[
									'ModeledHdfTopFileVariable'
								])
				]
			)
			"""

            # /#################/#
            # Check for all the tables already defined here
            #

            # Check
            if self.ModeledHdfTopFileVariable != None:

                # debug
                """
				self.debug(
					[	
						'Looking for names of tables here',
						(
							'self.ModelDeriveControllerVariable.',
							self.ModelDeriveControllerVariable,
							['HdfGroupPathStr']
						)
					]
				)
				"""

                # Definition Modeled attributes
                self.ModeledHdfGroupVariable = self.ModeledHdfTopFileVariable.getNode(
                    self.ModelDeriveControllerVariable.HdfGroupPathStr
                )

                # debug
                """
				self.debug(
							[
								('looking for tables with the same Model Tag Str as : '),
								('self.',self,['ModelTagStr'])
							]
						)
				"""

                # Get and sort
                self.ModeledHdfKeyStrsList = sorted(
                    filter(
                        lambda __KeyStr: __KeyStr.endswith(self.ModelTagStr),
                        self.ModeledHdfGroupVariable._v_leaves.keys(),
                    )
                )

                # update
                self.ModeledHdfTablesOrderedDict.update(
                    map(
                        lambda __ModeledKeyStr: (
                            __ModeledKeyStr,
                            self.ModeledHdfGroupVariable._f_getChild(__ModeledKeyStr),
                        ),
                        self.ModeledHdfKeyStrsList,
                    )
                )

                # debug
                """
				self.debug(
					[
						("self.",self,[
										'ModeledHdfTablesOrderedDict'
									])
					]
				)
				"""

                # /################/#
                # Refind all the names of the tables
                #

                # debug
            """
			self.debug(
						('self.',self,[
							'ModeledHdfKeyStrsList',
							'ModeledHdfSuffixStr',
							'ModeledHdfKeyStr'
						])
					)
			"""

            # Get the suffix Strs of all the tables and their index
            ModeledHdfList = SYS.unzip(
                map(
                    lambda __StrsList: (__StrsList[1], ModelOrderStr.join(__StrsList[2:])),
                    map(lambda __ModeledHdfKeyStr: __ModeledHdfKeyStr.split(ModelOrderStr), self.ModeledHdfKeyStrsList),
                ),
                [0, 1],
            )

            # debug
            """
			self.debug(
				[
					'All the corresponding table models are ',
					('vars()[\'',vars(),['ModeledHdfList'],"\']")
				]
			)
			"""

            # /##################/#
            # Find if there are already some tables here and deduce the index of the table
            #

            # Unpack if it is possible
            if len(ModeledHdfList) > 0:

                # Unpack
                [ModeledHdfIndexIntsTuple, ModeledHdfSuffixStrsList] = ModeledHdfList

                # debug
                """
				self.debug(
							[
								'There are already some tables',
								'ModeledHdfSuffixStrsList is '+str(ModeledHdfSuffixStrsList),
								"self.ModeledHdfSuffixStr is "+str(
									self.ModeledHdfSuffixStr)
							]
						)
				"""

                if self.ModeledHdfSuffixStr not in ModeledHdfSuffixStrsList:

                    # Increment the IndexStr
                    ModeledHdfIndexInt = max(map(int, ModeledHdfIndexIntsTuple)) + 1

                    # Strify
                    ModeledHdfIndexStr = str(ModeledHdfIndexInt)

                    # debug
                    """
					self.debug('IndexStr of this new table is '+str(IndexStr))
					"""

                else:

                    # Get the already setted one
                    ModeledHdfIndexStr = self.ModeledHdfKeyStrsList[
                        ModeledHdfSuffixStrsList.index(self.ModeledHdfSuffixStr)
                    ].split(ModelOrderStr)[1]

                    # Intify
                    ModeledHdfIndexInt = (int)(ModeledHdfIndexStr)

                    # debug
                    """
					self.debug('IndexStr of this not new table is '+str(IndexStr))
					"""

            else:

                # debug
                """
				self.debug('There are no tables here')
				"""

                # set to empty lists
                [ModeledHdfIndexIntsTuple, ModeledHdfSuffixStrsList] = [[], []]

                # Init the list
                ModeledHdfIndexInt = 0

                # Strify
                ModeledHdfIndexStr = "0"

                # /##################/#
                # set the table key str
                #

                # debug
            """
			self.debug(
					[
						'We set the table key str',
						('self.',self,[
							'ModeledHdfSuffixStr'
						]),
						'ModeledHdfIndexStr is '+str(ModeledHdfIndexStr)
					]
				)
			"""

            # Bind with ModeledHdfKeyStr setting
            self.ModeledHdfKeyStr = ModelOrderStr + ModeledHdfIndexStr + ModelOrderStr + self.ModeledHdfSuffixStr

            # set the ModeledInt
            self.ModeledHdfIndexInt = ModeledHdfIndexInt

            # debug
            """
			self.debug(
				[
					'Ok we have setted which hdf table',
					('self.',self,[
							'ModeledHdfKeyStr',
							'ModeledHdfIndexInt'
						]),
					'Now we create the table, or get it, depending if it is new or not',
					('self.',self,[
						'ModeledHdfKeyStr',
						'ModeledHdfTopFileVariable'
						])
				]
			)
			"""

            # Check
            if self.ModeledHdfKeyStr != "" and self.ModeledHdfTopFileVariable != None:

                # debug
                """
				self.debug(
							[
								('self.',self,[
									'ModeledHdfKeyStr',
									'ModeledHdfKeyStrsList'
								])
							]
						)
				"""

                # Create the Table if not already
                if self.ModeledHdfKeyStr not in self.ModeledHdfKeyStrsList:

                    # debug
                    """
					self.debug(
								[
									'The table not exists',
								]
							)
					"""

                    # Create the Table in the hdf5
                    self.ModeledHdfTable = self.ModeledHdfTopFileVariable.create_table(
                        self.ModeledHdfGroupVariable,
                        self.ModeledHdfKeyStr,
                        self.ModeledDescriptionClass,
                        self.ModeledDescriptionClass.__doc__
                        if self.ModeledDescriptionClass.__doc__ != None
                        else "This is the " + self.ModeledDescriptionClass.__name__,
                    )

                    # Append
                    self.ModeledHdfKeyStrsList.append(self.ModeledHdfKeyStr)

                else:

                    # debug
                    """
					self.debug(
									[
										'The table exists',
										"self.ModeledGroupVariable is "+str(self.ModeledGroupVariable)
									]
								)
					"""

                    # Else just get it
                    self.ModeledHdfTable = self.ModeledHdfGroupVariable._f_getChild(self.ModeledHdfKeyStr)

                    # set the in the TablesOrderedDict
                self.ModeledHdfTablesOrderedDict[self.ModeledHdfKeyStr] = self.ModeledHdfTable

                # debug
                """
				self.debug("self.ModeledHdfTablesOrderedDict is "+str(
					self.ModeledHdfTablesOrderedDict))
				"""

                # debug
            """
Exemplo n.º 6
0
	def do__class(self):

		#Definition the MethodsList
		ClassedFunctionsList=SYS._filter(
			lambda __ListedVariable:
				type(__ListedVariable).__name__=="function"
				if hasattr(__ListedVariable,'__name__')
				else False,
				self.DoClass.__dict__.values()
		)

		#debug
		'''
		print('l 66 Classer')
		print("ClassedFunctionsList is ",WatchedFunctionsList)
		print('Set all the mimick methods')
		print('')
		'''

		#/###################/#
		# Mimic all that you can find 
		#

		#Get all the hooking methods
		ClassedMimickFunctionsList=SYS._filter(
			lambda __ListedVariable:
			__ListedVariable.__name__.startswith(
					Mimicker.MimickingWrapPrefixStr
			)
			if hasattr(__ListedVariable,'__name__')
			else False,
			ClassedFunctionsList
		)

		#debug
		'''
		print('l 82 Classer')
		print("ClassedMimickFunctionsList is ",ClassedMimickFunctionsList)
		print('')
		'''

		#map
		map(	
				lambda __ClassedMimickFunction:
				self.mimic(
					Mimicker.MimickingWrapPrefixStr.join(
						__ClassedMimickFunction.__name__.split(
							Mimicker.MimickingWrapPrefixStr)[1:]
						)
				),
				ClassedMimickFunctionsList
			)

		#/###################/#
		# Set the watch methods 
		#

		#debug
		'''
		print('l 104 Classer')
		print('set the watch functions')
		print('self.ClassingWatchMethodStrsList is ',self.ClassingWatchMethodStrsList)
		print('self.DoClass.DoMethodStr is ',self.DoClass.DoMethodStr)
		print('')
		'''
		
		#map
		map(	
				lambda __ClassingWatchUnboundMethodStr:
				self.watch(
					True,
					**{'ObservingWrapMethodStr':__ClassingWatchUnboundMethodStr}
				),
				self.ClassingWatchMethodStrsList
			)

		#/###################/#
		# Set the switch methods 
		#

		#debug
		'''
		print('l 104 Classer')
		print('set the switch functions')
		print('self.ClassingSwitchMethodStrsList is ',self.ClassingSwitchMethodStrsList)
		print('self.DoClass.DoMethodStr is ',self.DoClass.DoMethodStr)
		print('')
		'''
		
		#map
		map(	
				lambda __ClassingSwitchUnboundMethodStr:
				self.switch(
					True,
					__ClassingSwitchUnboundMethodStr
				),
				self.ClassingSwitchMethodStrsList
			)

		#/###################/#
		# Check for overriden propertize_ methods 
		#

		#Debug
		'''
		print('Classer l 125')
		print('Check for overriden propertize_ methods ')
		print('self.DoClass.InspectMethodDict')
		print(self.DoClass.InspectMethodDict)
		print('')
		'''

		#filter
		ClassedPropertyNewMethodDict=dict(
			SYS._filter(
				lambda __MethodItemTuple:
				__MethodItemTuple[0].startswith(
						Propertiser.PropertyPrefixStr
					) and (
					SYS.getNewMethodBool(self.DoClass,__MethodItemTuple[0])
					#getattr(
					#	self.DoClass.__bases__[0],
					#	__MethodItemTuple[0]
					#)!=__MethodItemTuple[1]
					#if hasattr(self.DoClass.__bases__[0],
					#	__MethodItemTuple[0]
					#) else True
				),
				self.DoClass.InspectMethodDict.items()
			)
		)

		#Debug
		'''
		print('Classer l 147')
		print('self.DoClass is ')
		print(self.DoClass)
		print('ClassedPropertyNewMethodDict is')
		print(SYS.indent(ClassedPropertyNewMethodDict))
		print('')
		'''
		
		#map
		ClassedPropertyKeyStrsList=map(
				lambda __PropertizedKeyStr:
				SYS.deprefix(
					__PropertizedKeyStr,
					Propertiser.PropertyPrefixStr
				)[3:],
				ClassedPropertyNewMethodDict.keys()
			)

		#map reset the properties
		map(
				lambda __PropertyKeyStr:
				setattr(
						self.DoClass,
						__PropertyKeyStr,
						property(
								getattr(
									self.DoClass,
									Propertiser.PropertyPrefixStr+'get'+__PropertyKeyStr
								),
								getattr(
									self.DoClass,
									Propertiser.PropertyPrefixStr+'set'+__PropertyKeyStr
								),
								getattr(
									self.DoClass,
									Propertiser.PropertyPrefixStr+'del'+__PropertyKeyStr
								)
							)
					),
				ClassedPropertyKeyStrsList
			)

		#/###################/#
		# Set maybe a structure 
		#

		#Check
		if self.ClassingStructureVariable!=None:

			#Check
			if hasattr(
					self.ClassingStructureVariable,'items'
				):
				ClassedStructureVariable=self.ClassingStructureVariable.items()
			else:
				ClassedStructureVariable=self.ClassingStructureVariable


			#debug
			'''
			print('Classer l 241')
			print('We structure here')
			print('self.ClassingStructureVariable is ')
			print(self.ClassingStructureVariable)
			print('')
			'''

			#map add the sing plurals
			map(
				lambda __ItemTuple:
				SYS.addSingPlural(
					*__ItemTuple
				),
				ClassedStructureVariable
			)

			#Define a class
			class StructureClass(SYS.StructurerClass):pass
			StructureClass.__name__=SYS.getClassStrWithNameStr(self.DoClass.NameStr+'sStructurer')
			StructureClass.ManagingValueClass=self.DoClass

			#set
			setattr(
				self.Module,
				StructureClass.__name__,
				StructureClass
			)

			#dict
			ClassesDict=dict(
					map(
						lambda __ItemTuple:
						(__ItemTuple[1],StructureClass),
						ClassedStructureVariable
					)
				)

			#map
			if self.DoClass.TeamingClassesDict==None:
				self.DoClass.TeamingClassesDict=ClassesDict
			else:
				self.DoClass.TeamingClassesDict.update(
					ClassesDict
				)
Exemplo n.º 7
0
	def do_imitate(self):

		#Debug
		'''
		print('l. 63 Imitater')
		print('self.ImitatingFunction is ',self.ImitatingFunction)
		print('')
		'''

		#Definitions
		ImitatedDoMethodStr=self.ImitatingFunction.__name__
		ImitatedDoStr=ImitatedDoMethodStr[0].upper()+ImitatedDoMethodStr[1:]
		ImitatedDoerStr=Doer.getDoerStrWithDoStr(ImitatedDoStr)

		#Debug
		'''
		print('ImitatedDoMethodStr is ',ImitatedDoMethodStr)
		print('ImitatedDoStr is ',ImitatedDoStr)
		print('ImitatedDoerStr is ',ImitatedDoerStr)
		print('')
		'''

		#Definitions
		ImitatedModule=getattr(SYS,ImitatedDoerStr)
		ImitatedClass=getattr(ImitatedModule,SYS.getClassStrWithNameStr(ImitatedDoerStr))
		ImitatedDoneExecStr=getattr(
			ImitatedClass,
			ImitatedClass.NameStr+'DoneExecStr'
		).replace('def DoerFunction','def ImitaterFunction')

		#Define
		def imitateDo(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict):
			
			#Debug
			'''
			print('Imitater l.93 inside of the function imitateDo')
			print('_InstanceVariable is ',_InstanceVariable)
			print('_LiargVariablesList is ',_LiargVariablesList)
			print('_KwargVariablesDict is ',_KwargVariablesDict)
			print('')
			'''

			if len(_KwargVariablesDict)>0:

				#group by
				[ImitatedItemTuplesList,ImitatedNotItemTuplesList]=SYS.groupby(
					lambda __ItemTuple:hasattr(_InstanceVariable,__ItemTuple[0]),
					_KwargVariablesDict.items()
				)

				#Debug
				'''
				print('ImitatedItemTuplesList is ',ImitatedItemTuplesList)
				print('ImitatedNotItemTuplesList is ',ImitatedNotItemTuplesList)
				print('')
				'''

				#set in the instance the corresponding kwarged arguments
				map(	
						lambda __ItemTuple:
						#set direct explicit attributes
						_InstanceVariable.__setattr__(*__ItemTuple),
						ImitatedItemTuplesList
					)

				#Define
				ImitatedKwargDict=dict(ImitatedNotItemTuplesList)

			else:

				#Define
				ImitatedKwargDict={}

			#Init
			ImitatedOutputVariable=None

			#Debug
			'''
			print('l.141 Imitater')
			print('self.ImitatingFunction is ',self.ImitatingFunction)
			print('ImitatedKwargDict is ',ImitatedKwargDict)
			print('')
			'''
			
			#call the imitated function
			if len(ImitatedKwargDict)>0:
				ImitatedOutputVariable=self.ImitatingFunction(
									_InstanceVariable,
									*_LiargVariablesList,
									**ImitatedKwargDict
								)
			else:
				ImitatedOutputVariable=self.ImitatingFunction(
						_InstanceVariable,
						*_LiargVariablesList
						)

			#Check
			if ImitatedClass.DoingGetBool==False:

				#Return 
				return _InstanceVariable
			
			else:

				#Return the 
				return ImitatedOutputVariable

		#Link
		ImitatedFunctionKeyStr='imitate'+ImitatedDoStr+'With'+inspect.getmodule(
			self.ImitatingFunction
					).__name__.split('.')[-1]
		if hasattr(ImitatedClass,ImitatedFunctionKeyStr)==False:
			setattr(ImitatedClass,ImitatedFunctionKeyStr,imitateDo)
		else:

			ImitatedLastInt=sorted(
				map(
					lambda __MethodKeyStr:
					(int)(__MethodKeyStr.split('_')[-1]),
					SYS._filter(
						lambda __KeyStr:
						__KeyStr.startswith(ImitatedFunctionKeyStr),
						ImitatedClass.__dict__.keys()
						)
				)
			)[-1]
			setattr(ImitatedClass,ImitatedFunctionKeyStr+'_'+str(ImitatedLastInt),imitateDo)

		#Add to the ImitatedDoneExecStr
		ImitatedDoneExecStr+='\n\treturn _InstanceVariable.'+ImitatedFunctionKeyStr+'(*_LiargVariablesList,**_KwargVariablesDict)'

		#Debug
		'''
		print('ImitatedDoneExecStr is ')
		print(ImitatedDoneExecStr)
		print('')
		'''
		
		#exec
		six.exec_(ImitatedDoneExecStr)

		#set the name
		locals()['ImitaterFunction'].__name__=self.__class__.NameStr+Doer.DoingDecorationStr+ImitatedDoMethodStr

		#Link
		self.ImitatedFunction=locals()['ImitaterFunction']
	def do_model(self):
		""" """

		#Debug
		self.debug('model start')
		
		#/###################/#
		# Define the ModeledKeyStr 
		#

		if self.ModeledDescriptionKeyStr=='':
			self.ModeledDescriptionKeyStr=self.ModelTagStr

		#/###################/#
		# Mongo Case
		#

		#Check
		if self.ModelingMongoBool:

			#debug
			'''
			self.debug(
					'We model mongo here'
				)
			'''

			#set
			self.ModeledMongoSuffixStr=self.ModelTagStr+'Collection'

			#debug
			'''
			self.debug(
				[
					('self.',self,[
							'PymongoneClientVariable',
							'ModeledMongoSuffixStr'
						]
					)
				]
			)
			'''

			#Check
			if self.ModelDeriveControllerVariable.PymongoneClientVariable==None:

				#debug
				'''
				self.debug('We have to pymongo first...')
				'''

				#pymongo
				self.ModelDeriveControllerVariable.pymongo()

			#Link
			self.ModeledMongoTopClientVariable=self.ModelDeriveControllerVariable.PymongoneClientVariable
			
			#Check
			if self.ModeledMongoTopClientVariable!=None:

				#debug
				'''
				self.debug(
							[	
								'Looking for names of collections here',
								('self.',self,[
									'ModeledMongoTopClientVariable'
									]),
							]
						)
				'''

				#set
				self.ModeledMongoDatabaseKeyStr=self.ModelDeriveControllerVariable.ControlModelStr

				#set
				self.ModelDeriveControllerVariable.PymongoingDatabaseKeyStr=self.ModeledMongoDatabaseKeyStr

				#set
				self.ModeledMongoLocalDatabaseVariable=self.ModeledMongoTopClientVariable[
						self.ModeledMongoDatabaseKeyStr
				]

				#debug
				'''
				self.debug(
						[
							('self.',self,[
								'ModeledMongoDatabaseKeyStr',
								'ModeledMongoLocalDatabaseVariable'
								]),
							"id(self.ModeledMongoLocalDatabaseVariable) is "+str(
								id(self.ModeledMongoLocalDatabaseVariable))
						]
					)
				'''

				#set
				self.ModeledMongoLocalDatabaseVariable.__dict__[
					'ParentDerivePymongoer'
				]=self.ModelDeriveControllerVariable

				#alias
				self.ModelDeriveControllerVariable.Database=self.ModeledMongoLocalDatabaseVariable

				#debug
				'''
				self.debug(
							[	
								('self.',self,[
									'ModeledMongoLocalDatabaseVariable'
									]),
								"'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__",
								'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__
							]
						)
				'''

				#Get and sort
				self.ModeledMongoKeyStrsList=map(
					str,
					sorted(
						filter(
								lambda __KeyStr:
								__KeyStr.endswith(
									self.ModeledMongoSuffixStr
								),
								self.ModeledMongoLocalDatabaseVariable.collection_names()
							)
						)
				)
				
				#debug
				'''
				self.debug(
					[	
						('self.',self,[
							'ModeledMongoKeyStrsList'
							])
					]
				)
				'''
				
				#update
				self.ModeledMongoCollectionsOrderedDict.update(
					map(
							lambda __ModeledKeyStr:
							(
								__ModeledKeyStr,
								self.ModeledMongoLocalDatabaseVariable[
									__ModeledKeyStr
								]
							),
							self.ModeledMongoKeyStrsList
						)
				)

				#debug
				'''
				self.debug(("self.",self,[
											'ModeledMongoSuffixStr',
											'ModeledMongoKeyStrsList'
											]))
				'''

			#debug
			'''
			self.debug(
						[
							'ModeledMongoKeyStrsList',
							'ModeledMongoSuffixStr',
							'ModeledMongoKeyStr'
						]
					)
			'''

			#Get the suffix Strs of all the tables and their index
			ModeledMongoList=SYS.unzip(map(
					lambda __StrsList:
					(
						__StrsList[1],
						ModelingOrderStr.join(__StrsList[2:])
					),
					map(
							lambda __ModeledMongoKeyStr:
							__ModeledMongoKeyStr.split(ModelingOrderStr),
							self.ModeledMongoKeyStrsList
						)
				),[0,1]
			)

			#debug
			'''
			self.debug(('vars ',vars(),['ModeledHdfList']))
			'''
			
			#Unpack if it is possible
			if len(ModeledMongoList)>0:

				#Unpack
				[ModeledMongoIndexIntsTuple,ModeledMongoSuffixStrsList]=ModeledMongoList

				#debug
				'''
				self.debug(
							[
								'There are already some tables',
								'ModeledMongoSuffixStrsList is '+str(ModeledMongoSuffixStrsList),
								"self.ModeledMongoSuffixStr is "+str(
									self.ModeledMongoSuffixStr)
							]
						)
				'''

				if self.ModeledMongoSuffixStr not in ModeledMongoSuffixStrsList:

					#Increment the IndexStr
					ModeledMongoIndexInt=max(map(int,ModeledMongoIndexIntsTuple))+1

					#Strify
					ModeledMongoIndexStr=str(ModeledMongoIndexInt)

					#debug
					'''
					self.debug('IndexStr of this new table is '+str(IndexStr))
					'''
					
				else:

					#Get the already setted one
					ModeledMongoIndexStr=self.ModeledMongoKeyStrsList[
							ModeledMongoSuffixStrsList.index(self.ModeledMongoSuffixStr)
						].split(ModelingOrderStr)[1]

					#Intify
					ModeledMongoIndexInt=(int)(ModeledMongoIndexStr)

					#debug
					'''
					self.debug('IndexStr of this not new table is '+str(IndexStr))
					'''

			else:

				#debug
				'''
				self.debug('There are no tables here')
				'''

				#set to empty lists 
				[ModeledMongoIndexIntsTuple,ModeledMongoSuffixStrsList]=[[],[]]

				#Init the list
				ModeledMongoIndexInt=0

				#Strify
				ModeledMongoIndexStr="0"

			#Bind with ModeledHdfKeyStr setting
			self.ModeledMongoKeyStr=ModelingOrderStr+ModeledMongoIndexStr+ModelingOrderStr+self.ModeledMongoSuffixStr

			#set the ModeledInt
			self.ModeledMongoIndexInt=ModeledMongoIndexInt

			#debug
			'''
			self.debug("self.ModeledMongoKeyStr is "+str(self.ModeledMongoKeyStr))
			'''
			
			#debug
			'''
			self.debug(
						[
							'Here we create the collection or get it depending if it is new or not',
							'self.ModeledMongoKeyStr is '+self.ModeledMongoKeyStr,
							'self.ModeledTopFileVariable!=None is '+str(self.ModeledTopFileVariable!=None)
						]
					)
			'''

			#Check
			if self.ModeledMongoKeyStr!="" and self.ModeledMongoLocalDatabaseVariable!=None:

				#debug
				'''
				self.debug(
							[
								('self.',self,[
									'ModeledMongoKeyStr',
									'ModeledMongoKeyStrsList'
									]
								),
								'self.ModeledMongoLocalDatabaseVariable.collection_names() is ',
								str(self.ModeledMongoLocalDatabaseVariable.collection_names())
							]
						)
				'''
				
				#Create the collection if not already
				if self.ModeledMongoKeyStr not in self.ModeledMongoKeyStrsList:

					#debug
					'''
					self.debug(
								[
									'The collection not exists',
								]
							)
					'''

					#Create the collections
					self.ModeledMongoCollection=self.ModeledMongoLocalDatabaseVariable.create_collection(
						self.ModeledMongoKeyStr
					)

					#Append
					self.ModeledMongoKeyStrsList.append(self.ModeledMongoKeyStr)

				else:

					#debug
					'''
					self.debug(
						[
							'The collection exists',
						]
					)
					'''

					#Else just get it 
					self.ModeledMongoCollection=self.ModeledMongoLocalDatabaseVariable[
						self.ModeledMongoKeyStr
					]
					
				#set the in the ModeledMongoCollectionsOrderedDict
				self.ModeledMongoCollectionsOrderedDict[
					self.ModeledMongoKeyStr
				]=self.ModeledMongoCollection

				#debug
				'''
				self.debug("self.ModeledMongoCollectionsOrderedDict is "+str(self.ModeledMongoCollectionsOrderedDict))
				'''
				
			#debug
			'''
			self.debug(
						[
							'Table is done here for mongo...',
							('self.',self,[
								'ModeledMongoCollection',
								'ModeledMongoTopDatabaseVariable'
								]
							)
						]
					)
			'''

		#/###################/#
		# Hdf Case
		#

		#Check
		if self.ModelingHdfBool:

			#/###################/#
			# Define the Description
			#

			#import 
			import tables

			#Definition the DescriptionClass
			class DescriptionClass(tables.IsDescription):

				#Add (just like a unique KEY in mysql...) 
				RowInt=tables.Int64Col()

			#debug
			self.debug(
				[
					'We add descriptions in the description Class',
					('self.',self,['ModelingDescriptionTuplesList'])
				]
			)
			
			#set the cols in the ModelClass
			map(
					lambda __ModelingColumnTuple:
					DescriptionClass.columns.__setitem__(
						__ModelingColumnTuple[1],
						__ModelingColumnTuple[2]
						),
					self.ModelingDescriptionTuplesList
				)

			#Give a name
			DescriptionClass.__name__=SYS.getClassStrWithNameStr(self.ModelTagStr)

			#set the ModelClass
			if self.ModeledDescriptionClassesOrderedDict==None:
				self.ModeledDescriptionClassesOrderedDict=collections.OrderedDict()
			self.ModeledDescriptionClassesOrderedDict[self.ModelTagStr]=DescriptionClass

			#set the ModeledDescriptionClass
			self.ModeledDescriptionClass=DescriptionClass

			#debug
			'''
			self.debug('We tabular for hdf here...')
			'''
			
			#set
			self.ModeledHdfSuffixStr=self.ModelTagStr+'Table'

			#Check
			if self.ModelDeriveControllerVariable.HdformatedFileVariable==None:

				#Check
				if self.ModelDeriveControllerVariable.HdformatingFileKeyStr=='':

					#set
					self.ModelDeriveControllerVariable.HdformatingFileKeyStr=self.ModelDeriveControllerVariable.ControlModelStr+'.hdf5'

				#debug
				'''
				self.debug(
					[
						'We have to hdformat first...',
						'self.ModelDeriveControllerVariable.HdformatingFileKeyStr is ',
						self.ModelDeriveControllerVariable.HdformatingFileKeyStr
					]
				)
				'''

				#Hdformat
				self.ModelDeriveControllerVariable.hdformat()
				
			#Set
			self.ModelDeriveControllerVariable.HdfGroupPathStr=self.ModelDeriveControllerVariable.ControlModelStr

			#Link
			self.ModeledHdfTopFileVariable=self.ModelDeriveControllerVariable.HdformatedFileVariable
			
			#debug
			'''
			self.debug(('self.',self,[
										'ModeledHdfTopFileVariable'
									]))
			'''
			
			#/#################/#
			# Check for all the tables alreday defined here
			#

			#Check
			if self.ModeledHdfTopFileVariable!=None:

				#debug
				'''
				self.debug(
							[	
								'Looking for names of tables here',
								('self.',self,['HdfGroupPathStr'])
							]
						)
				'''

				#Definition Modeled attributes
				self.ModeledHdfGroupVariable=self.ModeledHdfTopFileVariable.getNode(
					self.ModelDeriveControllerVariable.HdfGroupPathStr
				)

				#debug
				'''
				self.debug(
							[
								('looking for tables with the same suffix Str as : '),
								('self.',self,['ModeledHdfSuffixStr'])
							]
						)
				'''

				#Get and sort
				self.ModeledHdfKeyStrsList=sorted(
					filter(
							lambda __KeyStr:
							__KeyStr.endswith(self.ModeledHdfSuffixStr),
							self.ModeledHdfGroupVariable._v_leaves.keys()
						)
				)
				
				self.ModeledHdfTablesOrderedDict.update(
					map(
							lambda __ModeledKeyStr:
							(
								__ModeledKeyStr,
								self.ModeledHdfGroupVariable._f_getChild(
									__ModeledKeyStr
								)
							),
							self.ModeledHdfKeyStrsList
						)
				)

				#debug
				'''
				self.debug(("self.",self,[
											'ModeledHdfSuffixStr',
											'ModeledHdfKeyStrsList'
											]))
				'''	

			#/################/#
			# Refind all the names of the tables
			#

			#debug
			'''
			self.debug(
						('self.',self,[
							'ModeledHdfKeyStrsList',
							'ModeledHdfSuffixStr',
							'ModeledHdfKeyStr'
						])
					)
			'''

			#Get the suffix Strs of all the tables and their index
			ModeledHdfList=SYS.unzip(map(
					lambda __StrsList:
					(
						__StrsList[1],
						ModelingOrderStr.join(__StrsList[2:])
					),
					map(
							lambda __ModeledHdfKeyStr:
							__ModeledHdfKeyStr.split(ModelingOrderStr),
							self.ModeledHdfKeyStrsList
						)
				),[0,1]
			)

			#debug
			self.debug(('vars ',vars(),['ModeledHdfList']))
			
			#/##################/#
			# Find if there are already some tables here and deduce the index of the table
			#

			#Unpack if it is possible
			if len(ModeledHdfList)>0:

				#Unpack
				[ModeledHdfIndexIntsTuple,ModeledHdfSuffixStrsList]=ModeledHdfList

				#debug
				'''
				self.debug(
							[
								'There are already some tables',
								'ModeledHdfSuffixStrsList is '+str(ModeledHdfSuffixStrsList),
								"self.ModeledHdfSuffixStr is "+str(
									self.ModeledHdfSuffixStr)
							]
						)
				'''

				if self.ModeledHdfSuffixStr not in ModeledHdfSuffixStrsList:

					#Increment the IndexStr
					ModeledHdfIndexInt=max(map(int,ModeledHdfIndexIntsTuple))+1

					#Strify
					ModeledHdfIndexStr=str(ModeledHdfIndexInt)

					#debug
					'''
					self.debug('IndexStr of this new table is '+str(IndexStr))
					'''
					
				else:

					#Get the already setted one
					ModeledHdfIndexStr=self.ModeledHdfKeyStrsList[
							ModeledHdfSuffixStrsList.index(self.ModeledHdfSuffixStr)
						].split(ModelingOrderStr)[1]

					#Intify
					ModeledHdfIndexInt=(int)(ModeledHdfIndexStr)

					#debug
					'''
					self.debug('IndexStr of this not new table is '+str(IndexStr))
					'''

			else:

				#debug
				'''
				self.debug('There are no tables here')
				'''

				#set to empty lists 
				[ModeledHdfIndexIntsTuple,ModeledHdfSuffixStrsList]=[[],[]]

				#Init the list
				ModeledHdfIndexInt=0

				#Strify
				ModeledHdfIndexStr="0"

			#/##################/#
			# set the table key str
			#

			#debug
			self.debug(
					[
						'We set the table key str',
						('self.',self,['ModeledHdfKeyStr'])
					]
				)

			#Bind with ModeledHdfKeyStr setting
			self.ModeledHdfKeyStr=ModelingOrderStr+ModeledHdfIndexStr+ModelingOrderStr+self.ModeledHdfSuffixStr

			#set the ModeledInt
			self.ModeledHdfIndexInt=ModeledHdfIndexInt

			#debug
			'''
			self.debug("self.ModeledHdfKeyStr is "+str(self.ModeledHdfKeyStr))
			'''
			
			#debug
			'''
			self.debug(
						[
							'Here we create the table or get it depending if it is new or not',
							('self.',self,[
								'ModeledHdfKeyStr',
								'ModeledHdfTopFileVariable'
								])
						]
					)
			'''
			
			#Check
			if self.ModeledHdfKeyStr!="" and self.ModeledHdfTopFileVariable!=None:

				#debug
				'''
				self.debug(
							[
								('self.',self,[
									'ModeledHdfKeyStr',
									'ModeledHdfKeyStrsList'
								])
							]
						)
				'''
				
				#Create the Table if not already
				if self.ModeledHdfKeyStr not in self.ModeledHdfKeyStrsList:

					#debug
					'''
					self.debug(
								[
									'The table not exists',
								]
							)
					'''

					#Create the Table in the hdf5
					self.ModeledHdfTable=self.ModeledHdfTopFileVariable.create_table(
						self.ModeledHdfGroupVariable,
						self.ModeledHdfKeyStr,
						self.ModeledDescriptionClass,
						self.ModeledDescriptionClass.__doc__ 
						if self.ModeledDescriptionClass.__doc__!=None 
						else "This is the "+self.ModeledDescriptionClass.__name__
					)

					#Append
					self.ModeledHdfKeyStrsList.append(
						self.ModeledHdfKeyStr
					)

				else:

					#debug
					'''
					self.debug(
									[
										'The table exists',
										"self.ModeledGroupVariable is "+str(self.ModeledGroupVariable)
									]
								)
					'''

					#Else just get it 
					self.ModeledHdfTable=self.ModeledHdfGroupVariable._f_getChild(
						self.ModeledHdfKeyStr
					)

				#set the in the TablesOrderedDict
				self.ModeledHdfTablesOrderedDict[
					self.ModeledHdfKeyStr
				]=self.ModeledHdfTable

				#debug
				'''
				self.debug("self.ModeledHdfTablesOrderedDict is "+str(
					self.ModeledHdfTablesOrderedDict))
				'''
				
			#debug
			'''
	def argument(self,_Variable):

		#debug
		'''
		self.debug(('locals ',locals(),['_Variable']))
		'''

		#set
		if self.ArgumentingFunction==None or _Variable!=None:
			self.ArgumentingFunction=_Variable

		#set the ArgumentingDoStr if not already
		if self.ArgumentingDoStr=="":

			#debug
			'''
			self.debug(('self.',self,['ArgumentingFunction']))
			'''

			#Keep only the last part of the name to avoid the FunctingDecorationStrs
			ArgumentedSplitFunctionStr=self.ArgumentingFunction.__name__.split(
				Functer.FunctingDecorationStr)[-1]

			#set
			self.ArgumentingDoStr=ArgumentedSplitFunctionStr[0].upper(
				)+ArgumentedSplitFunctionStr[1:]
			self.ArgumentingDoerStr=Doer.getDoerStrWithDoStr(self.ArgumentingDoStr)

		#debug
		'''
		self.debug(('self.',self,['ArgumentingDoStr']))
		'''

		#set the ArgumentedDoingStr
		self.ArgumentedDoingStr=Doer.getDoingStrWithDoneStr(
			Doer.getDoneStrWithDoStr(self.ArgumentingDoStr)
			)

		#Find the Arguments Types
		self.ArgumentedInspectOrderedDict=SYS.getArgumentDictWithFunction(
			self.ArgumentingFunction)

		#Definition
		ArgumentedExecStr='def ArgumentedFunction('
		ArgumentedExecStr+=','.join(
								map(
									lambda __KeyStr:
									__KeyStr+"=None",
									getattr(
										SYS,
										SYS.getClassStrWithNameStr(
											self.ArgumentingDoerStr
										)
									).DoingAttributeVariablesOrderedDict.keys()
								)
							)
		ArgumentedExecStr+=',**_KwargVariablesDict):\n'
		ArgumentedExecStr+='''

			#set in the instance the corresponding listed arguments if they are not None
			map(	
					lambda __KeyStr,__Variable:
					_InstanceVariable.__setattr__(__KeyStr,__Variable) 
					if __Variable!=None,
					map(
							lambda __InputKeyStr:
							self.ArgumentedDoingStr+ArgumentingStr.join(
								__InputKeyStr.split(ArgumentingStr)[1:]
								),
							self.__class__.DoingAttributeVariablesOrderedDict.keys()
							#self.ArgumentedInspectOrderedDict[
							#'InputKeyStrsList'][1:]
					),
					_LiargVariablesList
				)


			#Definition the ArgumentedSetTuplesList
			ArgumentedKwargTuplesList=map(
											lambda __ItemTuple:
											(
												self.ArgumentedDoingStr+ArgumentingStr.join(
												__ItemTuple[0].split(ArgumentingStr)[1:]),
												__ItemTuple[1]
											) if __ItemTuple[0].startswith(ArgumentingStr)
											else __ItemTuple,
											_KwargVariablesDict.items()
										)

			#set in the instance the corresponding kwarged arguments
			map(	
					lambda __ItemTuple:
					#set direct explicit attributes
					_InstanceVariable.__setattr__(*__ItemTuple) 
					if hasattr(_InstanceVariable,__ItemTuple[0])
					else None,
					ArgumentedKwargTuplesList
				)

			#Call the argumenting self.ArgumentingFunction
			return self.ArgumentingFunction(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict)


		'''

		#debug
		print('ArgumentedExecStr is ',ArgumentedExecStr)
		print('')

		#Definition the ArgumentedFunction
		def ArgumentedFunction(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict):

			
			#debug
			'''
			self.debug(
						[
							('',locals(),[
											'_LiargVariablesList'
								]),
							('self.',self,[
											'ArgumentingDoStr',
											'ArgumentedDoingStr',
											'ArgumentedInspectOrderedDict'
											])
						]
					)
			'''
			
			#set in the instance the corresponding listed arguments if they are not None
			map(	
					lambda __KeyStr,__Variable:
					_InstanceVariable.__setattr__(__KeyStr,__Variable) 
					if __Variable!=None and hasattr(_InstanceVariable,__KeyStr) else None,
					map(
							lambda __InputKeyStr:
							self.ArgumentedDoingStr+ArgumentingStr.join(
								__InputKeyStr.split(ArgumentingStr)[1:]
								),
							#self.__class__.DoingAttributeVariablesOrderedDict.keys()
							self.ArgumentedInspectOrderedDict[
							'InputKeyStrsList'][1:]
					),
					_LiargVariablesList
				)


			#Definition the ArgumentedSetTuplesList
			ArgumentedKwargTuplesList=map(
											lambda __ItemTuple:
											(
												self.ArgumentedDoingStr+ArgumentingStr.join(
												__ItemTuple[0].split(ArgumentingStr)[1:]),
												__ItemTuple[1]
											) if __ItemTuple[0].startswith(ArgumentingStr)
											else __ItemTuple,
											_KwargVariablesDict.items()
										)

			#set in the instance the corresponding kwarged arguments
			map(	
					lambda __ItemTuple:
					#set direct explicit attributes
					_InstanceVariable.__setattr__(*__ItemTuple) 
					if hasattr(_InstanceVariable,__ItemTuple[0])
					else None,
					ArgumentedKwargTuplesList
				)

			#Call the argumenting self.ArgumentingFunction
			return self.ArgumentingFunction(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict)

		#set
		self.ArgumentedFunction=ArgumentedFunction

		#Return self
		return self
Exemplo n.º 10
0
	def do_map(self):

		#Debug
		'''
		print('l 174 Mapper')
		print('self.MappingDoMethodStr is ',self.MappingDoMethodStr)
		print('')
		'''

		#Check
		if self.MappingDoMethodStr!="":

			#observe
			self.observe(True,self.MappingDoMethodStr)

			#set
			self.MappedWrapMethodStr=MappingWrapPrefixStr+self.MappingDoMethodStr

			#Debug
			'''
			print('l 75 Mapper ')
			print('self.MappedWrapMethodStr is ',self.MappedWrapMethodStr)
			print('')
			'''

			#Define
			MappedDoStr=self.MappingDoMethodStr[0].upper()+self.MappingDoMethodStr[1:]
			MappedDoerStr=Doer.DoStrToDoerStrOrderedDict[MappedDoStr]

			#Debug
			'''
			print('l 84 Mapper ')
			print('MappedDoStr is ',MappedDoStr)
			print('MappedDoerStr is ',MappedDoerStr)
			print('MappedBaseModule is ',MappedBaseModule)
			print('')
			'''

			#Definitions
			MappedBaseClass=getattr(
				SYS,
				SYS.getClassStrWithNameStr(MappedDoerStr)
			)

			#get
			MappedDoExecStr=getattr(
				MappedBaseClass,
				'Do'+MappedBaseClass.NameStr+'ExecStr'
			)

			#debug
			'''
			print('l 206 Mapper')
			print('MappedDoExecStr is ')
			print(MappedDoExecStr)
			print('')
			'''

			#replace
			MappedDecorationMethodStr=MappingDecorationPrefixStr+MappingDecorationTagStr+MappingDecorationSuffixStr
			MappedDecorationMethodStr+=self.ObservedWrapMethodStr

			#Debug
			'''
			print('l 232 Mapper')
			print('MappedDecorationMethodStr is '+MappedDecorationMethodStr)
			print('')
			'''
			
			#replace
			MappedExecStr='def '+MappedDecorationMethodStr+'('+'('.join(
				MappedDoExecStr.split('(')[1:]
			)

			#Debug
			'''
			print('l 208 Mapper')
			print('MappedExecStr is ')
			print(MappedExecStr)
			print('')
			'''
			
			#Add to the ImitatedDoneExecStr
			MappedExecStr+='\n\treturn map(_InstanceVariable,*_LiargVariablesList,'
			MappedExecStr+='**dict({\'MapMethodStr\':\''+self.MappedWrapMethodStr+'\','
			MappedExecStr+='\'MapClassStr\':\''+self.DoClass.__name__+'\','
			MappedExecStr+='\'BaseClassStr\':\''+MappedBaseClass.__name__+'\''
			MappedExecStr+='},**_KwargVariablesDict))'
			
			#Debug
			'''
			print('l 223 Mapper')
			print('MappedExecStr is ')
			print(MappedExecStr)
			print('')
			'''
			
			#exec
			six.exec_(MappedExecStr)

			#set
			self.MappedDecorationUnboundMethod=locals()[MappedDecorationMethodStr]

			#set in the __class__
			setattr(
						self.DoClass,
						MappedDecorationMethodStr,
						self.MappedDecorationUnboundMethod
					)

			#make the amalgam
			setattr(
						self.DoClass,
						self.MappingDoMethodStr,
						self.MappedDecorationUnboundMethod
					)
Exemplo n.º 11
0
    def do_database(self):
        """ """

        # debug
        """
		self.debug(('self.',self,['DatabasingSealTuplesList']))
		"""

        # model first
        self.model()

        # set a name if it was not already
        if self.DatabasedKeyStr == "":

            # debug
            """
			self.debug(('self.',self,['DatabasingKeyStr','ModeledSuffixStr']))
			"""

            # Link set
            self.DatabasedKeyStr = self.ModeledSuffixStr

            # Check
        if len(self.DatabasingSealTuplesList) > 0:
            self.DatabasingHdfBool = True
            self.DatabasingMongoBool = False
        else:
            self.DatabasingHdfBool = False
            self.DatabasingMongoBool = True

            # Check
        if self.DatabasingHdfBool:

            # import
            import tables

            # Definition the ModelClass
            class ModelClass(tables.IsDescription):

                # Add (just like a unique KEY in mysql...)
                RowInt = tables.Int64Col()

                # debug

            """
			self.debug(('self.',self,['DatabasedGetStrToColumnStrOrderedDict']))
			"""

            # set the cols in the ModelClass
            map(
                lambda __DatabasingColumnTuple: ModelClass.columns.__setitem__(
                    __DatabasingColumnTuple[1], __DatabasingColumnTuple[2]
                ),
                self.DatabasingSealTuplesList,
            )

            # Give a name
            ModelClass.__name__ = SYS.getClassStrWithNameStr(self.DatabasedKeyStr)

            # set the ModelClass
            if self.DatabasedModelClassesOrderedDict == None:
                self.DatabasedModelClassesOrderedDict = collections.OrderedDict()
            self.DatabasedModelClassesOrderedDict[self.DatabasedKeyStr] = ModelClass

            # set the DatabasedModelClass
            self.DatabasedModelClass = ModelClass
	def do_mimic(self):
				
		#set
		self.MimickedMethodStr=MimickingPrefixStr+self.MimickingDoMethodStr

		#Debug
		'''
		print('l 75 Mimicker ')
		print('self.MimickedMethodStr is ',self.MimickedMethodStr)
		print('')
		'''

		#Define
		MimickedDoStr=self.MimickingDoMethodStr[0].upper()+self.MimickingDoMethodStr[1:]
		MimickedDoerStr=Doer.DoStrToDoerStrOrderedDict[MimickedDoStr]

		#Debug
		'''
		print('l 84 Mimicker ')
		print('MimickedDoStr is ',MimickedDoStr)
		print('MimickedDoerStr is ',MimickedDoerStr)
		print('')
		'''

		#Definitions
		MimickedModule=getattr(SYS,MimickedDoerStr)
		MimickedClass=getattr(MimickedModule,SYS.getClassStrWithNameStr(MimickedDoerStr))
		MimickedDoneExecStr=getattr(
			MimickedClass,
			MimickedClass.NameStr+'DoneExecStr'
		).replace('def DoerFunction','def MimickerFunction')

		#Debug
		'''
		print('l 99 Mimicker')
		print('MimickedDoneExecStr is ')
		print(MimickedDoneExecStr)
		print('')
		'''

		#Define
		def MimickedNewFunction(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict):
			
			#Set
			MimicMethodStr=_KwargVariablesDict['MimicMethodStr']
			del _KwargVariablesDict['MimicMethodStr']
			MimicDoStr=MimickingPrefixStr.join(MimicMethodStr.split(MimickingPrefixStr)[1:])
			MimicDoStr=MimicDoStr[0].upper()+MimicDoStr[1:] if MimicDoStr[0]!='_' else MimicDoStr[1].upper()+MimicDoStr[2:]
			MimicNameStr=Doer.DoStrToDoerStrOrderedDict[MimicDoStr]
			MimicClass=getattr(SYS,SYS.getClassStrWithNameStr(MimicNameStr))
			DoClassStr=_KwargVariablesDict['DoClassStr']
			del _KwargVariablesDict['DoClassStr']
			DoClass=getattr(SYS,DoClassStr)

			#Debug
			'''
			print('Mimicker l.119 inside of the function MimickedNewFunction')
			#print('_InstanceVariable is ',_InstanceVariable)
			print('_LiargVariablesList is ',_LiargVariablesList)
			print('_KwargVariablesDict is ',_KwargVariablesDict)
			print('MimicMethodStr is ',MimicMethodStr)
			print('')
			'''

			if len(_KwargVariablesDict)>0:

				#group by
				[
					MimicItemTuplesList,
					MimicNotItemTuplesList
				]=SYS.groupby(
					lambda __ItemTuple:
					hasattr(_InstanceVariable,__ItemTuple[0]),
					_KwargVariablesDict.items()
				)

				#Debug
				'''
				print('MimicItemTuplesList is ',MimicItemTuplesList)
				print('MimicNotItemTuplesList is ',MimicNotItemTuplesList)
				print('')
				'''

				#set in the instance the corresponding kwarged arguments
				map(	
						lambda __ItemTuple:
						#set direct explicit attributes
						_InstanceVariable.__setattr__(*__ItemTuple),
						MimicItemTuplesList
					)

				#Define
				MimicKwargDict=dict(MimicNotItemTuplesList)

			else:

				#Define
				MimicKwargDict={}

			#Init
			MimicOutputVariable=None

			#Debug
			'''
			print('Mimicker l.167 inside of the function MimickedNewFunction')
			print('DoClass is ',DoClass)
			print('MimicMethodStr is ',MimicMethodStr)
			print('')
			'''

			#Get the method
			MimicUnBoundMethod=getattr(
				DoClass,
				MimicMethodStr
			)

			#Debug
			'''
			print('Mimicker l.181 inside of the function MimickedNewFunction')
			print('MimicUnBoundMethod is ',MimicUnBoundMethod)
			print('MimicKwargDict is ',MimicKwargDict)
			print('')
			'''
			
			#call the Mimicked function
			if len(MimicKwargDict)>0:
				MimicOutputVariable=MimicUnBoundMethod(
									_InstanceVariable,
									*_LiargVariablesList,
									**MimicKwargDict
								)
			else:
				MimicOutputVariable=MimicUnBoundMethod(
						_InstanceVariable,
						*_LiargVariablesList
					)

			#Debug
			'''
			print('Mimicker l.178 inside of the function MimickedNewFunction')
			print('MimicClass is ',MimicClass)
			print('MimicClass.DoingGetBool is ',MimicClass.DoingGetBool)
			print('MimicOutputVariable is ',MimicOutputVariable)
			print('')
			'''

			#Check
			if MimicClass.DoingGetBool==False:

				#Return 
				return _InstanceVariable
			
			else:

				#Return the 
				return MimicOutputVariable

		#Rename
		MimickedNewFunction.__name__='mimic'+MimickedDoStr+'With'+self.DoClass.NameStr

		#Debug
		'''
		print('l.225 Mimicker')
		print('MimickedNewFunction is ',MimickedNewFunction)
		print('MimickedNewFunction.__name__ is ',MimickedNewFunction.__name__)
		print('')
		'''

		#Set in the class
		setattr(
				self.DoClass,
				MimickedNewFunction.__name__,
				MimickedNewFunction
			)

		#Add to the ImitatedDoneExecStr
		MimickedDoneExecStr+='\n\treturn _InstanceVariable.'+MimickedNewFunction.__name__+'(*_LiargVariablesList,**dict({\'MimicMethodStr\':\''+self.MimickedMethodStr+'\',\'DoClassStr\':\''+self.DoClass.__name__+'\'},**_KwargVariablesDict))'

		#Debug
		'''
		print('MimickedDoneExecStr is ')
		print(MimickedDoneExecStr)
		print('')
		'''
		
		#exec
		six.exec_(MimickedDoneExecStr)

		#set the name
		locals()[
			'MimickerFunction'
		].__name__=self.__class__.NameStr+Doer.DoingDecorationStr+MimickingDecoratioStr+self.MimickingDoMethodStr

		#set in the __class__
		setattr(
					self.DoClass,
					self.MimickingDoMethodStr,
					locals()['MimickerFunction']
				)
		def MimickedNewFunction(_InstanceVariable,*_LiargVariablesList,**_KwargVariablesDict):
			
			#Set
			MimicMethodStr=_KwargVariablesDict['MimicMethodStr']
			del _KwargVariablesDict['MimicMethodStr']
			MimicDoStr=MimickingPrefixStr.join(MimicMethodStr.split(MimickingPrefixStr)[1:])
			MimicDoStr=MimicDoStr[0].upper()+MimicDoStr[1:] if MimicDoStr[0]!='_' else MimicDoStr[1].upper()+MimicDoStr[2:]
			MimicNameStr=Doer.DoStrToDoerStrOrderedDict[MimicDoStr]
			MimicClass=getattr(SYS,SYS.getClassStrWithNameStr(MimicNameStr))
			DoClassStr=_KwargVariablesDict['DoClassStr']
			del _KwargVariablesDict['DoClassStr']
			DoClass=getattr(SYS,DoClassStr)

			#Debug
			'''
			print('Mimicker l.119 inside of the function MimickedNewFunction')
			#print('_InstanceVariable is ',_InstanceVariable)
			print('_LiargVariablesList is ',_LiargVariablesList)
			print('_KwargVariablesDict is ',_KwargVariablesDict)
			print('MimicMethodStr is ',MimicMethodStr)
			print('')
			'''

			if len(_KwargVariablesDict)>0:

				#group by
				[
					MimicItemTuplesList,
					MimicNotItemTuplesList
				]=SYS.groupby(
					lambda __ItemTuple:
					hasattr(_InstanceVariable,__ItemTuple[0]),
					_KwargVariablesDict.items()
				)

				#Debug
				'''
				print('MimicItemTuplesList is ',MimicItemTuplesList)
				print('MimicNotItemTuplesList is ',MimicNotItemTuplesList)
				print('')
				'''

				#set in the instance the corresponding kwarged arguments
				map(	
						lambda __ItemTuple:
						#set direct explicit attributes
						_InstanceVariable.__setattr__(*__ItemTuple),
						MimicItemTuplesList
					)

				#Define
				MimicKwargDict=dict(MimicNotItemTuplesList)

			else:

				#Define
				MimicKwargDict={}

			#Init
			MimicOutputVariable=None

			#Debug
			'''
			print('Mimicker l.167 inside of the function MimickedNewFunction')
			print('DoClass is ',DoClass)
			print('MimicMethodStr is ',MimicMethodStr)
			print('')
			'''

			#Get the method
			MimicUnBoundMethod=getattr(
				DoClass,
				MimicMethodStr
			)

			#Debug
			'''
			print('Mimicker l.181 inside of the function MimickedNewFunction')
			print('MimicUnBoundMethod is ',MimicUnBoundMethod)
			print('MimicKwargDict is ',MimicKwargDict)
			print('')
			'''
			
			#call the Mimicked function
			if len(MimicKwargDict)>0:
				MimicOutputVariable=MimicUnBoundMethod(
									_InstanceVariable,
									*_LiargVariablesList,
									**MimicKwargDict
								)
			else:
				MimicOutputVariable=MimicUnBoundMethod(
						_InstanceVariable,
						*_LiargVariablesList
					)

			#Debug
			'''
			print('Mimicker l.178 inside of the function MimickedNewFunction')
			print('MimicClass is ',MimicClass)
			print('MimicClass.DoingGetBool is ',MimicClass.DoingGetBool)
			print('MimicOutputVariable is ',MimicOutputVariable)
			print('')
			'''

			#Check
			if MimicClass.DoingGetBool==False:

				#Return 
				return _InstanceVariable
			
			else:

				#Return the 
				return MimicOutputVariable
Exemplo n.º 14
0
	def do_call(self):

		#Module first to know where we are
		self.package()

		#debug
		'''
		print("self.CallingVariable is ",self.CallingVariable)
		print('')
		'''

		#If it was not yet setted or changed
		if self.CallingVariable==None or self.CallingVariable.__name__!=self.CallingFunctionStr:

			#debug
			'''
			print('Get in the module')
			print('self.PackagingModuleVariable is '+str(self.PackagingModuleVariable))
			print('')
			'''

			#Get maybe the one in the module
			if self.CallingFunctionStr!="":

				#debug
				'''
				print('Get in the module with the function Str')
				print('self.CallingFunctionStr is ',self.CallingFunctionStr)
				print('')
				'''

				#Get and return
				self.CallingVariable=getattr(self.PackagedModuleVariable,self.CallingFunctionStr)
				return self

		#Get the function 
		if self.CallingVariable==None or self.CallingVariable.__name__!=self.CallingMethodStr:

			#debug
			'''
			print('Get in a class')
			print('self.PackagingModuleVariable is '+str(self.PackagingModuleVariable))
			print('self.CallingVariable is ',self.CallingVariable)
			print('self.CallingMethodStr is ',self.CallingMethodStr)
			print('self.CallingClass is ',self.CallingClass)
			print('self.CallingClassStr is ',self.CallingClassStr)
			print('self.CallingInstanceVariable is ',self.CallingInstanceVariable)
			print('')
			'''
			
			#Get with the CallingInstanceVariable class maybe
			if self.CallingClass==None and self.CallingInstanceVariable!=None:
				self.CallingClass=self.CallingInstanceVariable.__class__

			#Import the module if not already
			if self.CallingClass==None:
				if self.CallingClassStr!="":
					self.CallingClass=getattr(self.PackagedModuleVariable,self.CallingClassStr)
				else:
					self.CallingClass=getattr(
									self.PackagedModuleVariable,
									SYS.getClassStrWithNameStr(
										SYS.getNameStrWithModuleStr(self.PackagedModuleVariable.__name__)
										)
									)
			

			#debug
			'''
			print('Now get the unbounded method function')
			print('self.CallingClass is '+str(self.CallingClass))
			print('')
			'''

			#Check
			if self.CallingMethodStr!="":
	
				#debug
				'''
				print('self.CallingMethodStr is ',self.CallingMethodStr)
				print('')
				'''

				#Return 
				self.CallingVariable=getattr(self.CallingClass,self.CallingMethodStr)