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

Fixed type issue on SLENTRY and NBTENTRY on HN #90

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
21 changes: 11 additions & 10 deletions src/formats/pst.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,12 @@ class HN:
bTypeBTH: int = 0xB5
bTypePC: int = 0xBC

nbt_entry: NBTENTRY
bid_sub: Optional[BID] = None

# While it is not defined in the spec,
# BID data and BID sub nodes are needed to enumerate the sub nodes
# BID comes from a NBTENTRY or a SLENTRY object
node_entry: Union[NBTENTRY, SLENTRY]
data_sections: list[bytes]
ltp: 'LTP'
hnpagemaps: list[HNPAGEMAP]
Expand All @@ -661,10 +666,10 @@ class HN:
hidUserRoot: HID
rgbFillLevel: int

def __init__(self, nbt_entry: NBTENTRY, ltp: 'LTP', data_sections: list[bytes]) -> None:
def __init__(self, node_entry: Union[NBTENTRY, SLENTRY], ltp: 'LTP', data_sections: list[bytes]) -> None:
"""data_sections = list of data sections from blocks"""

self.nbt_entry = nbt_entry
self.node_entry = node_entry
self.data_sections = data_sections
self.ltp = ltp
self.hnpagemaps = []
Expand Down Expand Up @@ -692,9 +697,8 @@ def __init__(self, nbt_entry: NBTENTRY, ltp: 'LTP', data_sections: list[bytes])
self.hnpagemaps.append(HNPAGEMAP(section_bytes[ibHnpm:]))

# subnode SLENTRYs
self.subnodes = None
if self.nbt_entry.bidSub.bid != 0:
self.subnodes = self.ltp.nbd.fetch_subnodes(self.nbt_entry.bidSub)
if node_entry.bidSub.bid != 0:
self.subnodes = self.ltp.nbd.fetch_subnodes(node_entry.bidSub)

def get_hid_data(self, hid: HID) -> bytes:

Expand All @@ -705,7 +709,7 @@ def get_hid_data(self, hid: HID) -> bytes:

def __repr__(self) -> str:

return 'HN: %s, Blocks: %s' % (self.nbt_entry, len(self.data_sections))
return 'HN: %s, Blocks: %s' % (self.node_entry, len(self.data_sections))


class BTHData:
Expand Down Expand Up @@ -1309,7 +1313,6 @@ def get_pc_by_slentry(self, slentry: SLENTRY) -> PC:

block_data_list: list[bytes] = self.nbd.fetch_all_block_data(
slentry.bidData)
# TODO: Solve HN with SLENTRY parameter
hn: HN = HN(slentry, self, block_data_list)

return PC(hn)
Expand All @@ -1327,7 +1330,6 @@ def get_tc_by_slentry(self, slentry: SLENTRY) -> TC:

block_data_list: list[bytes] = self.nbd.fetch_all_block_data(
slentry.bidData)
# TODO: Solve HN with SLENTRY parameter
hn: HN = HN(slentry, self, block_data_list)

return TC(hn)
Expand Down Expand Up @@ -1594,7 +1596,6 @@ def __init__(self, nid: NID, ltp: LTP, nbd: Optional[NBD] = None, parent_message

block_data_list: list[bytes] = nbd.fetch_all_block_data(
subnode.bidData)
# TODO: Solve HN with SLENTRY parameter
hn: HN = HN(subnode, ltp, block_data_list)
self.pc = PC(hn)
else:
Expand Down
Loading