Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-11-06 09:48:42 +0100
committerGitHub <noreply@github.com>2021-11-06 09:48:42 +0100
commit97a91aab6019d6efb500de1240bc58b4165ab02d (patch)
tree83374c51a8dd5d0e6b8481362427bd65f0ad7885
parent0c1139ffaf5f62b3f927d90e3371e3fa6e0c5134 (diff)
Added mimic function for file operations
-rw-r--r--archinstall/lib/installer.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index aa26abf3..9cff1f7a 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -1,4 +1,5 @@
import time
+from typing import Union
from .disk import *
from .hardware import *
from .locale_helpers import verify_keyboard_layout, verify_x11_keyboard_layout
@@ -15,16 +16,29 @@ __packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "l
class InstallationFile:
- def __init__(self, installation, filename, owner):
+ def __init__(self, installation, filename, owner, mode="w"):
self.installation = installation
self.filename = filename
self.owner = owner
+ self.mode = mode
+ self.fh = None
def __enter__(self):
+ self.fh = open(self.filename, self.mode)
return self
- def __exit__(self):
+ def __exit__(self, *args):
+ self.fh.close()
self.installation.chown(self.owner, self.filename)
+
+ def write(self, data :Union[str, bytes]):
+ return self.fh.write(data)
+
+ def read(self, *args):
+ return self.fh.read(*args)
+
+ def poll(self, *args):
+ return self.fh.poll(*args)
class Installer:
"""