From e90dba067e912ad65e5d7c0d519a5d97ed5f89d4 Mon Sep 17 00:00:00 2001 From: Alexander Shorin Date: Sat, 16 Jun 2012 23:30:57 +0400 Subject: [PATCH] Add arguments description to docstrings. --- jsonpatch.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/jsonpatch.py b/jsonpatch.py index 3b2d8f3..25d04d4 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -64,19 +64,42 @@ class JsonPatchConflict(JsonPatchException): def apply_patch(doc, patch, in_place=False): """Apply list of patches to specified json document. + :param doc: Document object. + :type doc: dict + + :param patch: JSON patch as list of dicts. + :type patch: list + + :param in_place: While :const:`True` patch will modify target document. + By default patch will be applied to document copy. + :type in_place: bool + + :return: Patched document object. + :rtype: dict + >>> doc = {'foo': 'bar'} >>> other = apply_patch(doc, [{'add': '/baz', 'value': 'qux'}]) >>> doc is not other True >>> other {'foo': 'bar', 'baz': 'qux'} + >>> apply_patch(doc, [{'add': '/baz', 'value': 'qux'}], in_place=True) + {'foo': 'bar', 'baz': 'qux'} + >>> doc == other + True """ patch = JsonPatch(patch) return patch.apply(doc, in_place) def make_patch(src, dst): - """Generates patch by comparing of two objects. + """Generates patch by comparing of two document objects. + + :param src: Data source document object. + :type src: dict + + :param dst: Data source document object. + :type dst: dict >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]} >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}