/
extract_newfiles.py
89 lines (78 loc) · 3.23 KB
/
extract_newfiles.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Written in 2014, 2015 by HarJIT
#
# This file is made available under the CC0 Public Domain Dedication. To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this file to the public domain worldwide. This file is distributed without any warranty.
#
# You may have received a copy of the CC0 Public Domain Dedication along with this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#
# -----------------------------------------------------------------
#
# Note: the above notice applies to this file specifically. Other files may use
# different terms. This note is not part of the above notice.
#
import os, json
def getdate_st(fn):
pl = len("ST-2010-04-23-")
r = (fn[3:][:10], (int(fn[pl:][:5]) if fn[pl:][:5].strip("xn") else None),
fn[pl + 6:][:-4].split("-SLUG-", 1)[0].split("SLUG-", 1)[0])
if "-SLUG-" in fn:
r += (fn.split("-SLUG-", 1)[1].split(".", 1)[0], )
return (fn[3:][:10] + "/" + fn[pl:][:5], r)
def getdate_sb(fn):
pl = len("NP-2010-04-23-")
r = (fn[3:][:10], (int(fn[pl:][:5]) if fn[pl:][:5].strip("xn") else None),
fn[pl + 6:][:-4].split("-SLUG-", 1)[0].split("SLUG-", 1)[0])
if "-SLUG-" in fn:
r += (fn.split("-SLUG-", 1)[1].split(".", 1)[0], )
return (fn[3:][:10] + "/" + fn[pl:][:5], r)
def getdate_np(fn):
pl = len("NP-2010-04-23-")
r = (fn[3:][:10], (int(fn[pl:][:5]) if fn[pl:][:5].strip("xn") else None),
fn[pl + 6:][:-4].split("-SLUG-", 1)[0].split("SLUG-", 1)[0])
if "-SLUG-" in fn:
r += (fn.split("-SLUG-", 1)[1].split(".", 1)[0], )
return (fn[3:][:10] + "/" + fn[pl:][:5], r)
def extract_newfiles():
print(">>> extract_newfiles")
if not os.path.exists("../../egs/0003 - (Sketchbook and Extras)/0001 - Filler Sketchbook"):
print("Not running on HarJIT's machine, not regenerating NewFiles.txt")
return
#
stmap = []
sbmap = []
npmap = []
for r, ds, fs in os.walk("../../egs"):
if ".git" not in r:
for i in fs:
if i.startswith("ST-"):
stmap.append(i)
elif i.startswith("SB-"):
sbmap.append(i)
elif i.startswith("NP-"):
npmap.append(i)
stmap = dict(
list(
map(getdate_st, [
i for i in stmap if not i.lower().count("-original")
and not i.lower().count("-pagecut") and not i.lower().count(
"-pageextend") and not i.lower().count("-remastered-sb")
])))
sbmap = dict(
list(
map(getdate_sb,
[i for i in sbmap if (i.count("-00") or i.count("-SLUG-")) and
not i.lower().count("-nbg")])))
npmap = dict(
list(
map(getdate_np, [
i for i in npmap if not i.lower().count("-original")
and not i.lower().count("-remastered-sb")
and not i.lower().count("-colour-official")
])))
open("NewFiles.txt",
"w").write(json.dumps({
"story": stmap,
"sketch": sbmap,
"np": npmap
}, sort_keys=True))
if __name__ == "__main__":
extract_newfiles()