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

This commit is contained in:
The MMGen Project 2022-02-05 13:32:52 +00:00
commit 05e901e78d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 9 additions and 4 deletions

View file

@ -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):

View file

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