How to use the dpath.util.delete function in dpath

To help you get started, we’ve selected a few dpath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akesterson / dpath-python / tests / test_util_delete.py View on Github external
def test_delete_missing():
    dict = {
        "a": {
            }
        }
    dpath.util.delete(dict, '/a/b')
github akesterson / dpath-python / tests / test_types.py View on Github external
def test_delete_filter():
    def afilter(x):
        if int(x) == 31:
            return True
        return False

    data = TestMapping({
        "a": TestMapping({
            "b": 0,
            "c": 1,
            "d": 31
        })
    })
    dpath.util.delete(data, '/a/*', afilter=afilter)
    assert (data['a']['b'] == 0)
    assert (data['a']['c'] == 1)
    assert ('d' not in data['a'])
github akesterson / dpath-python / tests / test_util_delete.py View on Github external
def test_delete_separator():
    dict = {
        "a": {
            "b": 0
            }
        }
    dpath.util.delete(dict, ';a;b', separator=";")
    assert(not 'b' in dict['a'])
github akesterson / dpath-python / tests / test_util_delete.py View on Github external
def test_delete_filter():
    def afilter(x):
        if int(x) == 31:
            return True
        return False

    dict = {
        "a": {
            "b": 0,
            "c": 1,
            "d": 31
            }
        }
    dpath.util.delete(dict, '/a/*', afilter=afilter)
    assert (dict['a']['b'] == 0)
    assert (dict['a']['c'] == 1)
    assert ('d' not in dict['a'])
github Netflix / security_monkey / security_monkey / datastore.py View on Github external
def durable_hash(self, item, ephemeral_paths):
        """
        Remove all ephemeral paths from the item and return the hash of the new structure.

        :param item: dictionary, representing an item tracked in security_monkey
        :return: hash of the sorted json dump of the item with all ephemeral paths removed.
        """
        durable_item = deepcopy(item)
        if ephemeral_paths:
            for path in ephemeral_paths:
                try:
                    dpath.util.delete(durable_item, path, separator='$')
                except PathNotFound:
                    pass
        return self.hash_config(durable_item)
github Netflix / security_monkey / migrations / versions / bfb550a500ab_.py View on Github external
def durable_hash(item, ephemeral_paths):
    """
    Remove all ephemeral paths from the item and return the hash of the new structure.

    :param item: dictionary, representing an item tracked in security_monkey
    :return: hash of the sorted json dump of the item with all ephemeral paths removed.
    """
    durable_item = deepcopy(item)
    for path in ephemeral_paths:
        try:
            dpath.util.delete(durable_item, path, separator='$')
        except PathNotFound:
            pass
    return hash_config(durable_item)
github datawire / ambassador / unused-e2e / yfix.py View on Github external
path = element[0]
            self.set(manifest, x, path, {})

        for element in self.elements.get('set', []):
            path, value = element
            self.set(manifest, x, path, args.interpolate(value))

        for element in self.elements.get('setint', []):
            path, value = element
            self.set(manifest, x, path, int(value))

        for element in self.elements.get('delete', []):
            path = element[0]
            qualified = '/%d/%s' % (x, path)
            logging.debug("DEL %s" % qualified)
            dpath.util.delete(manifest, qualified)

        return True