Skip to content

Commit feddd98

Browse files
committed
addressing issues
1 parent bab2b98 commit feddd98

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

deepdiff/deephash.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
import os
43
import logging
54
from collections import Iterable
65
from collections import MutableMapping
@@ -9,7 +8,7 @@
98
from hashlib import sha1, sha256
109

1110
from deepdiff.helper import (strings, numbers, unprocessed, not_hashed, add_to_frozen_set,
12-
convert_item_or_items_into_set_else_none, current_dir,
11+
convert_item_or_items_into_set_else_none, get_doc,
1312
convert_item_or_items_into_compiled_regexes_else_none,
1413
get_id, type_is_subclass_of_type_group, type_in_type_group)
1514
from deepdiff.base import Base
@@ -18,7 +17,6 @@
1817
try:
1918
import mmh3
2019
except ImportError:
21-
logger.warning('Can not find Murmur3 hashing installed. Switching to SHA256 as the default hash. Refer to https://github.com/seperman/deepdiff#murmur3 for more info.')
2220
mmh3 = False
2321

2422
UNPROCESSED = 'unprocessed'
@@ -48,8 +46,7 @@ def prepare_string_for_hashing(obj, ignore_string_type_changes=False, ignore_str
4846
return obj
4947

5048

51-
with open(os.path.join(current_dir, 'deephash_doc.rst'), 'r') as doc_file:
52-
doc = doc_file.read()
49+
doc = get_doc('deephash_doc.rst')
5350

5451

5552
class DeepHash(dict, Base):

deepdiff/diff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from deepdiff.helper import (strings, bytes_type, numbers, ListItemRemovedOrAdded, notpresent,
2424
IndexedHash, Verbose, unprocessed, json_convertor_default, add_to_frozen_set,
2525
convert_item_or_items_into_set_else_none, get_type,
26-
convert_item_or_items_into_compiled_regexes_else_none, current_dir,
27-
type_is_subclass_of_type_group, type_in_type_group)
26+
convert_item_or_items_into_compiled_regexes_else_none,
27+
type_is_subclass_of_type_group, type_in_type_group, get_doc)
2828
from deepdiff.model import RemapDict, ResultDict, TextResult, TreeResult, DiffLevel
2929
from deepdiff.model import DictRelationship, AttributeRelationship
3030
from deepdiff.model import SubscriptableIterableRelationship, NonSubscriptableIterableRelationship, SetRelationship
@@ -37,8 +37,8 @@
3737
TREE_VIEW = 'tree'
3838
TEXT_VIEW = 'text'
3939

40-
with open(os.path.join(current_dir, 'diff_doc.rst'), 'r') as doc_file:
41-
doc = doc_file.read()
40+
41+
doc = get_doc('diff_doc.rst')
4242

4343

4444
class DeepDiff(ResultDict, Base):

deepdiff/helper.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,12 @@ def type_in_type_group(item, type_group):
203203

204204
def type_is_subclass_of_type_group(item, type_group):
205205
return isinstance(item, type_group) or issubclass(item, type_group) or type_in_type_group(item, type_group)
206+
207+
208+
def get_doc(doc_filename):
209+
try:
210+
with open(os.path.join(current_dir, doc_filename), 'r') as doc_file:
211+
doc = doc_file.read()
212+
except Exception:
213+
doc = 'Failed to load the docstrings. Please visit: https://github.com/seperman/deepdiff'
214+
return doc

deepdiff/search.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
# In order to run the docstrings:
4-
# python3 -m deepdiff.search
5-
import os
63
import re
74
from collections.abc import MutableMapping, Iterable
85
import logging
96

10-
from deepdiff.helper import strings, numbers, add_to_frozen_set, current_dir
7+
from deepdiff.helper import strings, numbers, add_to_frozen_set, get_doc
118

129
logger = logging.getLogger(__name__)
1310

1411

15-
with open(os.path.join(current_dir, 'search_doc.rst'), 'r') as doc_file:
16-
doc = doc_file.read()
12+
doc = get_doc('search_doc.rst')
1713

1814

1915
class DeepSearch(dict):

0 commit comments

Comments
 (0)