Esempio n. 1
0
 def enter(path, key, value):
     new_parent, new_items = default_enter(path, key, value)
     try:
         new_parent.update(base_obj)
         base_obj['id'] += 1
     except:
         pass
     return new_parent, new_items
Esempio n. 2
0
    def _enter(path, key, value):
        # Do not traverse types defined in compare_funcs. All other types are handled
        # like in boltons.iterutils.default_enter (e.g. descend into nested structures).
        # See `boltons.iterutils.remap` for details.
        if any(isinstance(value, t) for t in _Eq_compare_nested.compare_funcs):
            return value, False

        return iterutils.default_enter(path, key, value)
Esempio n. 3
0
 def enter(path, key, value):
     new_parent, new_items = default_enter(path, key, value)
     try:
         new_parent.update(base_obj)
         base_obj['id'] += 1
     except:
         pass
     return new_parent, new_items
Esempio n. 4
0
def enter(path, key, value):
    if isinstance(value, BaseDict):
        return dict(), value.items()
    elif isinstance(value, list):
        dot_path = delimiter.join(list(path) + [key])
        raise ValidationError(f"lists not allowed ({dot_path})!")

    return default_enter(path, key, value)
Esempio n. 5
0
 def _dover_enter(p, k, v):
     ret = default_enter(p, k, v)
     if k == None:
         return ret
     try:
         n = get_path(config, p)
         if (k not in n):
             n[k] = v
             return (ret[0], False)
     except:
         pass
     return ret
Esempio n. 6
0
    def remerge_enter(path, key, value):
        new_parent, new_items = default_enter(path, key, value)
        if ret and not path and key is None:
            new_parent = ret
        try:
            # TODO: type check?
            new_parent = get_path(ret, path + (key,))
        except KeyError:
            pass

        if isinstance(value, list):
            # lists are purely additive. See https://github.com/mahmoud/boltons/issues/81
            new_parent.extend(value)
            new_items = []

        return new_parent, new_items
Esempio n. 7
0
 def enter(path, key, value):
     curr = SarTransform.__path(path, key)
     if curr is '/':
         result[curr] = {
             SarBase.PROPERTY: value.pop('@', {}),
             SarBase.TYPE: value.pop('$', {})
         }
     else:
         prev = SarTransform.__path(path, None)
         #
         result[prev].update({SarBase.CHILDREN: {curr: value['$']}})
         #
         result[curr] = {
             SarBase.PROPERTY: value.pop('@', {}),
             SarBase.TYPE: value.pop('$', {}),
             SarBase.PARENT: {
                 prev: result[prev]['$']
             }
         }
     #
     return default_enter(path, key, value)
Esempio n. 8
0
 def enter(path, key, value):
     try:
         all_interests.update(value['interests'])
     except:
         pass
     return default_enter(path, key, value)
Esempio n. 9
0
 def enter(path, key, value):
     if isinstance(value, dict):
         return OMD(), sorted(value.items())
     return default_enter(path, key, value)
Esempio n. 10
0
 def enter(path, key, value):
     if value is target_obj:
         path_map['target_obj'] = path + (key,)
     return default_enter(path, key, value)
Esempio n. 11
0
 def enter_adapter(path, key, value):
     if path or key is not None:  # path=() key=None is root
         handler(path + (key,), value)
     return iterutils.default_enter(path, key, value)
Esempio n. 12
0
 def enter(path, key, value):
     if isinstance(value, dict):
         return OMD(), sorted(value.items())
     return default_enter(path, key, value)
Esempio n. 13
0
 def enter(path, key, value):
     if value is target_obj:
         path_map['target_obj'] = path + (key, )
     return default_enter(path, key, value)
Esempio n. 14
0
 def _remap_enter_constructor(cls, p, k, v):
     """Determines which nodes to visit. The default_enter points to leaf nodes.
     This additionally looks for Ctor.CONSTRUCTOR nodes."""
     if k == Ctor.CONSTRUCTOR:
         return p, False
     return default_enter(p, k, v)
Esempio n. 15
0
 def enter(path, key, value):
     if not cls.is_python_to_json_basic_type(
             value) and key != Ctor.CONSTRUCTOR:
         return path, False
     else:
         return default_enter(path, key, value)
Esempio n. 16
0
 def enter(path, key, value):
     if cls.is_ctor_dict(value):
         return path, False
     else:
         return default_enter(path, key, value)
Esempio n. 17
0
def enter(path, key, value):
    if isinstance(value, BaseDict):
        return dict(), value.items()
    return default_enter(path, key, value)
Esempio n. 18
0
 def enter(path, key, value):
     try:
         all_interests.update(value['interests'])
     except:
         pass
     return default_enter(path, key, value)