From 3a659528614c6137f06d0dc25b850ea6ec229e6f Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Sun, 7 Oct 2018 22:24:57 +0800 Subject: [PATCH] ready to factor slightly --- thing.py | 6 ++++-- thing_test.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/thing.py b/thing.py index 7896d59..a66d846 100644 --- a/thing.py +++ b/thing.py @@ -106,13 +106,15 @@ class _Node: def _mkbtree(records, bthKeyLen): nodelist = [] # append to this as we go - index_step = 8 # pointers per index node; min=2, max=11 + # pointers per index node, range 2-11 + index_step = 8 # not really worth tuning # First node is always a header node, with three records: # header records, reserved record, bitmap record headnode = _Node(ndType=1, ndNHeight=0, records=['header placeholder', bytes(128), 'bitmap placeholder']) nodelist.append(headnode) + # Followed (in our implementation) by leaf nodes bthNRecs = 0 bthRoot = 0 bthDepth = 0 @@ -158,7 +160,7 @@ def _mkbtree(records, bthKeyLen): # Add map nodes with 3952-bit bitmap recs to cover every node bits_covered = 2048 mapnodes = [] - while bits_covered < len(nodelist): # THIS ID NUMBER IS WRONG! + while bits_covered < len(nodelist): mapnode = _Node(ndType=2, ndNHeight=1) nodelist.append(mapnode) mapnodes.append(mapnode) diff --git a/thing_test.py b/thing_test.py index 1b77ee0..41f7a4a 100644 --- a/thing_test.py +++ b/thing_test.py @@ -22,7 +22,7 @@ def test_macos_mount(): h.drVN = b'ElmoTest' hf = File() hf.data = b'12345' * 10 - for i in range(100): + for i in reversed(range(100)): last = b'testfile-%03d' % i h[last] = hf ser = h.write(10*1024*1024) @@ -32,7 +32,7 @@ def test_macos_mount(): assert h2[b'testfile-000'].data == hf.data open('/tmp/SMALL.dmg','wb').write(ser) - os.system('open /tmp/SMALL.dmg') + os.system('hdiutil attach /tmp/SMALL.dmg') n = 10 while 1: n += 1