Skip to content

Commit

Permalink
inflate_code_string now deals with new packing
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Whitman committed May 22, 2011
1 parent eec42cb commit 4307111
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions API/fp.py
Expand Up @@ -57,7 +57,7 @@ def match(self):
def inflate_code_string(s):
""" Takes an uncompressed code string consisting of 0-padded fixed-width
sorted hex and converts it to the standard code string."""
n = int(len(s) / 13.0) # 8 bytes for hash, 5 bytes for time
n = int(len(s) / 10.0) # 5 hex bytes for hash, 5 hex bytes for time (40 bits)

def pairs(l, n=2):
"""Non-overlapping [1,2,3,4] -> [(1,2), (3,4)]"""
Expand All @@ -73,7 +73,7 @@ def pairs(l, n=2):
# Parse out n groups of 5 timestamps in hex; then n groups of 8 hash codes in hex.
end_timestamps = n*5
times = [int(''.join(t), 16) for t in pairs(s[:end_timestamps], 5)]
codes = [int(''.join(t), 16) for t in pairs(s[end_timestamps:], 8)]
codes = [int(''.join(t), 16) for t in pairs(s[end_timestamps:], 5)]

assert(len(times) == len(codes)) # these should match up!
return ' '.join('%d %d' % (c, t) for c,t in zip(codes, times))
Expand Down

0 comments on commit 4307111

Please sign in to comment.