Browse Source

devtools.py: add pexit() method, allow args in pmsg()

The MMGen Project 3 years ago
parent
commit
05e901e78d
2 changed files with 9 additions and 4 deletions
  1. 8 4
      mmgen/devtools.py
  2. 1 0
      mmgen/obj.py

+ 8 - 4
mmgen/devtools.py

@@ -53,13 +53,17 @@ if os.getenv('MMGEN_DEBUG') or os.getenv('MMGEN_TEST_SUITE') or os.getenv('MMGEN
 			print_stack_trace(*args,**kwargs)
 
 		# Pretty-print any object subclassed from MMGenObject, recursing into sub-objects - WIP
-		def pmsg(self):
-			print(self.pfmt())
+		def pmsg(self,*args):
+			print(args[0] if len(args) == 1 else args if args else self.pfmt())
 
-		def pdie(self):
-			print(self.pfmt())
+		def pdie(self,*args):
+			self.pmsg(*args)
 			sys.exit(1)
 
+		def pexit(self,*args):
+			self.pmsg(*args)
+			sys.exit(0)
+
 		def pfmt(self,lvl=0,id_list=[]):
 			scalars = (str,int,float,Decimal)
 			def do_list(out,e,lvl=0,is_dict=False):

+ 1 - 0
mmgen/obj.py

@@ -177,6 +177,7 @@ class MMGenListItem(MMGenObject):
 		'pfmt',
 		'pmsg',
 		'pdie',
+		'pexit',
 		'valid_attrs',
 		'valid_attrs_extra',
 		'invalid_attrs',