Cosmetic clean ups.

This commit is contained in:
philip 2021-12-15 16:00:18 +03:00
parent 45a6e5e79f
commit 10cbb1344d
Signed by: mango-habanero
GPG Key ID: B00CE9034DA19FB7

View File

@ -49,7 +49,7 @@ class Extension:
:returns: Token data state of extension after load :returns: Token data state of extension after load
""" """
return self.prepare_token(token.name, token.symbol, token.precision, token.code, token.supply) return self.prepare_token(token.name, token.symbol, token.precision, token.code, token.supply)
def prepare_token(self, name, symbol, precision, code, supply, extra=[], extra_types=[], positions=None): def prepare_token(self, name, symbol, precision, code, supply, extra=[], extra_types=[], positions=None):
"""Initialize extension token data. """Initialize extension token data.
@ -105,10 +105,10 @@ class Extension:
r = f.read() r = f.read()
f.close() f.close()
self.parse_code_as_hex(r) self.parse_code_as_hex(r)
except FileNotFoundError: except FileNotFoundError as e:
logg.debug('could not parse code as file: {}'.format(e)) logg.debug('could not parse code as file: {}'.format(e))
pass pass
except IsADirectoryError: except IsADirectoryError as e:
logg.debug('could not parse code as file: {}'.format(e)) logg.debug('could not parse code as file: {}'.format(e))
pass pass
@ -121,7 +121,7 @@ class Extension:
:param v: Bytecode as hex :param v: Bytecode as hex
:type v: str :type v: str
""" """
try: try:
self.token_code = valid_hex(v) self.token_code = valid_hex(v)
except ValueError as e: except ValueError as e:
logg.debug('could not parse code as hex: {}'.format(e)) logg.debug('could not parse code as hex: {}'.format(e))
@ -139,7 +139,7 @@ class Extension:
code = self.token_details['code'] code = self.token_details['code']
if hint == 'hex': if hint == 'hex':
self.token_code = valid_hex(code) self.token_code = valid_hex(code)
for m in [ for m in [
self.parse_code_as_hex, self.parse_code_as_hex,
self.parse_code_as_file, self.parse_code_as_file,
@ -147,7 +147,7 @@ class Extension:
m(code) m(code)
if self.token_code != None: if self.token_code != None:
break break
if self.token_code == None: if self.token_code == None:
raise RuntimeError('could not successfully parse token code') raise RuntimeError('could not successfully parse token code')
@ -167,9 +167,9 @@ class Extension:
if writer == None: if writer == None:
writer = self.outputs_writer writer = self.outputs_writer
tasks = [] tasks = []
self.token_address = self.resources['token']['reference'] self.token_address = self.resources['token']['reference']
# TODO: get token details when token address is not none # TODO: get token details when token address is not none
if self.token_address == None: if self.token_address == None:
if self.token_details['code'] == None: if self.token_details['code'] == None:
@ -182,7 +182,7 @@ class Extension:
continue continue
if self.resources[k]['reference'] != None: if self.resources[k]['reference'] != None:
tasks.append(k) tasks.append(k)
self.prepare_extension() self.prepare_extension()
for task in tasks: for task in tasks: