Beispiel #1
0
	def callBeforeBasesWithDebugger(self,*_ArgsList):
		'''
			<Help>
				Get a Debug String
			</Help>
		
			<Test>
				#Load ShareYourSystem as SYS
				import ShareYourSystem as SYS
				#
				#Print a Debug String
				def foo():
					print(SYS.callBeforeBasesWithDebugger(SYS.DebuggerClass()));
				foo();
			</Test>
		'''
		
		#Get the Frame
		if self.Frame==None:

			#Get the close back Frame
			Frame=SYS.inspect.currentframe().f_back

			#Go back until the scope is not found
			while Frame!=None and hasattr(Frame,"f_code"):

				#Get the ScriptPathString
				ScriptPathStringsList=SYS.getWordStringsListWithString(Frame.f_code.co_filename)
				ScriptPathString=''.join(ScriptPathStringsList)

				#Find the scope of the debugged Function
				if SYS.getCommonPrefixStringWithStringsList([SYS.MySYSFolderPathString,ScriptPathString])==SYS.MySYSFolderPathString:
					if SYS.getWordStringsListWithString(ScriptPathStringsList[-1])[-1] in ["Methods.py","Functions.py"]:
						break

				#Either go back in the Frame
				Frame=Frame.f_back
		else:
			Frame=self.Frame

		#Return the Debug Format
		print(self.Indent.AlineaString+"%s , %s, l. %s : "%(ScriptPathString,Frame.f_code.co_name,Frame.f_lineno)+self.Indent.LineJumpString+"<Debug>");
Beispiel #2
0
	def getPrintedDictString(self,_Dict):
		'''
			<Help>
				Get a Stringified version of a dict with alphabetical order
			</Help>

			<Test>
				#Load ShareYourSystem as SYS
				import ShareYourSystem as SYS
				#
				#Define a Dict
				Dict={'ThisDict':{'ThingsDict':{'Thing':0},'MyObjectsList':[{'ID':0}]},'Stuff':"Sad"};
				#
				#Print the Dict
				print("The PrintedDictString is :");
				print(SYS.getPrintedDictStringWithPrinter(SYS.ConsolePrinter,Dict));
			</Test>
		'''
			
		#Init the PrintedDictString
		PrintedDictString='{ '
		
		#Set the ElementString
		self.Indent['ElementString']=SYS.ReprElementString
		
		#Update the AlineaString and check that the binding has worked
		self.Indent.addElementString()
		
		#Do the first Jump
		PrintedDictString+=self.Indent.LineJumpString
		
		#Scan the Items (integrativ loop)
		StringLengthInt=len(_Dict)
		ItemInt=0
		for KeyString,ValueVariable in sorted(_Dict.iteritems(), key=lambda key_value: key_value[0]):
		
			#Only Key Displayed Case
			if self.IsPrintedKeysBool and self.IsPrintedValuesBool==False:
			
				if SYS.getWordStringsListWithNameString(KeyString)[-1]=="Pointer":
				
					#Pointer Case
					PrintedDictString+="'"+KeyString+"'"
				
				else:
					
					#OtherCases
					if hasattr(ValueVariable,'__dict__'):
						PrintedDictString+=SYS.getPrintedPointerString(ValueVariable)
					else:
						PrintedDictString+=str(type(ValueVariable))
			else:
				
				#Get the WordStringsList
				WordStringsList=SYS.getWordStringsListWithString(KeyString)

				#Init the DisplayedValueVariableString
				DisplayedValueVariableString="None"

				if len(WordStringsList)>0:

					#Value is displayed
					if SYS.getWordStringsListWithString(KeyString)[-1]=="Pointer":
					
						#Pointer Case
						DisplayedValueVariableString=SYS.getPrintedPointerString(ValueVariable)

					elif ''.join(SYS.getWordStringsListWithString(KeyString)[-2:])=="PointersList":
					
						#Pointer Case
						DisplayedValueVariableString=str(map(lambda ListedVariable:SYS.getPrintedPointerString(ListedVariable),ValueVariable))
						
				#Special Suffix Cases
				TypeString=type(ValueVariable).__name__
				if TypeString=="instancemethod":
					DisplayedValueVariableString="<"+ValueVariable.__name__+" "+TypeString+">"
							
				elif DisplayedValueVariableString=="None":
						
					#Other Cases
					DisplayedValueVariableString=self.getPrintedVariableString(ValueVariable)
				
				if self.IsPrintedKeysBool==False and self.IsPrintedValuesBool:
				
					#Only Value Case
					PrintedDictString+=DisplayedValueVariableString
			
				elif self.IsPrintedKeysBool and self.IsPrintedValuesBool:
					
					#Key and Value Case
					PrintedDictString+="'"+KeyString+"' : "+DisplayedValueVariableString

			#Separate items
			ItemInt+=1;
			if ItemInt<StringLengthInt:
				PrintedDictString+=self.Indent.LineJumpString

		#Update the AlineaString and check that the binding has worked
		self.Indent.substractElementString()
		
		#return the DictString
		return PrintedDictString+self.Indent.LineJumpString+' }'