dpath/util.py
def delete(obj, glob, separator="/", afilter=None):
    """
    Given a path glob, delete all elements that match the glob.

    Returns the number of deleted objects. Raises PathNotFound if no paths are
    found to delete.
    """
    deleted = 0
    paths = []
    for path in _inner_search(obj, glob.lstrip(separator).split(separator), separator):
        # These are yielded back, don't mess up the dict.
        paths.append(path)

    for path in paths:
        cur = obj
        prev = None
        for item in path:
            prev = cur
            try:
                cur = cur[item[0]]
            except AttributeError as e:
                # This only happens when we delete X/Y and the next
                # item in the paths is X/Y/Z
                pass
        if (not afilter) or (afilter and afilter(prev[item[0]])):
            prev.pop(item[0])
        deleted += 1
    if not deleted:
        raise dpath.exceptions.PathNotFound("Could not find {} to delete it".format(glob))
    return deleted

    Given a path glob, delete all elements that match the glob.

    Returns the number of deleted objects. Raises PathNotFound if no paths are
    found to delete.
    
Given a path glob, delete all elements that match the glob.
Returns the number of deleted objects. Raises PathNotFound if no paths are
found to delete.
Given a path glob delete all elements that match the glob . Returns the number of deleted objects . Raises PathNotFound if no paths are found to delete .
def delete(obj, glob, separator="/", afilter=None):
    deleted = 0
    paths = []
    for path in _inner_search(obj, glob.lstrip(separator).split(separator), separator):
        paths.append(path)
    for path in paths:
        cur = obj
        prev = None
        for item in path:
            prev = cur
            try:
                cur = cur[item[0]]
            except AttributeError as e:
                pass
        if (not afilter) or (afilter and afilter(prev[item[0]])):
            prev.pop(item[0])
        deleted += 1
    if not deleted:
        raise dpath.exceptions.PathNotFound("Could not find {} to delete it".format(glob))
    return deleted
def delete ( obj , glob , separator = "/" , afilter = None ) : deleted = 0 paths = [ ] for path in _inner_search ( obj , glob . lstrip ( separator ) . split ( separator ) , separator ) : paths . append ( path ) for path in paths : cur = obj prev = None for item in path : prev = cur try : cur = cur [ item [ 0 ] ] except AttributeError as e : pass if ( not afilter ) or ( afilter and afilter ( prev [ item [ 0 ] ] ) ) : prev . pop ( item [ 0 ] ) deleted += 1 if not deleted : raise dpath . exceptions . PathNotFound ( "Could not find {} to delete it" . format ( glob ) ) return deleted
Given a path glob, delete all elements that match the glob.
Given a path glob delete all elements that match the glob .
"""
    Given a path glob, delete all elements that match the glob.

    Returns the number of deleted objects. Raises PathNotFound if no paths are
    found to delete.
    """ # These are yielded back, don't mess up the dict. # This only happens when we delete X/Y and the next # item in the paths is X/Y/Z
obj
glob
separator
afilter