Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk.py
diff options
context:
space:
mode:
authorVarun Madiath <vamega@gmail.com>2020-10-19 22:59:30 -0400
committerVarun Madiath <vamega@gmail.com>2020-10-19 23:07:35 -0400
commit5ded22a5d0f5fb1cf1d4d95945f655e8b6a33896 (patch)
tree4e2b46493fadf9cf777e9371545a2e93d1510b17 /archinstall/lib/disk.py
parente4f363ce7dbd6ec27a30123caf262c99452a0dd4 (diff)
Fix some PEP-8 errors.
Diffstat (limited to 'archinstall/lib/disk.py')
-rw-r--r--archinstall/lib/disk.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index b11f2318..0d0285d2 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -1,6 +1,6 @@
import glob, re, os, json
from collections import OrderedDict
-from .exceptions import *
+from .exceptions import DiskError
from .general import *
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
@@ -21,7 +21,7 @@ class BlockDevice():
return f"BlockDevice({self.device})"
def __getitem__(self, key, *args, **kwargs):
- if not key in self.info:
+ if key not in self.info:
raise KeyError(f'{self} does not contain information: "{key}"')
return self.info[key]
@@ -37,9 +37,9 @@ class BlockDevice():
def __dump__(self):
return {
- 'path' : self.path,
- 'info' : self.info,
- 'partition_cache' : self.part_cache
+ 'path': self.path,
+ 'info': self.info,
+ 'partition_cache': self.part_cache
}
@property
@@ -50,7 +50,8 @@ class BlockDevice():
If it's a ATA-drive it returns the /dev/X device
And if it's a crypto-device it returns the parent device
"""
- if not 'type' in self.info: raise DiskError(f'Could not locate backplane info for "{self.path}"')
+ if "type" not in self.info:
+ raise DiskError(f'Could not locate backplane info for "{self.path}"')
if self.info['type'] == 'loop':
for drive in json.loads(b''.join(sys_command(f'losetup --json', hide_from_log=True)).decode('UTF_8'))['loopdevices']:
@@ -60,7 +61,8 @@ class BlockDevice():
elif self.info['type'] == 'disk':
return self.path
elif self.info['type'] == 'crypt':
- if not 'pkname' in self.info: raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.')
+ if 'pkname' not in self.info:
+ raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.')
return f"/dev/{self.info['pkname']}"
# if not stat.S_ISBLK(os.stat(full_path).st_mode):
@@ -97,7 +99,8 @@ class BlockDevice():
class Partition():
def __init__(self, path, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False):
- if not part_id: part_id = os.path.basename(path)
+ if not part_id:
+ part_id = os.path.basename(path)
self.path = path
self.part_id = part_id
self.mountpoint = mountpoint
@@ -115,7 +118,7 @@ class Partition():
log(f'Formatting {self} -> {filesystem}')
if filesystem == 'btrfs':
o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {self.path}'))
- if not b'UUID' in o:
+ if b'UUID' not in o:
raise DiskError(f'Could not format {self.path} with {filesystem} because: {o}')
self.filesystem = 'btrfs'
elif filesystem == 'fat32':
@@ -244,11 +247,11 @@ def device_state(name, *args, **kwargs):
# lsblk --json -l -n -o path
def all_disks(*args, **kwargs):
- if not 'partitions' in kwargs: kwargs['partitions'] = False
+ kwargs.setdefault("partitions", False)
drives = OrderedDict()
#for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']:
for drive in json.loads(b''.join(sys_command(f'lsblk --json -l -n -o path,size,type,mountpoint,label,pkname', *args, **kwargs, hide_from_log=True)).decode('UTF_8'))['blockdevices']:
if not kwargs['partitions'] and drive['type'] == 'part': continue
drives[drive['path']] = BlockDevice(drive['path'], drive)
- return drives \ No newline at end of file
+ return drives