update todo
[QuestHelper.git] / Development / build2 / build_06_identify
blobb9b033844318f5ae5b0a8b679bbd21654091bcc2
1 #!/usr/local/bin/python3.0
3 import re
4 import os
5 import sys
6 import hashlib
8 import utility
10 if not os.path.exists("data/06"):
11   os.makedirs("data/06")
13 collatefiles = {}
14 for path, dirs, files in os.walk("data/05"):
15   collatefiles.update({file:os.path.join(path, file) for file in files})
16 print("Collatefiles isolated: %d" % len(collatefiles))
18 treg = re.compile("data/06/[0-9a-f]{2,2}/([0-9a-f]{32,32})")
19 idfiles = {}
20 for path, dirs, files in os.walk("data/06"):
21   match = treg.match(path)
22   if match:
23     idfiles[match.group(1)] = path
24 print("Idfiles isolated: %d" % len(idfiles))
26 touchfiles = sorted(set([tag for tag in collatefiles.keys()]) | set([tag for tag in idfiles.keys()]))
28 trarg = re.compile("^([^\n]+)\n([^\n]+)$")
29 for tag in touchfiles:
30   assert(tag in collatefiles)
31   if not tag in idfiles:
32     print("Identifying %s" % tag)
33     dat = utility.exe("lua ./build_06_identify_core.lua %s" % collatefiles[tag])
34     
35     metch = trarg.match(dat)
36     assert(metch)
37     
38     id, ts = metch.group(1), metch.group(2)
39     
40     if not os.path.exists("data/06/%s/%s" % (tag[0:2], tag)):
41       os.makedirs("data/06/%s/%s" % (tag[0:2], tag))
42     os.link(collatefiles[tag], "data/06/%s/%s/%s_%s" % (tag[0:2], tag, id, ts))