|
|
|
@@ -14,14 +14,12 @@ def generateHashFile(): |
|
|
|
for root, dirs, files in os.walk(file): |
|
|
|
for file in files: |
|
|
|
path = os.path.join(root, file) |
|
|
|
if mimetypes.guess_type(file)[0] == 'text/plain': |
|
|
|
with open(path, 'rU') as f: |
|
|
|
with open(path, 'rb') as f: |
|
|
|
data = f.read() |
|
|
|
hashlist[path.replace('\\','/')]=hashlib.md5(data).hexdigest() |
|
|
|
else: |
|
|
|
with open(path, 'rb') as f: |
|
|
|
data = f.read() |
|
|
|
hashlist[path.replace('\\','/')]=hashlib.md5(data).hexdigest() |
|
|
|
if data.find('\r\n')!=-1 : |
|
|
|
hashlist[path.replace('\\','/')]=hashlib.md5(data.replace('\n','\r\n')).hexdigest() |
|
|
|
else : |
|
|
|
hashlist[path.replace('\\','/')]=hashlib.md5(data).hexdigest() |
|
|
|
targetFile=os.path.join(targetfolder,'hash.json') |
|
|
|
with open(targetFile, 'w') as fp: |
|
|
|
json.dump(hashlist,fp) |
|
|
|
|