filename = 'experimental_' + filename.replace('experimental_', '')
return filename
-def StringIdentity(string):
+def StringIdentity(first, *more):
'''Creates a small hash of a string.
'''
- return b64encode(sha1(string).digest())[:8]
+ def encode(string):
+ return b64encode(sha1(string).digest())
+ identity = encode(first)
+ for m in more:
+ identity = encode(identity + m)
+ return identity[:8]
+
+def MarkFirst(dicts):
+ '''Adds a property 'first' == True to the first element in a list of dicts.
+ '''
+ if len(dicts) > 0:
+ dicts[0]['first'] = True
def MarkLast(dicts):
'''Adds a property 'last' == True to the last element in a list of dicts.
if len(dicts) > 0:
dicts[-1]['last'] = True
+def MarkFirstAndLast(dicts):
+ '''Marks the first and last element in a list of dicts.
+ '''
+ MarkFirst(dicts)
+ MarkLast(dicts)
+
def ToUnicode(data):
'''Returns the str |data| as a unicode object. It's expected to be utf8, but
there are also latin-1 encodings in there for some reason. Fall back to that.