Skip to content

Commit

Permalink
Rewrote "parameters" sections using keywords.
Browse files Browse the repository at this point in the history
The following changes were also made to match the new style:
- Rephrased "key" description in both functions because saying
"list of keys" about a variable which is explicitly defined
as "str" in the next line is confusing.
- Removed type highlights from nestedKeys() description.
  • Loading branch information
Evildoor committed Sep 12, 2018
1 parent 03ea3cf commit 522e789
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Utils/Dataflow/pyDKB/common/json_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ def valueByKey(json_data, key):
nested in other dictionaries -- this function extracts the data from
such constructions according to given string or list with keys.
**Parameters:**
DICT json_data -- to search in
:param json_data: to search in
:type json_data: dict
:param key: nested keys
:type key: str
STRING key -- dot-separated list of nested keys
:return: value (None if failed)
:rtype: depends on value, NoneType
"""
nested_keys = nestedKeys(key)
val = json_data
Expand All @@ -50,13 +53,16 @@ def valueByKey(json_data, key):


def nestedKeys(key):
""" Transform STRING with nested keys into LIST.
""" Transform string with nested keys into list.
**Parameters:**
STRING key -- dot-separated list of nested keys.
If a key contains dot itself, the key must be put
between quotation marks.
String should contain keys separated by dot. If a key contains
dot itself, the key must be put between matching quotation marks.
:param key: nested keys
:type key: str
:return: nested keys
:rtype: list
"""
if type(key) == list:
return key
Expand Down

0 comments on commit 522e789

Please sign in to comment.