GeezerVison is showing github.com — Merge pull request #77 from seperman/dev · sreecodeslayer/deepdiff@103a201
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +14-10Lines changed: 14 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | Authors: | 2 | | - * Seperman | 3 | | - * Victor Hahn Castell @ Flexoptix | | 2 | +- Seperman | | 3 | +- Victor Hahn Castell @ Flexoptix | 4 | 4 |
| 5 | 5 | Also thanks to: | 6 | | - * nfvs for Travis-CI setup script. | 7 | | - * brbsix for initial Py3 porting. | 8 | | - * WangFenjin for unicode support. | 9 | | - * timoilya for comparing list of sets when ignoring order. | 10 | | - * Bernhard10 for significant digits comparison. | 11 | | - * b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings. | 12 | | - * finnhughes for fixing __slots__ | 13 | | - * moloney for Unicode vs. Bytes default | | 6 | +- nfvs for Travis-CI setup script. | | 7 | +- brbsix for initial Py3 porting. | | 8 | +- WangFenjin for unicode support. | | 9 | +- timoilya for comparing list of sets when ignoring order. | | 10 | +- Bernhard10 for significant digits comparison. | | 11 | +- b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings. | | 12 | +- finnhughes for fixing __slots__ | | 13 | +- moloney for Unicode vs. Bytes default | | 14 | +- serv-inc for adding help(deepdiff) | | 15 | +- movermeyer for updating docs | | 16 | +- maxrothman for search in inherited class attributes | | 17 | +- maxrothman for search for types/objects |
Collapse file Copy file name to clipboardExpand all lines: README.md +9-3Lines changed: 9 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -# deepdiff v 3.2.1 | | 1 | +# deepdiff v 3.3.0 | 2 | 2 |
| 3 | 3 | [](https://gitter.im/deepdiff/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | 4 | 4 | <!--  --> | @@ -788,12 +788,14 @@ I was honored to give a talk about how DeepDiff does what it does at Pycon 2016. | 788 | 788 | And here is more info: <http://zepworks.com/blog/diff-it-to-digg-it/> | 789 | 789 |
| 790 | 790 |
| 791 | | -##Documentation | | 791 | +## Documentation | 792 | 792 |
| 793 | 793 | <http://deepdiff.readthedocs.io/en/latest/> | 794 | 794 |
| 795 | | -##Changelog | | 795 | +## Change log | 796 | 796 |
| | 797 | +- v3-3-0: Searching for objects and class attributes | | 798 | +- v3-2-2: Adding help(deepdiff) | 797 | 799 | - v3-2-1: Fixing hash of None | 798 | 800 | - v3-2-0: Adding grep for search: object | grep(item) | 799 | 801 | - v3-1-3: Unicode vs. Bytes default fix | @@ -845,3 +847,7 @@ Also thanks to: | 845 | 847 | - b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings. | 846 | 848 | - finnhughes for fixing __slots__ | 847 | 849 | - moloney for Unicode vs. Bytes default | | 850 | +- serv-inc for adding help(deepdiff) | | 851 | +- movermeyer for updating docs | | 852 | +- maxrothman for search in inherited class attributes | | 853 | +- maxrothman for search for types/objects |
Collapse file Copy file name to clipboardExpand all lines: README.txt +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -**DeepDiff v 3.2.1** | | 1 | +**DeepDiff v 3.3.0** | 2 | 2 |
| 3 | 3 | Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes. | 4 | 4 |
| @@ -240,6 +240,8 @@ http://zepworks.com/blog/diff-it-to-digg-it/ | 240 | 240 |
| 241 | 241 | **Changelog** | 242 | 242 |
| | 243 | +- v3-3-0: Searching for objects and class attributes | | 244 | +- v3-2-2: Adding help(deepdiff) | 243 | 245 | - v3-2-1: Fixing hash of None | 244 | 246 | - v3-2-0: Adding grep for search: object | grep(item) | 245 | 247 | - v3-1-3: Unicode vs. Bytes default fix | @@ -291,3 +293,7 @@ Also thanks to: | 291 | 293 | - b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings. | 292 | 294 | - finnhughes for fixing __slots__ | 293 | 295 | - moloney for Unicode vs. Bytes default | | 296 | +- serv-inc for adding help(deepdiff) | | 297 | +- movermeyer for updating docs | | 298 | +- maxrothman for search in inherited class attributes | | 299 | +- maxrothman for search for types/objects |
Collapse file Copy file name to clipboardExpand all lines: deepdiff/search.py +10-1Lines changed: 10 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,6 +127,13 @@ def __search_obj(self, | 127 | 127 | parents_ids=frozenset({}), | 128 | 128 | is_namedtuple=False): | 129 | 129 | """Search objects""" | | 130 | + found = False | | 131 | + if obj == item: | | 132 | + found = True | | 133 | + # We report the match but also continue inside the match to see if there are | | 134 | + # furthur matches inside the `looped` object. | | 135 | + self.__report(report_key='matched_values', key=parent, value=obj) | | 136 | + | 130 | 137 | try: | 131 | 138 | if is_namedtuple: | 132 | 139 | obj = obj._asdict() | @@ -139,7 +146,9 @@ def __search_obj(self, | 139 | 146 | try: | 140 | 147 | obj = {i: getattr(obj, i) for i in obj.__slots__} | 141 | 148 | except AttributeError: | 142 | | - self['unprocessed'].append("%s" % parent) | | 149 | + if not found: | | 150 | + self['unprocessed'].append("%s" % parent) | | 151 | + | 143 | 152 | return | 144 | 153 |
| 145 | 154 | self.__search_dict( | |
Collapse file Copy file name to clipboardExpand all lines: docs/conf.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 60 | 60 | # built documents. | 61 | 61 | # | 62 | 62 | # The short X.Y version. | 63 | | -version = '3.2.1' | | 63 | +version = '3.3.0' | 64 | 64 | # The full version, including alpha/beta/rc tags. | 65 | | -release = '3.2.1' | | 65 | +release = '3.3.0' | 66 | 66 |
| 67 | 67 | # The language for content autogenerated by Sphinx. Refer to documentation | 68 | 68 | # for a list of supported languages. | |
Collapse file Copy file name to clipboardExpand all lines: docs/index.rst +3-1Lines changed: 3 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | You can adapt this file completely to your liking, but it should at least | 4 | 4 | contain the root `toctree` directive. | 5 | 5 |
| 6 | | -DeepDiff 3.2.1 documentation! | | 6 | +DeepDiff 3.3.0 documentation! | 7 | 7 | ============================= | 8 | 8 |
| 9 | 9 | **DeepDiff: Deep Difference of dictionaries, iterables and almost any other object recursively.** | @@ -346,6 +346,8 @@ Indices and tables | 346 | 346 | Changelog | 347 | 347 | ========= | 348 | 348 |
| | 349 | +- v3-3-0: Searching for objects and class attributes | | 350 | +- v3-2-2: Adding help(deepdiff) | 349 | 351 | - v3-2-1: Fixing hash of None | 350 | 352 | - v3-2-0: Adding grep for search: object | grep(item) | 351 | 353 | - v3-1-3: Unicode vs. Bytes default fix | |
Collapse file Copy file name to clipboardExpand all lines: setup.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | long_description = "Deep Difference and Search of any Python object/data." | 14 | 14 |
| 15 | 15 | setup(name='deepdiff', | 16 | | - version='3.2.1', | | 16 | + version='3.3.0', | 17 | 17 | description='Deep Difference and Search of any Python object/data.', | 18 | 18 | url='https://github.com/seperman/deepdiff', | 19 | 19 | download_url='https://github.com/seperman/deepdiff/tarball/master', | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_search.py +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | """ | 16 | 16 | import unittest | 17 | 17 | from deepdiff import DeepSearch, grep | | 18 | +from datetime import datetime | 18 | 19 | import logging | 19 | 20 | logging.disable(logging.CRITICAL) | 20 | 21 |
| @@ -286,6 +287,32 @@ def test_case_insensitive_of_str_in_one_liner(self): | 286 | 287 | result = {'matched_values': {'root'}} | 287 | 288 | self.assertEqual(DeepSearch(obj, item, verbose_level=1, case_sensitive=False), result) | 288 | 289 |
| | 290 | + def test_none(self): | | 291 | + obj = item = None | | 292 | + result = {'matched_values': {'root'}} | | 293 | + self.assertEqual(DeepSearch(obj, item, verbose_level=1), result) | | 294 | + | | 295 | + def test_complex_obj(self): | | 296 | + obj = datetime(2017, 5, 4, 1, 1, 1) | | 297 | + item = datetime(2017, 5, 4, 1, 1, 1) | | 298 | + result = {'matched_values': {'root'}} | | 299 | + self.assertEqual(DeepSearch(obj, item, verbose_level=1), result) | | 300 | + | | 301 | + def test_keep_searching_after_obj_match(self): | | 302 | + | | 303 | + class AlwaysEqual: | | 304 | + | | 305 | + def __init__(self, recurse=True): | | 306 | + if recurse: | | 307 | + self.some_attr = AlwaysEqual(recurse=False) | | 308 | + | | 309 | + def __eq__(self, other): | | 310 | + return True | | 311 | + | | 312 | + obj = AlwaysEqual() | | 313 | + item = AlwaysEqual() | | 314 | + result = {'matched_values': {'root', 'root.some_attr'}} | | 315 | + | 289 | 316 | def test_search_inherited_attributes(self): | 290 | 317 | class Parent(object): | 291 | 318 | a = 1 | |
|