Skip to content

Commit 103a201

Browse files
authored
Merge pull request #77 from seperman/dev
v3.3.0
2 parents e07e8bc + 5d0c217 commit 103a201

File tree

8 files changed

+73
-19
lines changed

8 files changed

+73
-19
lines changed

AUTHORS

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
Authors:
2-
* Seperman
3-
* Victor Hahn Castell @ Flexoptix
2+
- Seperman
3+
- Victor Hahn Castell @ Flexoptix
44

55
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

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# deepdiff v 3.2.1
1+
# deepdiff v 3.3.0
22

33
[![Join the chat at https://gitter.im/deepdiff/Lobby](https://badges.gitter.im/deepdiff/Lobby.svg)](https://gitter.im/deepdiff/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
<!-- ![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat) -->
@@ -788,12 +788,14 @@ I was honored to give a talk about how DeepDiff does what it does at Pycon 2016.
788788
And here is more info: <http://zepworks.com/blog/diff-it-to-digg-it/>
789789

790790

791-
##Documentation
791+
## Documentation
792792

793793
<http://deepdiff.readthedocs.io/en/latest/>
794794

795-
##Changelog
795+
## Change log
796796

797+
- v3-3-0: Searching for objects and class attributes
798+
- v3-2-2: Adding help(deepdiff)
797799
- v3-2-1: Fixing hash of None
798800
- v3-2-0: Adding grep for search: object | grep(item)
799801
- v3-1-3: Unicode vs. Bytes default fix
@@ -845,3 +847,7 @@ Also thanks to:
845847
- b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings.
846848
- finnhughes for fixing __slots__
847849
- 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

README.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**DeepDiff v 3.2.1**
1+
**DeepDiff v 3.3.0**
22

33
Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes.
44

@@ -240,6 +240,8 @@ http://zepworks.com/blog/diff-it-to-digg-it/
240240

241241
**Changelog**
242242

243+
- v3-3-0: Searching for objects and class attributes
244+
- v3-2-2: Adding help(deepdiff)
243245
- v3-2-1: Fixing hash of None
244246
- v3-2-0: Adding grep for search: object | grep(item)
245247
- v3-1-3: Unicode vs. Bytes default fix
@@ -291,3 +293,7 @@ Also thanks to:
291293
- b-jazz for PEP257 cleanup, Standardize on full names, fixing line endings.
292294
- finnhughes for fixing __slots__
293295
- 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

deepdiff/search.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ def __search_obj(self,
127127
parents_ids=frozenset({}),
128128
is_namedtuple=False):
129129
"""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+
130137
try:
131138
if is_namedtuple:
132139
obj = obj._asdict()
@@ -139,7 +146,9 @@ def __search_obj(self,
139146
try:
140147
obj = {i: getattr(obj, i) for i in obj.__slots__}
141148
except AttributeError:
142-
self['unprocessed'].append("%s" % parent)
149+
if not found:
150+
self['unprocessed'].append("%s" % parent)
151+
143152
return
144153

145154
self.__search_dict(

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
# built documents.
6161
#
6262
# The short X.Y version.
63-
version = '3.2.1'
63+
version = '3.3.0'
6464
# The full version, including alpha/beta/rc tags.
65-
release = '3.2.1'
65+
release = '3.3.0'
6666

6767
# The language for content autogenerated by Sphinx. Refer to documentation
6868
# for a list of supported languages.

docs/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
DeepDiff 3.2.1 documentation!
6+
DeepDiff 3.3.0 documentation!
77
=============================
88

99
**DeepDiff: Deep Difference of dictionaries, iterables and almost any other object recursively.**
@@ -346,6 +346,8 @@ Indices and tables
346346
Changelog
347347
=========
348348

349+
- v3-3-0: Searching for objects and class attributes
350+
- v3-2-2: Adding help(deepdiff)
349351
- v3-2-1: Fixing hash of None
350352
- v3-2-0: Adding grep for search: object | grep(item)
351353
- v3-1-3: Unicode vs. Bytes default fix

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
long_description = "Deep Difference and Search of any Python object/data."
1414

1515
setup(name='deepdiff',
16-
version='3.2.1',
16+
version='3.3.0',
1717
description='Deep Difference and Search of any Python object/data.',
1818
url='https://github.com/seperman/deepdiff',
1919
download_url='https://github.com/seperman/deepdiff/tarball/master',

tests/test_search.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""
1616
import unittest
1717
from deepdiff import DeepSearch, grep
18+
from datetime import datetime
1819
import logging
1920
logging.disable(logging.CRITICAL)
2021

@@ -286,6 +287,32 @@ def test_case_insensitive_of_str_in_one_liner(self):
286287
result = {'matched_values': {'root'}}
287288
self.assertEqual(DeepSearch(obj, item, verbose_level=1, case_sensitive=False), result)
288289

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+
289316
def test_search_inherited_attributes(self):
290317
class Parent(object):
291318
a = 1

0 commit comments

Comments
 (0)