diff --git a/manipulator/get.py b/manipulator/get.py index ae9a5b1..8ed4c50 100644 --- a/manipulator/get.py +++ b/manipulator/get.py @@ -1,6 +1,13 @@ from manipulator.query import treat_query def get(data, query): + """traverses data based on the query. + + - params: + - data: the input to traverse + - query: the rules for traversal + - complexity: determined by the complexity of the query + - returns: the data found at the leaves of the traversal""" selectors = treat_query(query) for selector in selectors: diff --git a/manipulator/update.py b/manipulator/update.py index 6305ca1..1469cb0 100644 --- a/manipulator/update.py +++ b/manipulator/update.py @@ -3,6 +3,15 @@ import copy from manipulator.query import treat_query def update(inpt, query, fn, in_place=True): + """transforms data based on the query dynamically. + + - params: + - data: the input to transform + - query: the rules for traversal + - fn: a transformation function for the leaves + - in_place: determines whether we should perform the transformations in place (True per default) + - complexity: determined by the complexity of the query + - returns: the transformed data""" if in_place: data = inpt else: @@ -31,4 +40,13 @@ def update(inpt, query, fn, in_place=True): def set(inpt, query, val, in_place=True): + """transforms data based on the query statically. + + - params: + - data: the input to transform + - query: the rules for traversal + - val: the value to which the leaves should be set + - in_place: determines whether we should perform the transformations in place (True per default) + - complexity: determined by the complexity of the query + - returns: the transformed data""" return update(inpt, query, lambda _: val, in_place)