forked from fgosc/fgosccnt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_hash_battle.py
59 lines (51 loc) · 1.75 KB
/
make_hash_battle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import argparse
import logging
import csv
import cv2
from pathlib import Path
from fgosccnt import compute_hash_ce, compute_hash, imread, item_name, item_shortname
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s')
logger = logging.getLogger(__name__)
Item_dir = Path(__file__).resolve().parent / Path("item/")
category = ["point", "ce", "equip"]
def main(args):
for c in category:
search_dir = Item_dir / c
files = search_dir.glob('**/*.png')
for file in files:
# name
name = file.stem
# id
if c == "equip":
try:
item_id = [k for k, v in item_shortname.items() if v == name][0]
name = item_name[item_id]
except:
item_id = [k for k, v in item_name.items() if v == name][0]
else:
print(name, flush=True)
item_id = [k for k, v in item_name.items() if v == name][0]
# hash
img = imread(file)
if c == "ce":
item_hash = compute_hash_ce(img)
else:
item_hash = compute_hash(img)
hash_hex = ""
for h in item_hash[0]:
hash_hex = hash_hex + "{:02x}".format(h)
print("{},{},{}".format(item_id, name, hash_hex))
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--loglevel',
choices=('DEBUG', 'INFO', 'WARNING'),
default='WARNING',
help='loglevel [default: WARNING]',
)
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
logger.setLevel(args.loglevel)
main(args)