-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrel_dump.py
More file actions
76 lines (65 loc) · 1.94 KB
/
rel_dump.py
File metadata and controls
76 lines (65 loc) · 1.94 KB
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
import contextlib
import sqlite3
def run():
dbpath = 'projects.db'
with contextlib.closing(sqlite3.connect(dbpath)) as conn:
with conn as cur:
rows = cur.execute('''
SELECT
projects_w.project_id,
projects_w.game_title,
packages_w.package_id,
packages_w.name,
releases_w.release_id,
releases_w.version,
files_w.version,
files_w.filename
FROM projects_w
LEFT OUTER JOIN packages_w
ON projects_w.project_id = packages_w.project_id
LEFT OUTER JOIN releases_w
ON packages_w.package_id = releases_w.package_id
LEFT OUTER JOIN files_w
ON releases_w.release_id = files_w.release_id
WHERE
packages_w.package_id IS NULL
OR (
files_w.filename IS NOT NULL
AND files_w.url IS NOT NULL
)
ORDER BY
projects_w.game_title ASC,
packages_w.package_id ASC,
releases_w.version_major DESC,
releases_w.version_minor DESC,
releases_w.version_patch DESC,
releases_w.version_pre DESC NULLS FIRST,
releases_w.version_build DESC NULLS FIRST,
files_w.version_major DESC,
files_w.version_minor DESC,
files_w.version_patch DESC,
files_w.version_pre DESC NULLS FIRST,
files_w.version_build DESC NULLS FIRST,
files_w.filename ASC
'''
)
proj_id = None
pkg_id = None
rel_id = None
for r in rows:
if r[0] != proj_id:
print('')
proj_id = r[0]
print(r[1])
if r[2] != pkg_id:
pkg_id = r[2]
if pkg_id is not None:
print(' ', r[3])
if r[4] != rel_id:
rel_id = r[4]
if rel_id is not None:
print(' ', r[5])
if pkg_id is not None and rel_id is not None:
print(' ', r[6:])
if __name__ == '__main__':
run()