Open snake-biscuits opened 2 months ago
Would
from ..branches import base as branches_base
work?
No, it doesn't
Time for Plan B
moving such a core feature to a new location is a huge job we also need to be sure the new location is a good one
utils.binary
seems like a good location from a namespaces perspective
but branches.base
is a big cluttered file, overlapping w/ function utils could be extremely messy
taking each class (Struct
, MappedArray
& BitField
) into their own script seems smart, but idk
branches.base
contains some utils universal to all 3, which might be hard to spread
possible new submodule:
lump_classes/
| __init__.py
| bitfield.py
| mapped_array.py
| struct.py
tbh we could put this under bsp_tool.lumps
, since most lumps interact w/ RawBspLump
etc.
branches.shared.UnsignedInts
etc. (BasicLumpClasses
) would need to move too
grouping them together makes sense to me, feels intuitive to remember
branches.shared
is kinda an awkward spot anyway
would also be cool to have a generic SpecialLumpClass
baseclass
for wiring up a .from_bytes()
@classmethod
that way implementations only need a .from_stream()
__init__
binary.read_struct
has been really handy for building .from_stream()
s in archives
I can see it getting a lot of use in SpecialLumpClass
specs as well
Just can't think of where'd be a good place to put that
Some
archives
scripts cannot importbranches.base
valve.source
&nexon.cso2
importpkware.Zip
&nexon.PakFile
UsingStruct
would be really handy for some binary structures (those less tightly packed)This might be because we use
from ..branches.base import Struct
(to avoid collision w/archives.base
) Since that has to go throughbsp_tool/branches/__init__.py
, which loads all branch scriptsIf that isn't the case, we'll have to move
branches.base
classes elsewhere (maybeutils.binary
?)