utils: use dict_md5

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-04-14 22:07:29 +03:00
parent 17a301d73b
commit fed22d3ab9
2 changed files with 8 additions and 4 deletions
+2 -4
View File
@@ -5,7 +5,7 @@ import threading
from dvc.system import System
from dvc.output import Output
from dvc.utils import file_md5, bytes_md5
from dvc.utils import file_md5, dict_md5
from dvc.exceptions import DvcException
@@ -70,9 +70,7 @@ class State(object):
def compute_md5(self, path):
if os.path.isdir(path):
dir_info = self.collect_dir(path)
byts = json.dumps(dir_info, sort_keys=True).encode('utf-8')
md5 = bytes_md5(byts)
return md5 + Output.MD5_DIR_SUFFIX
return dict_md5(dir_info) + Output.MD5_DIR_SUFFIX
else:
return file_md5(path)[0]
+6
View File
@@ -3,6 +3,7 @@ Helpers for other modules.
"""
import os
import re
import json
import stat
import shutil
import hashlib
@@ -34,6 +35,11 @@ def bytes_md5(byts):
return hasher.hexdigest()
def dict_md5(d):
byts = json.dumps(d, sort_keys=True).encode('utf-8')
return bytes_md5(byts)
def cached_property(func):
'''A decorator for caching properties in classes.'''
def get(self):