Resolve a few more PEP issues in general.py
This commit is contained in:
parent
dd340b9cba
commit
8bc361970b
|
|
@ -45,15 +45,14 @@ def locate_binary(name):
|
||||||
class JSON_Encoder:
|
class JSON_Encoder:
|
||||||
def _encode(obj):
|
def _encode(obj):
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
## We'll need to iterate not just the value that default() usually gets passed
|
# We'll need to iterate not just the value that default() usually gets passed
|
||||||
## But also iterate manually over each key: value pair in order to trap the keys.
|
# But also iterate manually over each key: value pair in order to trap the keys.
|
||||||
|
|
||||||
copy = {}
|
copy = {}
|
||||||
for key, val in list(obj.items()):
|
for key, val in list(obj.items()):
|
||||||
if isinstance(val, dict):
|
if isinstance(val, dict):
|
||||||
val = json.loads(json.dumps(val, cls=JSON)) # This, is a EXTREMELY ugly hack..
|
# This, is a EXTREMELY ugly hack.. but it's the only quick way I can think of to trigger a encoding of sub-dictionaries.
|
||||||
# But it's the only quick way I can think of to
|
val = json.loads(json.dumps(val, cls=JSON))
|
||||||
# trigger a encoding of sub-dictionaries.
|
|
||||||
else:
|
else:
|
||||||
val = JSON_Encoder._encode(val)
|
val = JSON_Encoder._encode(val)
|
||||||
|
|
||||||
|
|
@ -84,7 +83,7 @@ class JSON(json.JSONEncoder, json.JSONDecoder):
|
||||||
def encode(self, obj):
|
def encode(self, obj):
|
||||||
return super(JSON, self).encode(self._encode(obj))
|
return super(JSON, self).encode(self._encode(obj))
|
||||||
|
|
||||||
class sys_command():#Thread):
|
class sys_command:
|
||||||
"""
|
"""
|
||||||
Stolen from archinstall_gui
|
Stolen from archinstall_gui
|
||||||
"""
|
"""
|
||||||
|
|
@ -128,7 +127,7 @@ class sys_command():#Thread):
|
||||||
|
|
||||||
user_catalogue = os.path.expanduser('~')
|
user_catalogue = os.path.expanduser('~')
|
||||||
|
|
||||||
if (workdir := kwargs.get('workdir', None)):
|
if workdir := kwargs.get('workdir', None):
|
||||||
self.cwd = workdir
|
self.cwd = workdir
|
||||||
self.exec_dir = workdir
|
self.exec_dir = workdir
|
||||||
else:
|
else:
|
||||||
|
|
@ -275,7 +274,7 @@ class sys_command():#Thread):
|
||||||
if broke:
|
if broke:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
## Adding a exit trigger:
|
# Adding a exit trigger:
|
||||||
if len(self.kwargs['events']) == 0:
|
if len(self.kwargs['events']) == 0:
|
||||||
if 'debug' in self.kwargs and self.kwargs['debug']:
|
if 'debug' in self.kwargs and self.kwargs['debug']:
|
||||||
self.log(f"Waiting for last command {self.cmd[0]} to finish.", level=logging.DEBUG)
|
self.log(f"Waiting for last command {self.cmd[0]} to finish.", level=logging.DEBUG)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue