Skip to content

Commit

Permalink
(#197) renaming external_files to extras in base.Bsp
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Nov 7, 2024
1 parent e1bc9bf commit f080cd6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bsp_tool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Bsp:
"""Bsp base class"""
branch: ModuleType # soft copy of "branch script"
endianness: str = "little"
external_files: Dict[str, io.BytesIO] # file handles
extras: Dict[str, io.BytesIO] # file handles
file_magic: bytes = b"XBSP"
# NOTE: XBSP is not a real bsp variant! this is just a placeholder
filesize: int = 0 # size of .bsp in bytes
Expand All @@ -32,7 +32,7 @@ def __init__(self, branch: ModuleType, filepath: str = "untitled.bsp"):
self.folder, self.filename = os.path.split(filepath)
self.set_branch(branch)
self.headers = dict()
self.external_files = dict()
self.extras = dict()

def __enter__(self):
return self
Expand Down Expand Up @@ -107,12 +107,9 @@ def lump_as_bytes(self, lump_name: str) -> bytes:

def mount_file(self, filename: str, archive=None):
if archive is None:
self.external_files[filename] = open(filename, "rb")
self.extras[filename] = open(filename, "rb")
else:
self.external_files[filename] = io.BytesIO(archive.read(filename))

def unmount_file(self, filename: str):
self.external_files.pop(filename)
self.extras[filename] = io.BytesIO(archive.read(filename))

def save_as(self, filename: str):
"""Expects outfile to be a file with write bytes capability"""
Expand Down Expand Up @@ -147,6 +144,9 @@ def set_branch(self, branch: ModuleType):
method = MethodType(method, self)
setattr(self, method_name, method)

def unmount_file(self, filename: str):
self.extras.pop(filename)

@classmethod
def from_archive(cls, branch: ModuleType, filepath: str, archive, mount_extras=False) -> Bsp:
bsp = cls.from_bytes(branch, filepath, archive.read(filepath))
Expand Down

0 comments on commit f080cd6

Please sign in to comment.