Commit 25bc0037 authored by Cage, Marshall Andrew's avatar Cage, Marshall Andrew
Browse files

Fix Glob.fromNum in glob construction

lc wasn't being shifted two bits over, idk how I missed that. Also
sub was using the wrong two bits (and even those weren't shifted
properly.) Super hard to spot after you've left it alone for a bit,
no pun intended.

Complete Glob serialisation in emailscrapebasic with extras
parent b70bf6d5
......@@ -35,10 +35,13 @@ class Plugin(arcclasses.Plugin):
self.contexts = ['Date']
self.emails = []
# Map group names to a map of email objects to a list of cursor
# location tupples ;P
self.groups = {}
self.fetched = False
self.groupColors = [] #https://en.wikipedia.org/wiki/Web_colors
self.currentGroup = None
# Map group names to glob items
self.items = {}
self.fragments = {}
......@@ -130,6 +133,14 @@ class Plugin(arcclasses.Plugin):
if 'groups' in self.extras and self.extras['groups'] != '':
for g in self.extras['groups'].split(','):
self.addGroup(g)
if 'globs' in self.extras:
globs = self.extras['globs'].split(',')
self.items = {}
for g in globs:
group, num = g.split(':')
if group not in self.items:
self.items[group] = GlobItem()
self.items[group] + Glob.fromNum(num)
#needed
def storeOptions(self):
......@@ -147,6 +158,13 @@ class Plugin(arcclasses.Plugin):
self.extras['filters'] = self.widget.emailFilterTable.serialize()
self.extras['format'] = self.widget.formatEdit.toHtml()
self.extras['groups'] = ','.join(self.groups.keys())
self.constructItems()
globs = []
for group in self.items:
for glob in self.items[group].globs:
globs.append('%s:%s' %(group,glob))
self.extras['globs'] = ','.join(globs)
#override
def generate(self):
......@@ -481,7 +499,8 @@ class Plugin(arcclasses.Plugin):
body += (part.get_payload(decode=True)
.decode('utf-8'))
except UnicodeDecodeError:
body += (quopri.decodestring(part.get_payload())
body += (quopri.decodestring(
part.get_payload())
.decode('utf-8'))
doc.setHtml(body)
curs = []
......
......@@ -32,7 +32,7 @@ class Glob(object):
self.wc = 1 # Word count
self.lc = 1 # Line count
self.dev = 0.0 # Deviation (stdev/mean)
self.num = '0'*12 # Unique number, independent of text. 96 bits
self.num = '0'*24 # Unique number, independent of text. 96 bits
if len(curs) > 0:
# print(curs)
self.setValue(*curs)
......@@ -61,21 +61,21 @@ class Glob(object):
g.cla = int(num[13],16) >> 2
g.sub = int(num[13],16) & 0xc
g.sub = int(num[13],16) & 0x3
g.cov = int(num[14:17],16) >> 2
g.cov /= 1000.
g.wc = int(num[16:19],16) & 0x3ff
g.lc = int(num[19:22],16) & 0xffc
g.lc = int(num[19:22],16) >> 2
g.dev = int(num[21:],16) & 0x3ff
g.dev /= 1000.
g.calc()
if g.num != num:
print("messed up")
print("messed up", g.num, num)
return None
return g
......@@ -90,25 +90,31 @@ class Glob(object):
b = (self.end[0] & 65535)
# All 10 bits from sta1, upper 6 bits from end1
c = (int(self.sta[1]*1000) & 0x3ff) << 6
c |= (int(self.end[1]*1000) & 0x3ff) >> 4
# Lower 4 bits from end1, both bits from cla, both bits from sub,
# upper 8 bits from cov
d = (int(self.end[1]*1000) & 0xf) << 12
d |= (self.cla & 3) << 10
d |= (self.sub & 3) << 8
d |= (int(self.cov*1000) & 0x3ff) >> 2
# Lower 2 bits from cov, all 10 bits from wc, upper 4 bits from lc
e = (int(self.cov*1000) & 0x3) << 14
e |= (self.wc & 0x3ff) << 4
e |= (self.lc & 0x3ff) >> 6
# Lower 6 bits from lc, all 10 bits from dev
f = (self.lc & 0x3f) << 10
f |= (int(self.dev*1000) & 0x3ff)
# Easier this way to make a long hex string
byt = bytearray(12)
byt[0] = a >> 8
byt[1] = a & 0xff
byt[2] = b >> 8
byt[0] = a >> 8 # upper 8 = first character
byt[1] = a & 0xff # lower 8 = second character
byt[2] = b >> 8 # ...
byt[3] = b & 0xff
byt[4] = c >> 8
byt[5] = c & 0xff
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment