Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _very initial_ support for 3.0 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bw_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def decode(self, bytecode, meta_only = False):
bytecode.set_string_mode()
self.header = bytecode.read_str(40)
if self.header[:4] == 'BtWg' and int(self.header[4:40], 16):
if self.header[7] == '2':
if bytecode.contents_len < 60:
return
bytecode.reset_pos()
self.header = bytecode.read_str(60)

if self.header[11] == '2' or self.header[11] == '0':
bytecode.set_string_mode(self.header[11])
self.meta.decode(bytecode)
Expand Down Expand Up @@ -140,6 +146,13 @@ def export(self, path):
from pytwig.src.lib import fs
fs.write(path, self.serialize().replace('":', '" :'))

def read_bytes(self, bytes, raw = True, meta_only = False):
bytecode = BW_Bytecode().set_contents(bytes)
bytecode.raw = raw
bytecode.debug_obj = self
#self.num_spaces = 0
self.decode(bytecode, meta_only = meta_only)

def read(self, path, raw = True, meta_only = False):
from pytwig.src.lib import fs
bytecode = BW_Bytecode().set_contents(fs.read_binary(path))
Expand Down