-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_device.py
31 lines (25 loc) · 925 Bytes
/
block_device.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import utils
class BlockDevice:
def __init__(self, path) -> None:
raise RuntimeError("Use BlockDevice.create()")
@staticmethod
def create(path):
return BlockDevice.get_class()(path)
@staticmethod
def get_class():
match utils.get_platform():
case utils.Platform.LINUX:
from devices.linux import LinuxBlockDevice
return LinuxBlockDevice
case utils.Platform.MACOS:
from devices.macos import MacOSBlockDevice
return MacOSBlockDevice
case utils.Platform.WINDOWS:
from devices.windows import WindowsBlockDevice
return WindowsBlockDevice
case _:
raise NotImplementedError()
def __str__(self) -> str:
return f"BlockDevice({self.get_path()})"
def __repr__(self) -> str:
return self.__str__()