contribute utils

This commit is contained in:
Alexander Popov 2022-09-14 16:43:59 +03:00
parent c546169b51
commit e64f23035c
5 changed files with 111 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
# original game files dir
delver/
dataSums.new.json

12
CONTRIBUTE.md Normal file
View File

@ -0,0 +1,12 @@
### check_md5sum_data.py
Проверяем файлы по MD5 суммам из списков `dataSums.json` и `dataSums.new.json`
### generate_md5sum_data.py
Генерирует список файлов из директории `./delver`\*
> \* ./delver/ директория с оригинальными файлыми игры
### Создания списка файлов с их MD5 суммами
```sh
python generate_md5sum_data.py > dataSums.new.json
```

17
check_md5sum_data.py Normal file
View File

@ -0,0 +1,17 @@
import os
import hashlib
from glob import glob
from pathlib import Path
import json
if __name__ == '__main__':
data_sums = json.loads(Path('dataSums.json').read_text())
data_sums_new = json.loads(Path('dataSums.new.json').read_text())
for file in data_sums:
try:
if (data_sums[file] != data_sums_new[file]):
print('{file} updated.'.format(file=file))
except KeyError as e:
print('{file} added.'.format(file=file))

50
dataSums.json Normal file
View File

@ -0,0 +1,50 @@
{
"./delver/data/animations.dat" : "25184b283a4a7e82fb77a6f0eff1db3b",
"./delver/data/animations_new.dat" : "25184b283a4a7e82fb77a6f0eff1db3b",
"./delver/data/dungeons-testing.dat" : "78f4db6aca19d59bb8643e328e9b20e2",
"./delver/data/entities.dat" : "ef0bb391dc286b952d99b515cb57ef68",
"./delver/data/game.dat" : "3eaf830951535e154bd9148bbad78710",
"./delver/data/hud.dat" : "3977484c8f3c0e45e0e63d8565b9bf1e",
"./delver/data/items.dat" : "cc28507bfe57e13f5f88edf4881728cf",
"./delver/data/monsters.dat" : "8d374aed5f687a242ded1aae586ee987",
"./delver/data/player.dat" : "23690b91201c5974a3f11b08bd36d121",
"./delver/data/quests.dat" : "9168f2c2638b20034a10cb568e71d0ca",
"./delver/data/shaders.dat" : "a093fe0fd9ad45ff4e566fa6565282f7",
"./delver/data/splash.dat" : "375fff616526dac035e1c5972a5f0edb",
"./delver/data/spritesheets.dat" : "893f1415f9202c98af9a4026a7af97ab",
"./delver/data/strings.dat" : "b2b38c1f2cef6832b1087ba6463f3c2e",
"./delver/data/tiles.dat" : "df3f34c61643564c35aceb5c39d54b50",
"./delver/data/walltextures.dat" : "65b73dee3d5d742449bf7f5d9b685f42",
"./delver/data/messages/breach.dat" : "99740a7c9b1bbd685e5f3bbb863cf1a2",
"./delver/data/messages/camp-note1.dat" : "df73818cedb442faaee69e58483451a0",
"./delver/data/messages/camp-note2.dat" : "d3d0362c388e66a76e7edb23be2c907f",
"./delver/data/messages/camp-note3.dat" : "9bea006954147360747ef3fa8ca8d739",
"./delver/data/messages/camp-note4.dat" : "e8afb0bfa1b375aa075135acc62cceb8",
"./delver/data/messages/campfireguy.dat" : "06edcef63c6dd9424d4514820c9b0f59",
"./delver/data/messages/campfireguy2.dat" : "528dc7800bd770d6f0b3e8ab89f457c6",
"./delver/data/messages/campfireguy3.dat" : "244e8687721ec79e4e36be0a9d08fcd8",
"./delver/data/messages/campfireguy4.dat" : "638126f8c7cefd9ec2cea4ebd4f79945",
"./delver/data/messages/campfireguy5.dat" : "e73900305843948d70f98372ec1dce3f",
"./delver/data/messages/credits.dat" : "637404d81ab5f2e2ca31dea69e0d7f34",
"./delver/data/messages/end.dat" : "a0a2b5dd828e1c26dbcf41042d4cd301",
"./delver/data/messages/headstone.dat" : "b8c1e2ecbe78c512049a29e774711ab4",
"./delver/data/messages/hoodie.dat" : "97450566a414cc2e95fb7116b2930c2f",
"./delver/data/messages/hoodie2.dat" : "a952756589179c731122d7b49e52af79",
"./delver/data/messages/hoodie_sewer.dat" : "7cfa7884c6854c71bc0ef81d25f7a5d6",
"./delver/data/messages/jeff.dat" : "963c2d52e8fdc403057afeab88de5ff4",
"./delver/data/messages/jeff2.dat" : "f57f539ebb52ba7474267810e83efa07",
"./delver/data/messages/jeff3.dat" : "d01774b130930895adef2558d49136e4",
"./delver/data/messages/joff.dat" : "1d013c35b750c4af7109f5d3ee4aded5",
"./delver/data/messages/joff2.dat" : "408791c07a5c56f384cf77f15e088275",
"./delver/data/messages/joff3.dat" : "14fe045ef12e659ca170919e1cddf782",
"./delver/data/messages/later.dat" : "4e47297322ef9bd796b063f89025a8dc",
"./delver/data/messages/quietguy.dat" : "d19aff8e00203e44fa44069a2820d056",
"./delver/data/messages/tutorial_note1.dat" : "071d7e9268294af6815877e5ca8f7572",
"./delver/data/messages/wizard.dat" : "661696bae118a76225fb486f1e39eb09",
"./delver/data/messages/wizard2.dat" : "764c7a4faa69ce4d1517b1f366d5c090",
"./delver/data/messages/dungeonNotes/castle.dat" : "3ce9ed3a123ff34dc37042972985b0eb",
"./delver/data/room-builders/cave_rooms.dat" : "aa1eecbc4a99df22e52df970de71c10a",
"./delver/data/room-builders/dungeon_rooms.dat" : "7557c6e083e1228bb266184559d5c547",
"./delver/data/room-builders/sewer_rooms.dat" : "0046bcf75f2cec5f35c178d4ccf14008",
"./delver/data/room-builders/temple_rooms.dat" : "fe6c51c89072e2b80568633aca03c3fa"
}

31
generate_md5sum_data.py Normal file
View File

@ -0,0 +1,31 @@
import os
import hashlib
from glob import glob
from pathlib import Path
import json
def get_files_list(path):
"""Return *.dat files in directory and subdirectories"""
files = [y for x in os.walk('./delver/') for y in glob(os.path.join(x[0], '*.dat'))]
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('}')