Simplify blob design
This commit is contained in:
parent
844c5100ef
commit
9f116547d0
1 changed files with 5 additions and 14 deletions
|
|
@ -1,14 +1,4 @@
|
||||||
from enum import Enum, auto
|
def __load_blob(blob: str) -> bytes:
|
||||||
|
|
||||||
|
|
||||||
class Blobs(Enum):
|
|
||||||
init_hardcoded = auto()
|
|
||||||
init_hardcoded_clean_slate = auto()
|
|
||||||
reset_blob = auto()
|
|
||||||
db_write_enable = auto()
|
|
||||||
|
|
||||||
|
|
||||||
def __load_blob(blob):
|
|
||||||
from .usb import usb
|
from .usb import usb
|
||||||
|
|
||||||
if usb.usb_dev().idVendor == 0x138a:
|
if usb.usb_dev().idVendor == 0x138a:
|
||||||
|
|
@ -24,6 +14,7 @@ def __load_blob(blob):
|
||||||
return globals()[blob]
|
return globals()[blob]
|
||||||
|
|
||||||
|
|
||||||
for p in dir(Blobs):
|
init_hardcoded = lambda: __load_blob('init_hardcoded')
|
||||||
if isinstance(getattr(Blobs, p), Blobs):
|
init_hardcoded_clean_slate = lambda: __load_blob('init_hardcoded_clean_slate')
|
||||||
globals()[p] = lambda bname=p: __load_blob(bname)
|
reset_blob = lambda: __load_blob('reset_blob')
|
||||||
|
db_write_enable = lambda: __load_blob('db_write_enable')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue