2022-09-14 16:43:59 +03:00
|
|
|
import os
|
|
|
|
import hashlib
|
|
|
|
from glob import glob
|
|
|
|
from pathlib import Path
|
|
|
|
import json
|
|
|
|
|
2022-12-14 14:07:12 +03:00
|
|
|
DELVER_PATH = './delver/'
|
2022-09-14 16:43:59 +03:00
|
|
|
|
|
|
|
def get_files_list(path):
|
|
|
|
"""Return *.dat files in directory and subdirectories"""
|
2022-12-14 14:07:12 +03:00
|
|
|
files = [y for x in os.walk(DELVER_PATH) for y in glob(os.path.join(x[0], '*.dat'))]
|
2022-09-14 16:43:59 +03:00
|
|
|
files_with_norm_path = list()
|
|
|
|
for file in files:
|
|
|
|
files_with_norm_path.append(file.replace(os.sep, '/'))
|
|
|
|
|
|
|
|
return files_with_norm_path
|
|
|
|
|
|
|
|
|
|
|
|
def calc_md5(file_path):
|
|
|
|
"""Return files MD5 sum"""
|
|
|
|
filebytes = Path(file_path).read_bytes()
|
|
|
|
md5sum = hashlib.md5(filebytes)
|
|
|
|
return md5sum.hexdigest()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
files = get_files_list('./')
|
|
|
|
|
|
|
|
print('{')
|
|
|
|
for file in files:
|
|
|
|
print('"{path}" : "{sum}",'.format(
|
|
|
|
path=file, sum=calc_md5(file)))
|
|
|
|
print('}')
|