Skip to content

Commit 63eed6d

Browse files
committed
dupe-finder: write db of checksums to disk
1 parent 1d7f8eb commit 63eed6d

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

scripts/dupe_finder.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def look_for_rom(files):
3737
return -1
3838

3939

40-
'''
40+
"""
4141
given a path of a folder containing rom to be added in the database
4242
it says if we're adding duplicates or nope
4343
@@ -48,7 +48,7 @@ def look_for_rom(files):
4848
4949
params: beta flag --> if on, it won't print again the recap at the end and it will print a special [BETA] tag if a rom turns
5050
out to be duplicated
51-
'''
51+
"""
5252
d = dict()
5353

5454

@@ -85,13 +85,18 @@ def check_entries_folder(entries_path, beta=False):
8585
# print(rom_name + " " + hash)
8686
if len(d[hash]["appears_in"]) > 1:
8787
print(
88-
"[BETA] " + f"{d[hash]['filename']} found in entries: {d[hash]['appears_in']}")
88+
"[BETA] "
89+
+ f"{d[hash]['filename']} found in entries: {d[hash]['appears_in']}"
90+
)
8991

9092
except:
9193
print(data["slug"] + ": hash can't be retrieved.")
9294
else:
9395
print(data["slug"] + ": hash can't be retrieved.")
9496

97+
with open("rom-hashes.json", "w") as json_file:
98+
json.dump(d, json_file, indent=4)
99+
95100
"""
96101
If a list contains more than one slug, it means that those slugs are the same,
97102
because we've met twice or more times the same rom: every time we've encountered a rom we have stored its hash,
@@ -101,18 +106,25 @@ def check_entries_folder(entries_path, beta=False):
101106
if not beta:
102107
for key in d:
103108
if len(d[key]["appears_in"]) > 1:
104-
print(
105-
f"{d[key]['filename']} found in entries: {d[key]['appears_in']}")
106-
#print("hash: " + key)
109+
print(f"{d[key]['filename']} found in entries: {d[key]['appears_in']}")
110+
# print("hash: " + key)
107111

108112

109113
def main():
110114
args = sys.argv[1:]
111115

112116
if "-h" in args or "--help" in args:
113-
print("Usage: ./dupe_finder <entries folder>\n\t<entries_folder> are roms to be checked, hardcoded in source at DEFAULT_ENTRIES_FOLDER = " + DEFAULT_ENTRIES_FOLDER + "\n" +
114-
"Parameters:\n\t--beta <entries beta folder>:\n\t\tabsolute path where the beta folder is: new entries that are going to be merged\n" +
115-
"\t\thardcoded in source at DEFAULT_BETA_FOLDER = " + DEFAULT_BETA_FOLDER + "\n" + "\t--help\n" + "\t\tshow this message")
117+
print(
118+
"Usage: ./dupe_finder <entries folder>\n\t<entries_folder> are roms to be checked, hardcoded in source at DEFAULT_ENTRIES_FOLDER = "
119+
+ DEFAULT_ENTRIES_FOLDER
120+
+ "\n"
121+
+ "Parameters:\n\t--beta <entries beta folder>:\n\t\tabsolute path where the beta folder is: new entries that are going to be merged\n"
122+
+ "\t\thardcoded in source at DEFAULT_BETA_FOLDER = "
123+
+ DEFAULT_BETA_FOLDER
124+
+ "\n"
125+
+ "\t--help\n"
126+
+ "\t\tshow this message"
127+
)
116128
exit(0)
117129

118130
check_entries_folder(DEFAULT_ENTRIES_FOLDER)

0 commit comments

Comments
 (0)