summaryrefslogtreecommitdiff
path: root/utils/nwztools/database/gen_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nwztools/database/gen_db.py')
-rwxr-xr-xutils/nwztools/database/gen_db.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/utils/nwztools/database/gen_db.py b/utils/nwztools/database/gen_db.py
index cf1423f2a5..8b7d1cbaaf 100755
--- a/utils/nwztools/database/gen_db.py
+++ b/utils/nwztools/database/gen_db.py
@@ -13,6 +13,7 @@ with open('models.txt') as fp:
13 g_models.append({'mid': int(mid, 0), 'name': name}) 13 g_models.append({'mid': int(mid, 0), 'name': name})
14# parse series.txt 14# parse series.txt
15g_series = [] 15g_series = []
16g_series_codename = set()
16with open('series.txt') as fp: 17with open('series.txt') as fp:
17 for line in fp: 18 for line in fp:
18 # we unpack and repack 1) to make the format obvious 2) to catch errors 19 # we unpack and repack 1) to make the format obvious 2) to catch errors
@@ -25,6 +26,7 @@ with open('series.txt') as fp:
25 models = [] 26 models = []
26 models = [int(mid,0) for mid in models] 27 models = [int(mid,0) for mid in models]
27 g_series.append({'codename': codename, 'name': name, 'models': models}) 28 g_series.append({'codename': codename, 'name': name, 'models': models})
29 g_series_codename.add(codename)
28# parse all maps in nvp/ 30# parse all maps in nvp/
29# since most nvps are the same, what we actually do is to compute the md5sum hash 31# since most nvps are the same, what we actually do is to compute the md5sum hash
30# of all files, to identify groups and then each entry in the name is in fact the 32# of all files, to identify groups and then each entry in the name is in fact the
@@ -38,6 +40,9 @@ for line in subprocess.run(["md5sum"] + map_files, stdout = subprocess.PIPE).std
38 continue 40 continue
39 hash, file = line.rstrip().split() 41 hash, file = line.rstrip().split()
40 codename = re.search('nvp/(.*)\.txt', file).group(1) 42 codename = re.search('nvp/(.*)\.txt', file).group(1)
43 # sanity check
44 if not (codename in g_series_codename):
45 print("Warning: file %s does not have a match series in series.txt" % file)
41 hash = hash[:HASH_SIZE] 46 hash = hash[:HASH_SIZE]
42 # only keep one file 47 # only keep one file
43 if not (hash in g_hash_nvp): 48 if not (hash in g_hash_nvp):