Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Lee <stevenlee123@protonmail.com>2021-11-19 14:09:47 +1100
committerSteven Lee <stevenlee123@protonmail.com>2021-11-19 14:09:47 +1100
commit91d030a09c26f56ece0de72e3536ad31d48595ec (patch)
tree7cb45b216096ff972658216de96d9927469fa80a
parent5ec690da939ff5b2efb3ba2ffe177cb035c25ee6 (diff)
source code improvement
-rw-r--r--archinstall/lib/disk/partition.py10
-rw-r--r--archinstall/lib/general.py2
-rw-r--r--archinstall/lib/output.py1
-rw-r--r--examples/guided.py2
4 files changed, 9 insertions, 6 deletions
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index f8378d47..e2083649 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -136,7 +136,7 @@ class Partition:
@property
def partition_type(self):
lsblk = json.loads(SysCommand(f"lsblk --json -o+PTTYPE {self.path}").decode('UTF-8'))
-
+
for device in lsblk['blockdevices']:
return device['pttype']
@@ -153,7 +153,7 @@ class Partition:
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
if partuuid_struct.exit_code == 0:
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
- if (partuuid := partition_information.get('partuuid', None)):
+ if partuuid := partition_information.get('partuuid', None):
return partuuid
time.sleep(storage['DISK_TIMEOUTS'])
@@ -172,7 +172,7 @@ class Partition:
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
if partuuid_struct.exit_code == 0:
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
- if (partuuid := partition_information.get('partuuid', None)):
+ if partuuid := partition_information.get('partuuid', None):
return partuuid
@property
@@ -296,7 +296,7 @@ class Partition:
elif filesystem == 'f2fs':
options = ['-f'] + options
-
+
if (handle := SysCommand(f"/usr/bin/mkfs.f2fs {' '.join(options)} {path}")).exit_code != 0:
raise DiskError(f"Could not format {path} with {filesystem} because: {handle.decode('UTF-8')}")
self.filesystem = filesystem
@@ -378,7 +378,7 @@ class Partition:
try:
self.format(self.filesystem, '/dev/null', log_formatting=False, allow_formatting=True)
except (SysCallError, DiskError):
- pass # We supported it, but /dev/null is not formatable as expected so the mkfs call exited with an error code
+ pass # We supported it, but /dev/null is not formattable as expected so the mkfs call exited with an error code
except UnknownFilesystemFormat as err:
raise err
return True
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index ee088d4f..a057af5a 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -76,6 +76,7 @@ def json_dumps(*args, **kwargs):
return json.dumps(*args, **{**kwargs, 'cls': JSON})
class JsonEncoder:
+ @staticmethod
def _encode(obj):
"""
This JSON encoder function will try it's best to convert
@@ -112,6 +113,7 @@ class JsonEncoder:
else:
return obj
+ @staticmethod
def _unsafe_encode(obj):
"""
Same as _encode() but it keeps dictionary keys starting with !
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 595e9693..b81c91a9 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -19,6 +19,7 @@ class LogLevels:
class Journald(dict):
+ @staticmethod
@abc.abstractmethod
def log(message, level=logging.DEBUG):
try:
diff --git a/examples/guided.py b/examples/guided.py
index 0d56540a..a43aff5b 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -113,7 +113,7 @@ def ask_user_questions():
# Get disk encryption password (or skip if blank)
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None:
- if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')):
+ if passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '):
archinstall.arguments['!encryption-password'] = passwd
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None):