Fixing CI for python version 2.7
This commit is contained in:
parent
fdce9e685a
commit
652ab9882d
2 changed files with 25 additions and 18 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
- "3.5"
|
|
||||||
- "3.6"
|
- "3.6"
|
||||||
|
- "3.7"
|
||||||
# command to install dependencies
|
# command to install dependencies
|
||||||
install:
|
install:
|
||||||
- pip install .
|
- pip install .
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ from six import iteritems
|
||||||
from nested_lookup import nested_lookup
|
from nested_lookup import nested_lookup
|
||||||
|
|
||||||
|
|
||||||
def nested_delete(document, key: str, in_place: bool = False):
|
def nested_delete(document, key, in_place=False):
|
||||||
if not in_place:
|
if not in_place:
|
||||||
document = copy.deepcopy(document)
|
document = copy.deepcopy(document)
|
||||||
return _nested_delete(document=document, key=key)
|
return _nested_delete(document=document, key=key)
|
||||||
|
|
||||||
|
|
||||||
def _nested_delete(document, key: str) -> dict:
|
def _nested_delete(document, key):
|
||||||
"""
|
"""
|
||||||
Method to delete a key->value pair from a nested document
|
Method to delete a key->value pair from a nested document
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -31,9 +31,9 @@ def _nested_delete(document, key: str) -> dict:
|
||||||
return document
|
return document
|
||||||
|
|
||||||
|
|
||||||
def nested_update(document, key: str, value: object,
|
def nested_update(
|
||||||
in_place: bool = False,
|
document, key, value, in_place=False, treat_as_element=True
|
||||||
treat_as_element: bool = True):
|
):
|
||||||
"""
|
"""
|
||||||
Method to update a key->value pair in a nested document
|
Method to update a key->value pair in a nested document
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -74,8 +74,9 @@ def nested_update(document, key: str, value: object,
|
||||||
val_len=val_len)
|
val_len=val_len)
|
||||||
|
|
||||||
|
|
||||||
def _nested_update(document, key: str, value: object,
|
def _nested_update(
|
||||||
val_len: int, run: int = 0):
|
document, key, value, val_len, run=0
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Method to update a key->value pair in a nested document
|
Method to update a key->value pair in a nested document
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -113,9 +114,10 @@ def _nested_update(document, key: str, value: object,
|
||||||
return document
|
return document
|
||||||
|
|
||||||
|
|
||||||
def nested_alter(document, key: str, callback_function=None,
|
def nested_alter(
|
||||||
function_parameters: list = None, conversion_function=None,
|
document, key, callback_function=None, function_parameters=None,
|
||||||
wild_alter: bool = False, in_place: bool = True):
|
conversion_function=None, wild_alter=False, in_place=True
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Method to alter all values of the occurences of the key "key".
|
Method to alter all values of the occurences of the key "key".
|
||||||
The provided callback_function is used to alter the scalar values
|
The provided callback_function is used to alter the scalar values
|
||||||
|
|
@ -134,7 +136,7 @@ def nested_alter(document, key: str, callback_function=None,
|
||||||
"callback_function"
|
"callback_function"
|
||||||
wild_alter: Find matching elements via wild-match by the given keys
|
wild_alter: Find matching elements via wild-match by the given keys
|
||||||
and alter those.
|
and alter those.
|
||||||
HINT: Keep in mind that the wild-match might return unexpected types!
|
HINT: Keep in mind that the wild-match might return unexpected types!
|
||||||
in_place (bool):
|
in_place (bool):
|
||||||
True: modify the dict in place;
|
True: modify the dict in place;
|
||||||
False: create a deep copy of the dict and modify it
|
False: create a deep copy of the dict and modify it
|
||||||
|
|
@ -161,8 +163,10 @@ def nested_alter(document, key: str, callback_function=None,
|
||||||
in_place=in_place, key_len=key_len)
|
in_place=in_place, key_len=key_len)
|
||||||
|
|
||||||
|
|
||||||
def _call_callback(value_list: list, callback_function,
|
def _call_callback(
|
||||||
function_parameters: list, conversion_function):
|
value_list, callback_function, function_parameters,
|
||||||
|
conversion_function
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
internal helper to call the callback function
|
internal helper to call the callback function
|
||||||
"""
|
"""
|
||||||
|
|
@ -183,9 +187,10 @@ def _call_callback(value_list: list, callback_function,
|
||||||
return return_list
|
return return_list
|
||||||
|
|
||||||
|
|
||||||
def _nested_alter(document, keys, callback_function,
|
def _nested_alter(
|
||||||
function_parameters: list, conversion_function,
|
document, keys, callback_function, function_parameters,
|
||||||
wild_alter: bool, in_place: bool, key_len: int):
|
conversion_function, wild_alter, in_place, key_len
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
# return data if no callback_function is provided
|
# return data if no callback_function is provided
|
||||||
|
|
@ -196,7 +201,9 @@ def _nested_alter(document, keys, callback_function,
|
||||||
# iterate over all given keys in the list
|
# iterate over all given keys in the list
|
||||||
for key in keys:
|
for key in keys:
|
||||||
# try to find the key:
|
# try to find the key:
|
||||||
findings = nested_lookup(key, document, with_keys=True, wild=wild_alter)
|
findings = nested_lookup(
|
||||||
|
key, document, with_keys=True, wild=wild_alter
|
||||||
|
)
|
||||||
for k, v in findings.items():
|
for k, v in findings.items():
|
||||||
trans_val = _call_callback(v, callback_function,
|
trans_val = _call_callback(v, callback_function,
|
||||||
function_parameters,
|
function_parameters,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue