Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions glom/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ def glomit(self, target, scope):
return target


class Update(object):
"""
Update a dict or set without otherwise modifying.
This allows dict creation to be broken into "chunks".

({'a': 'a'}, [dict, Update({'b': 'b', 'c': 'c'})])
"""
def __init__(self, subspec):
assert type(subspec) in (dict, set, frozenset)
self.subspec = subspec

def glomit(self, target, scope):
assert hasattr(target, 'update')
target.update(scope[glom](target, self.subspec, scope))
return target


def assign(obj, path, val, missing=None):
"""The ``assign()`` function provides convenient "deep set"
functionality, modifying nested data structures in-place::
Expand Down