home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from hashlib import md5
- from collections import defaultdict
-
- class AttrChain(object):
-
- def __init__(self, name, parent):
- self.name = name
- self.parent = parent
-
-
- def __getattr__(self, attr):
- if attr == '_getAttributeNames':
- return False
-
- return None(AttrChain if self.name is not None else '' + attr, self.parent)
-
-
- def __call__(self, *a, **k):
- return self.parent(self.name, *a, **k)
-
-
- def __repr__(self):
- return '<AttrChain ' + self.name + '>'
-
-
-
- def signature(secret, **kw):
- return md5(''.join((lambda .0: for k, v in .0:
- '='.join((str(k), str(v))))(sorted(kw.items()))) + secret).hexdigest()
-
- from datetime import date
-
- def one_per_day(seq, key = (lambda o: o)):
- dates = { }
- for item in seq:
- val = key(item)
- d = date.fromtimestamp(val)
- if d not in dates or key(dates[d]) <= val:
- dates[d] = item
- continue
-
- return dates.values()
-
-
- def one_per_x_per_day(seq, x_key, time_key = (lambda o: o)):
- dates = defaultdict(dict)
- for item in seq:
- x = x_key(item)
- d = date.fromtimestamp(time_key(item))
- if x not in dates[d] or time_key(dates[d][x]) <= time_key(item):
- dates[d][x] = item
- continue
-
- return []([ d.values() for d in dates.itervalues() ], [])
-
-