Skip to content

Commit

Permalink
rename to_object to from_items
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Stewmon committed Sep 15, 2016
1 parent e34147c commit 3016b06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions jmespath/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ def _func_to_array(self, arg):
else:
return [arg]

@signature({'types': ['array']})
def _func_to_object(self, pairs):
return dict(pairs)

@signature({'types': []})
def _func_to_string(self, arg):
if isinstance(arg, STRING_TYPE):
Expand Down Expand Up @@ -288,6 +284,10 @@ def _func_sum(self, arg):
def _func_items(self, arg):
return list(map(list, iteritems(arg)))

@signature({'types': ['array']})
def _func_from_items(self, items):
return dict(items)

@signature({"types": ['object']})
def _func_keys(self, arg):
# To be consistent with .values()
Expand Down
10 changes: 5 additions & 5 deletions tests/compliance/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"empty_list": [],
"empty_hash": {},
"objects": {"foo": "bar", "bar": "baz"},
"pairs": [["a", "first"], ["b", "second"], ["c", "third"]],
"items": [["a", "first"], ["b", "second"], ["c", "third"]],
"null_key": null
},
"cases": [
Expand Down Expand Up @@ -184,6 +184,10 @@
"expression": "items(numbers)",
"error": "invalid-type"
},
{
"expression": "from_items(items)",
"result": {"a": "first", "b": "second", "c": "third"}
},
{
"expression": "length('abc')",
"result": 3
Expand Down Expand Up @@ -488,10 +492,6 @@
"expression": "to_array(false)",
"result": [false]
},
{
"expression": "to_object(pairs)",
"result": {"a": "first", "b": "second", "c": "third"}
},
{
"expression": "to_string('foo')",
"result": "foo"
Expand Down

0 comments on commit 3016b06

Please sign in to comment.