Skip to content

Commit

Permalink
Revert 31dd471
Browse files Browse the repository at this point in the history
  • Loading branch information
somewes committed Nov 6, 2015
1 parent 31dd471 commit 7dcca16
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: python
python:
- '2.7'
- '3.2'
- '3.3'
- '3.4'
- '3.5'
install:
- pip install coveralls flake8 nose>=1.3.0
- python setup.py install
Expand Down
4 changes: 0 additions & 4 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Release Notes
=============

v0.1.5
------
* Added a method to get a set of all field keys used in a kmatch pattern

v0.1.3
------
* Added KmatchTestMixin for tests
Expand Down
27 changes: 0 additions & 27 deletions kmatch/kmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,30 +152,3 @@ def match(self, value):
suppress_key_errors class variable is False
"""
return self._match(self._compiled_pattern, value)

def get_field_keys(self, pattern=None):
"""
Builds a set of all field keys used in the pattern including nested fields.
:param pattern: The kmatch pattern to get field keys from or None to use self.pattern
:type pattern: list or None
:returns: A set object of all field keys used in the pattern
:rtype: set
"""
# Use own pattern or passed in argument for recursion
pattern = pattern or self.pattern
keys = set()

# Valid pattern length can only be 2 or 3
if len(pattern) == 2:
if pattern[0] in ('&', '|', '^'):
# Pass each nested pattern to get_field_keys
for filter_item in pattern[1]:
keys = keys.union(self.get_field_keys(filter_item))
else:
# pattern[0] == '!'
keys = keys.union(self.get_field_keys(pattern[1]))
else:
# Pattern length is 3
keys.add(pattern[1])
return keys
21 changes: 0 additions & 21 deletions kmatch/tests/kmatch_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,27 +225,6 @@ def test_xor_false(self):
]).match({'email': 'opensource@ambition.com',
'e-mail': 'opensource@ambition.com'}))

def test_get_field_keys(self):
"""
Verifies that all field keys are returned
"""
pattern = ['&', [
['=~', 'one', 'one value'],
['=~', 'two', 'two value'],
['|', [
['=~', 'three', 'three value'],
['!', ['=~', 'one', 'other one value']],
['^', [
['==', 'five', 'five value'],
['==', 'five', 'five value']
]],
['&', [
['=~', 'four', 'four value'],
]]
]],
]]
self.assertEqual(K(pattern).get_field_keys(), set(['one', 'two', 'three', 'four', 'five']))


class KInitTest(TestCase):
"""
Expand Down
2 changes: 1 addition & 1 deletion kmatch/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.5'
__version__ = '0.1.4'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def get_version():
packages=find_packages(),
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
Expand Down

0 comments on commit 7dcca16

Please sign in to comment.