Пример #1
0
 def exit(path, key, old_parent, new_parent, new_items):
     ret = default_exit(path, key, old_parent, new_parent, new_items)
     try:
         ret['review_length'] = len(ret['review'])
     except:
         pass
     return ret
Пример #2
0
 def exit(path, key, old_parent, new_parent, new_items):
     ret = default_exit(path, key, old_parent, new_parent, new_items)
     try:
         ret['review_length'] = len(ret['review'])
     except:
         pass
     return ret
Пример #3
0
 def __noramlizeDoc(self, path, key, old_parent, new_parent, new_items):
     ret = default_exit(path, key, old_parent, new_parent, new_items)
     if "$oid" in ret:
         ret = ObjectId(ret["$oid"])
     elif "$date" in ret:
         ret = datetime.datetime.utcfromtimestamp(ret['$date'] / 1e3)
     return ret
Пример #4
0
 def exit(path, key, old_parent, new_parent, new_items):
     resp = iterutils.default_exit(path, key, old_parent,
                                   new_parent, new_items)
     if paths_to_keep_tagged and isinstance(resp, dict):
         for sub_key, value in resp.items():
             if not isinstance(value, list):
                 continue
             new_key = '{}@'.format(sub_key)
             resp[new_key] = value
         try:
             paths_to_keep_tagged.remove((path, key))
         except KeyError:
             pass
     return resp
Пример #5
0
 def exit(path, key, old_parent, new_parent, new_items):
     resp = iterutils.default_exit(path, key, old_parent,
                                   new_parent, new_items)
     if paths_to_keep_tagged and isinstance(resp, dict):
         for sub_key, value in resp.items():
             if not isinstance(value, list):
                 continue
             new_key = '{}@'.format(sub_key)
             resp[new_key] = value
         try:
             paths_to_keep_tagged.remove((path, key))
         except KeyError:
             pass
     return resp
Пример #6
0
def map_values(mapping, path, key, old_parent, new_parent, new_items):
    ret = default_exit(path, key, old_parent, new_parent, new_items)
    for k, v in ret.items():
        if isinstance(v, Hashable) and v in mapping:
            ret[k] = mapping[v]
    return ret
Пример #7
0
 def exit(path, key, old_parent, new_parent, new_items):
     # NB: in this case, I'd normally use *a, **kw
     ret = default_exit(path, key, old_parent, new_parent, new_items)
     if isinstance(ret, list):
         ret.sort()
     return ret
Пример #8
0
 def exit(path, key, old_parent, new_parent, new_items):
     if old_parent is target_set:
         path_map['target_set'] = path + (key,)
     return default_exit(path, key, old_parent, new_parent, new_items)
Пример #9
0
 def exit(path, key, old_parent, new_parent, new_items):
     # NB: in this case, I'd normally use *a, **kw
     ret = default_exit(path, key, old_parent, new_parent, new_items)
     if isinstance(ret, list):
         ret.sort()
     return ret
Пример #10
0
 def exit(path, key, old_parent, new_parent, new_items):
     if old_parent is target_set:
         path_map['target_set'] = path + (key, )
     return default_exit(path, key, old_parent, new_parent, new_items)