scripts: Adopted rbydaddr/tagrepr changes across scripts
Just some minor tweaks: - rbydaddr: Return list instead of tuple, note we rely on the type distinction in Rbyd.fetch now. - tagrepr: Rename w -> weight.
This commit is contained in:
+5
-5
@@ -32,10 +32,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -66,7 +66,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def xxd(data, width=16):
|
def xxd(data, width=16):
|
||||||
for i in range(0, len(data), width):
|
for i in range(0, len(data), width):
|
||||||
|
|||||||
+5
-5
@@ -97,10 +97,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -131,7 +131,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def crc32c(data, crc=0):
|
def crc32c(data, crc=0):
|
||||||
crc ^= 0xffffffff
|
crc ^= 0xffffffff
|
||||||
|
|||||||
+18
-18
@@ -79,10 +79,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -113,7 +113,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def crc32c(data, crc=0):
|
def crc32c(data, crc=0):
|
||||||
crc ^= 0xffffffff
|
crc ^= 0xffffffff
|
||||||
@@ -165,11 +165,11 @@ def xxd(data, width=16):
|
|||||||
b if b >= ' ' and b <= '~' else '.'
|
b if b >= ' ' and b <= '~' else '.'
|
||||||
for b in map(chr, data[i:i+width])))
|
for b in map(chr, data[i:i+width])))
|
||||||
|
|
||||||
def tagrepr(tag, w=None, size=None, off=None):
|
def tagrepr(tag, weight=None, size=None, off=None):
|
||||||
if (tag & 0x6fff) == TAG_NULL:
|
if (tag & 0x6fff) == TAG_NULL:
|
||||||
return '%snull%s%s' % (
|
return '%snull%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %d' % size if size else '')
|
' %d' % size if size else '')
|
||||||
elif (tag & 0x6f00) == TAG_CONFIG:
|
elif (tag & 0x6f00) == TAG_CONFIG:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -183,14 +183,14 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
||||||
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
||||||
else 'config 0x%02x' % (tag & 0xff),
|
else 'config 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_GDELTA:
|
elif (tag & 0x6f00) == TAG_GDELTA:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
||||||
else 'gdelta 0x%02x' % (tag & 0xff),
|
else 'gdelta 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_NAME:
|
elif (tag & 0x6f00) == TAG_NAME:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -201,7 +201,7 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
||||||
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
||||||
else 'name 0x%02x' % (tag & 0xff),
|
else 'name 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_STRUCT:
|
elif (tag & 0x6f00) == TAG_STRUCT:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -216,21 +216,21 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'did' if (tag & 0xfff) == TAG_DID
|
else 'did' if (tag & 0xfff) == TAG_DID
|
||||||
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_ATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%s%sattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
's' if tag & 0x100 else 'u',
|
's' if tag & 0x100 else 'u',
|
||||||
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
return 'alt%s%s 0x%03x%s%s' % (
|
return 'alt%s%s 0x%03x%s%s' % (
|
||||||
'r' if tag & TAG_R else 'b',
|
'r' if tag & TAG_R else 'b',
|
||||||
'gt' if tag & TAG_GT else 'le',
|
'gt' if tag & TAG_GT else 'le',
|
||||||
tag & 0x0fff,
|
tag & 0x0fff,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' 0x%x' % (0xffffffff & (off-size))
|
' 0x%x' % (0xffffffff & (off-size))
|
||||||
if size and off is not None
|
if size and off is not None
|
||||||
else ' -%d' % size if size
|
else ' -%d' % size if size
|
||||||
@@ -239,27 +239,27 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
return 'cksum%s%s%s%s' % (
|
return 'cksum%s%s%s%s' % (
|
||||||
'p' if not tag & 0xfe and tag & TAG_P else '',
|
'p' if not tag & 0xfe and tag & TAG_P else '',
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_NOTE:
|
elif (tag & 0x7f00) == TAG_NOTE:
|
||||||
return 'note%s%s%s' % (
|
return 'note%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_ECKSUM:
|
elif (tag & 0x7f00) == TAG_ECKSUM:
|
||||||
return 'ecksum%s%s%s' % (
|
return 'ecksum%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
||||||
return 'gcksumdelta%s%s%s' % (
|
return 'gcksumdelta%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
else:
|
else:
|
||||||
return '0x%04x%s%s' % (
|
return '0x%04x%s%s' % (
|
||||||
tag,
|
tag,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' %d' % size if size is not None else '')
|
' %d' % size if size is not None else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -32,10 +32,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -66,7 +66,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def xxd(data, width=16):
|
def xxd(data, width=16):
|
||||||
for i in range(0, len(data), width):
|
for i in range(0, len(data), width):
|
||||||
|
|||||||
+18
-18
@@ -80,10 +80,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -114,7 +114,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def crc32c(data, crc=0):
|
def crc32c(data, crc=0):
|
||||||
crc ^= 0xffffffff
|
crc ^= 0xffffffff
|
||||||
@@ -211,11 +211,11 @@ def xxd(data, width=16):
|
|||||||
b if b >= ' ' and b <= '~' else '.'
|
b if b >= ' ' and b <= '~' else '.'
|
||||||
for b in map(chr, data[i:i+width])))
|
for b in map(chr, data[i:i+width])))
|
||||||
|
|
||||||
def tagrepr(tag, w=None, size=None, off=None):
|
def tagrepr(tag, weight=None, size=None, off=None):
|
||||||
if (tag & 0x6fff) == TAG_NULL:
|
if (tag & 0x6fff) == TAG_NULL:
|
||||||
return '%snull%s%s' % (
|
return '%snull%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %d' % size if size else '')
|
' %d' % size if size else '')
|
||||||
elif (tag & 0x6f00) == TAG_CONFIG:
|
elif (tag & 0x6f00) == TAG_CONFIG:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -229,14 +229,14 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
||||||
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
||||||
else 'config 0x%02x' % (tag & 0xff),
|
else 'config 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_GDELTA:
|
elif (tag & 0x6f00) == TAG_GDELTA:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
||||||
else 'gdelta 0x%02x' % (tag & 0xff),
|
else 'gdelta 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_NAME:
|
elif (tag & 0x6f00) == TAG_NAME:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -247,7 +247,7 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
||||||
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
||||||
else 'name 0x%02x' % (tag & 0xff),
|
else 'name 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_STRUCT:
|
elif (tag & 0x6f00) == TAG_STRUCT:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -262,21 +262,21 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'did' if (tag & 0xfff) == TAG_DID
|
else 'did' if (tag & 0xfff) == TAG_DID
|
||||||
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_ATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%s%sattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
's' if tag & 0x100 else 'u',
|
's' if tag & 0x100 else 'u',
|
||||||
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
return 'alt%s%s 0x%03x%s%s' % (
|
return 'alt%s%s 0x%03x%s%s' % (
|
||||||
'r' if tag & TAG_R else 'b',
|
'r' if tag & TAG_R else 'b',
|
||||||
'gt' if tag & TAG_GT else 'le',
|
'gt' if tag & TAG_GT else 'le',
|
||||||
tag & 0x0fff,
|
tag & 0x0fff,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' 0x%x' % (0xffffffff & (off-size))
|
' 0x%x' % (0xffffffff & (off-size))
|
||||||
if size and off is not None
|
if size and off is not None
|
||||||
else ' -%d' % size if size
|
else ' -%d' % size if size
|
||||||
@@ -285,27 +285,27 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
return 'cksum%s%s%s%s' % (
|
return 'cksum%s%s%s%s' % (
|
||||||
'p' if not tag & 0xfe and tag & TAG_P else '',
|
'p' if not tag & 0xfe and tag & TAG_P else '',
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_NOTE:
|
elif (tag & 0x7f00) == TAG_NOTE:
|
||||||
return 'note%s%s%s' % (
|
return 'note%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_ECKSUM:
|
elif (tag & 0x7f00) == TAG_ECKSUM:
|
||||||
return 'ecksum%s%s%s' % (
|
return 'ecksum%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
||||||
return 'gcksumdelta%s%s%s' % (
|
return 'gcksumdelta%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
else:
|
else:
|
||||||
return '0x%04x%s%s' % (
|
return '0x%04x%s%s' % (
|
||||||
tag,
|
tag,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' %d' % size if size is not None else '')
|
' %d' % size if size is not None else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-18
@@ -79,10 +79,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -113,7 +113,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
def crc32c(data, crc=0):
|
def crc32c(data, crc=0):
|
||||||
crc ^= 0xffffffff
|
crc ^= 0xffffffff
|
||||||
@@ -180,11 +180,11 @@ def xxd(data, width=16):
|
|||||||
b if b >= ' ' and b <= '~' else '.'
|
b if b >= ' ' and b <= '~' else '.'
|
||||||
for b in map(chr, data[i:i+width])))
|
for b in map(chr, data[i:i+width])))
|
||||||
|
|
||||||
def tagrepr(tag, w=None, size=None, off=None):
|
def tagrepr(tag, weight=None, size=None, off=None):
|
||||||
if (tag & 0x6fff) == TAG_NULL:
|
if (tag & 0x6fff) == TAG_NULL:
|
||||||
return '%snull%s%s' % (
|
return '%snull%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %d' % size if size else '')
|
' %d' % size if size else '')
|
||||||
elif (tag & 0x6f00) == TAG_CONFIG:
|
elif (tag & 0x6f00) == TAG_CONFIG:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -198,14 +198,14 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
||||||
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
||||||
else 'config 0x%02x' % (tag & 0xff),
|
else 'config 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_GDELTA:
|
elif (tag & 0x6f00) == TAG_GDELTA:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
||||||
else 'gdelta 0x%02x' % (tag & 0xff),
|
else 'gdelta 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_NAME:
|
elif (tag & 0x6f00) == TAG_NAME:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -216,7 +216,7 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
||||||
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
||||||
else 'name 0x%02x' % (tag & 0xff),
|
else 'name 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_STRUCT:
|
elif (tag & 0x6f00) == TAG_STRUCT:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -231,21 +231,21 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'did' if (tag & 0xfff) == TAG_DID
|
else 'did' if (tag & 0xfff) == TAG_DID
|
||||||
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_ATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%s%sattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
's' if tag & 0x100 else 'u',
|
's' if tag & 0x100 else 'u',
|
||||||
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
return 'alt%s%s 0x%03x%s%s' % (
|
return 'alt%s%s 0x%03x%s%s' % (
|
||||||
'r' if tag & TAG_R else 'b',
|
'r' if tag & TAG_R else 'b',
|
||||||
'gt' if tag & TAG_GT else 'le',
|
'gt' if tag & TAG_GT else 'le',
|
||||||
tag & 0x0fff,
|
tag & 0x0fff,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' 0x%x' % (0xffffffff & (off-size))
|
' 0x%x' % (0xffffffff & (off-size))
|
||||||
if size and off is not None
|
if size and off is not None
|
||||||
else ' -%d' % size if size
|
else ' -%d' % size if size
|
||||||
@@ -254,27 +254,27 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
return 'cksum%s%s%s%s' % (
|
return 'cksum%s%s%s%s' % (
|
||||||
'p' if not tag & 0xfe and tag & TAG_P else '',
|
'p' if not tag & 0xfe and tag & TAG_P else '',
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_NOTE:
|
elif (tag & 0x7f00) == TAG_NOTE:
|
||||||
return 'note%s%s%s' % (
|
return 'note%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_ECKSUM:
|
elif (tag & 0x7f00) == TAG_ECKSUM:
|
||||||
return 'ecksum%s%s%s' % (
|
return 'ecksum%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
||||||
return 'gcksumdelta%s%s%s' % (
|
return 'gcksumdelta%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
else:
|
else:
|
||||||
return '0x%04x%s%s' % (
|
return '0x%04x%s%s' % (
|
||||||
tag,
|
tag,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' %d' % size if size is not None else '')
|
' %d' % size if size is not None else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -88,7 +88,6 @@ def bdgeom(s):
|
|||||||
else:
|
else:
|
||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# TODO sync across scripts
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> [0xa]
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> [(0xa, 0xc)]
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
@@ -169,7 +168,6 @@ def xxd(data, width=16):
|
|||||||
b if b >= ' ' and b <= '~' else '.'
|
b if b >= ' ' and b <= '~' else '.'
|
||||||
for b in map(chr, data[i:i+width])))
|
for b in map(chr, data[i:i+width])))
|
||||||
|
|
||||||
# TODO sync across scripts
|
|
||||||
def tagrepr(tag, weight=None, size=None, off=None):
|
def tagrepr(tag, weight=None, size=None, off=None):
|
||||||
if (tag & 0x6fff) == TAG_NULL:
|
if (tag & 0x6fff) == TAG_NULL:
|
||||||
return '%snull%s%s' % (
|
return '%snull%s%s' % (
|
||||||
@@ -387,7 +385,7 @@ class Rbyd:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fetch(cls, data, block, trunk=None, cksum=None):
|
def fetch(cls, data, block, trunk=None, cksum=None):
|
||||||
# multiple blocks?
|
# multiple blocks? unfortunately this must be a list
|
||||||
if isinstance(block, list):
|
if isinstance(block, list):
|
||||||
# fetch all blocks
|
# fetch all blocks
|
||||||
rbyds = [cls.fetch(data, block, trunk, cksum) for block in block]
|
rbyds = [cls.fetch(data, block, trunk, cksum) for block in block]
|
||||||
|
|||||||
+13
-13
@@ -62,11 +62,11 @@ def fromleb128(data):
|
|||||||
return word, i+1
|
return word, i+1
|
||||||
return word, len(data)
|
return word, len(data)
|
||||||
|
|
||||||
def tagrepr(tag, w=None, size=None, off=None):
|
def tagrepr(tag, weight=None, size=None, off=None):
|
||||||
if (tag & 0x6fff) == TAG_NULL:
|
if (tag & 0x6fff) == TAG_NULL:
|
||||||
return '%snull%s%s' % (
|
return '%snull%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %d' % size if size else '')
|
' %d' % size if size else '')
|
||||||
elif (tag & 0x6f00) == TAG_CONFIG:
|
elif (tag & 0x6f00) == TAG_CONFIG:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -80,14 +80,14 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT
|
||||||
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT
|
||||||
else 'config 0x%02x' % (tag & 0xff),
|
else 'config 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_GDELTA:
|
elif (tag & 0x6f00) == TAG_GDELTA:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
'grmdelta' if (tag & 0xfff) == TAG_GRMDELTA
|
||||||
else 'gdelta 0x%02x' % (tag & 0xff),
|
else 'gdelta 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_NAME:
|
elif (tag & 0x6f00) == TAG_NAME:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -98,7 +98,7 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
|
||||||
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
else 'stickynote' if (tag & 0xfff) == TAG_STICKYNOTE
|
||||||
else 'name 0x%02x' % (tag & 0xff),
|
else 'name 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6f00) == TAG_STRUCT:
|
elif (tag & 0x6f00) == TAG_STRUCT:
|
||||||
return '%s%s%s%s' % (
|
return '%s%s%s%s' % (
|
||||||
@@ -113,21 +113,21 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
else 'did' if (tag & 0xfff) == TAG_DID
|
else 'did' if (tag & 0xfff) == TAG_DID
|
||||||
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
else 'branch' if (tag & 0xfff) == TAG_BRANCH
|
||||||
else 'struct 0x%02x' % (tag & 0xff),
|
else 'struct 0x%02x' % (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x6e00) == TAG_ATTR:
|
elif (tag & 0x6e00) == TAG_ATTR:
|
||||||
return '%s%sattr 0x%02x%s%s' % (
|
return '%s%sattr 0x%02x%s%s' % (
|
||||||
'shrub' if tag & TAG_SHRUB else '',
|
'shrub' if tag & TAG_SHRUB else '',
|
||||||
's' if tag & 0x100 else 'u',
|
's' if tag & 0x100 else 'u',
|
||||||
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
((tag & 0x100) >> 1) ^ (tag & 0xff),
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif tag & TAG_ALT:
|
elif tag & TAG_ALT:
|
||||||
return 'alt%s%s 0x%03x%s%s' % (
|
return 'alt%s%s 0x%03x%s%s' % (
|
||||||
'r' if tag & TAG_R else 'b',
|
'r' if tag & TAG_R else 'b',
|
||||||
'gt' if tag & TAG_GT else 'le',
|
'gt' if tag & TAG_GT else 'le',
|
||||||
tag & 0x0fff,
|
tag & 0x0fff,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' 0x%x' % (0xffffffff & (off-size))
|
' 0x%x' % (0xffffffff & (off-size))
|
||||||
if size and off is not None
|
if size and off is not None
|
||||||
else ' -%d' % size if size
|
else ' -%d' % size if size
|
||||||
@@ -136,27 +136,27 @@ def tagrepr(tag, w=None, size=None, off=None):
|
|||||||
return 'cksum%s%s%s%s' % (
|
return 'cksum%s%s%s%s' % (
|
||||||
'p' if not tag & 0xfe and tag & TAG_P else '',
|
'p' if not tag & 0xfe and tag & TAG_P else '',
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xfe else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_NOTE:
|
elif (tag & 0x7f00) == TAG_NOTE:
|
||||||
return 'note%s%s%s' % (
|
return 'note%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_ECKSUM:
|
elif (tag & 0x7f00) == TAG_ECKSUM:
|
||||||
return 'ecksum%s%s%s' % (
|
return 'ecksum%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
elif (tag & 0x7f00) == TAG_GCKSUMDELTA:
|
||||||
return 'gcksumdelta%s%s%s' % (
|
return 'gcksumdelta%s%s%s' % (
|
||||||
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
' 0x%02x' % (tag & 0xff) if tag & 0xff else '',
|
||||||
' w%d' % w if w else '',
|
' w%d' % weight if weight else '',
|
||||||
' %s' % size if size is not None else '')
|
' %s' % size if size is not None else '')
|
||||||
else:
|
else:
|
||||||
return '0x%04x%s%s' % (
|
return '0x%04x%s%s' % (
|
||||||
tag,
|
tag,
|
||||||
' w%d' % w if w is not None else '',
|
' w%d' % weight if weight is not None else '',
|
||||||
' %d' % size if size is not None else '')
|
' %d' % size if size is not None else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -80,10 +80,10 @@ def bdgeom(s):
|
|||||||
return int(s, b)
|
return int(s, b)
|
||||||
|
|
||||||
# parse some rbyd addr encodings
|
# parse some rbyd addr encodings
|
||||||
# 0xa -> (0xa,)
|
# 0xa -> [0xa]
|
||||||
# 0xa.c -> ((0xa, 0xc),)
|
# 0xa.c -> [(0xa, 0xc)]
|
||||||
# 0x{a,b} -> (0xa, 0xb)
|
# 0x{a,b} -> [0xa, 0xb]
|
||||||
# 0x{a,b}.c -> ((0xa, 0xc), (0xb, 0xc))
|
# 0x{a,b}.c -> [(0xa, 0xc), (0xb, 0xc)]
|
||||||
def rbydaddr(s):
|
def rbydaddr(s):
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
b = 10
|
b = 10
|
||||||
@@ -114,7 +114,7 @@ def rbydaddr(s):
|
|||||||
else:
|
else:
|
||||||
addr.append(int(s, b))
|
addr.append(int(s, b))
|
||||||
|
|
||||||
return tuple(addr)
|
return addr
|
||||||
|
|
||||||
|
|
||||||
class RingIO:
|
class RingIO:
|
||||||
|
|||||||
Reference in New Issue
Block a user