Last active
January 14, 2024 02:46
-
-
Save kato-megumi/b6d2f99816afcdf9c2fd17415672f656 to your computer and use it in GitHub Desktop.
port https://github.com/crskycode/GenHxHashList to python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import re | |
if len(sys.argv) < 2: | |
print("Usage:") | |
print(" GenHxHashList Dump.log ...") | |
print() | |
print("Note: Support multi input file,") | |
print(" output will be created in the current directory.") | |
print() | |
input("Press Enter to exit.") | |
sys.exit() | |
list_file = "HxNames.lst" | |
path_map = {} | |
name_map = {} | |
if os.path.exists(list_file): | |
with open(list_file, 'r') as file: | |
for line in file: | |
if not line or len(line.strip()) == 0: | |
continue | |
entry = line.split(':') | |
if len(entry) != 2: | |
continue | |
if len(entry[0]) == 16: | |
if len(entry[1]) > 0: | |
path_map[entry[0]] = entry[1] | |
continue | |
if len(entry[0]) == 64: | |
if len(entry[1]) > 0: | |
name_map[entry[0]] = entry[1] | |
continue | |
for arg in sys.argv[1:]: | |
print("Read file...") | |
with open(arg, 'r') as file: | |
for line in file: | |
if not line or len(line.strip()) == 0: | |
continue | |
match1 = re.search(r'PathHash: "(.+?)" "(.+?)" "(.+?)"', line) | |
if match1 and len(match1.groups()) == 3: | |
path_hash = match1.group(3) | |
path_str = match1.group(1) | |
path_map[path_hash] = path_str | |
continue | |
match2 = re.search(r'NameHash: "(.+?)" "(.+?)" "(.+?)"', line) | |
if match2 and len(match2.groups()) == 3: | |
name_hash = match2.group(3) | |
name_str = match2.group(1) | |
name_map[name_hash] = name_str | |
continue | |
print("Write list...") | |
with open(list_file, 'w') as file: | |
for key, value in path_map.items(): | |
file.write(f"{key}:{value}\n") | |
for key, value in name_map.items(): | |
file.write(f"{key}:{value}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment