Merge lp:~phill-ridout/openlp/ftw-json into lp:openlp/ftw-data
- ftw-json
- Merge into ftw-data
Proposed by
Phill
Status: | Merged |
---|---|
Approved by: | Raoul Snyman |
Approved revision: | 21 |
Merged at revision: | 20 |
Proposed branch: | lp:~phill-ridout/openlp/ftw-json |
Merge into: | lp:openlp/ftw-data |
Diff against target: |
434 lines (+412/-1) 3 files modified
download_3.0.json (+326/-0) scripts/hashgen.py (+1/-1) scripts/jsongen.py (+85/-0) |
To merge this branch: | bzr merge lp:~phill-ridout/openlp/ftw-json |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Tomas Groth | Approve | ||
Review via email: mp+363049@code.launchpad.net |
This proposal supersedes a proposal from 2019-02-11.
Commit message
Add a JSON formatted config file for easier parsing and associated script
Description of the change
To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
review:
Needs Fixing
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal | # |
2 minor things.
review:
Needs Fixing
Revision history for this message
Tomas Groth (tomasgroth) : | # |
review:
Approve
Revision history for this message
Raoul Snyman (raoul-snyman) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'download_3.0.json' | |||
2 | --- download_3.0.json 1970-01-01 00:00:00 +0000 | |||
3 | +++ download_3.0.json 2019-02-12 10:51:53 +0000 | |||
4 | @@ -0,0 +1,326 @@ | |||
5 | 1 | { | ||
6 | 2 | "_comments": "The most recent version should be added to http://openlp.org/files/frw/download_3.0.json", | ||
7 | 3 | "_meta": { | ||
8 | 4 | "base_url": "https://get.openlp.org/ftw/", | ||
9 | 5 | "bibles_dir": "bibles", | ||
10 | 6 | "songs_dir": "songs", | ||
11 | 7 | "themes_dir": "themes" | ||
12 | 8 | }, | ||
13 | 9 | "bibles": { | ||
14 | 10 | "af": { | ||
15 | 11 | "title": "Afrikaans", | ||
16 | 12 | "translations": { | ||
17 | 13 | "afr": { | ||
18 | 14 | "file_name": "Afrikaans_Bybel.sqlite", | ||
19 | 15 | "sha256": "d4f12ebbb35bf589e791200dd2f320cf89f894b53953724edb458570f47affcf", | ||
20 | 16 | "title": "Afrikaanse Bybel" | ||
21 | 17 | } | ||
22 | 18 | } | ||
23 | 19 | }, | ||
24 | 20 | "ar": { | ||
25 | 21 | "title": "العربية (Arabic)", | ||
26 | 22 | "translations": { | ||
27 | 23 | "kelh": { | ||
28 | 24 | "file_name": "Ketab-EL-Hayat.sqlite", | ||
29 | 25 | "sha256": "7b5d4c46fbd77477db0503b4565f1d558f6e29cf7e7e74f2ae48fbbe14766dde", | ||
30 | 26 | "title": "Ketab EL Hayat" | ||
31 | 27 | }, | ||
32 | 28 | "sp": { | ||
33 | 29 | "file_name": "Syriac_Peshitta_NT.sqlite", | ||
34 | 30 | "sha256": "a7a1ccb205e8e0c92707344e90efbf0c8e60c8ad95eeb216c8b41ce23a231eef", | ||
35 | 31 | "title": "Syriac Peshitta" | ||
36 | 32 | }, | ||
37 | 33 | "vd": { | ||
38 | 34 | "file_name": "VanDyke-Without-Vowels.sqlite", | ||
39 | 35 | "sha256": "b3d216b92c62954da7b69c27eb2872b1163f49fa290a23acc6cb3274d1f68f56", | ||
40 | 36 | "title": "VanDyke Without Vowels" | ||
41 | 37 | }, | ||
42 | 38 | "vdv": { | ||
43 | 39 | "file_name": "VanDyke-With-Vowels.sqlite", | ||
44 | 40 | "sha256": "c1767d8bc2e6aff9097f63f3f9a15af134841ee3fdf40267adba3263f5a6ba0f", | ||
45 | 41 | "title": "VanDyke With Vowels" | ||
46 | 42 | } | ||
47 | 43 | } | ||
48 | 44 | }, | ||
49 | 45 | "cz": { | ||
50 | 46 | "title": "Čeština (Czech)", | ||
51 | 47 | "translations": { | ||
52 | 48 | "csp": { | ||
53 | 49 | "file_name": "Cesky_studijni_preklad.sqlite", | ||
54 | 50 | "sha256": "93885991c10d4ce71418c33b77cba7a321f7c66fe0d40edd7bd474160517d666", | ||
55 | 51 | "title": "Český Studijní Překlad" | ||
56 | 52 | }, | ||
57 | 53 | "krl": { | ||
58 | 54 | "file_name": "Kralicka_Bible_1613.sqlite", | ||
59 | 55 | "sha256": "9d9e25e3361eeb9d550aea571aad55c4320b592ed28a4fa1cf4b0dad5ee382f4", | ||
60 | 56 | "title": "Kralická Bible 1613" | ||
61 | 57 | }, | ||
62 | 58 | "prk": { | ||
63 | 59 | "file_name": "Bible_Preklad_21_stoleti.sqlite", | ||
64 | 60 | "sha256": "1fad90dc62bad7d246092dc4792eb39b89f910cf4fac0efd2bd35c69fcd89acf", | ||
65 | 61 | "title": "Bible, Překlad 21. století" | ||
66 | 62 | } | ||
67 | 63 | } | ||
68 | 64 | }, | ||
69 | 65 | "de": { | ||
70 | 66 | "title": "Deutsch", | ||
71 | 67 | "translations": { | ||
72 | 68 | "145": { | ||
73 | 69 | "file_name": "Luther_1545.sqlite", | ||
74 | 70 | "sha256": "965ca4df59fc6af80472be00fb9a92e1539792b42f2f7c368d9623d057293098", | ||
75 | 71 | "title": "Luther 1545" | ||
76 | 72 | }, | ||
77 | 73 | "elb": { | ||
78 | 74 | "file_name": "Elberfelder_1905.sqlite", | ||
79 | 75 | "sha256": "32cf96da94be0df237584130df7b840b82828c753db0664393d354a4c7ac246b", | ||
80 | 76 | "title": "Elberfelder" | ||
81 | 77 | }, | ||
82 | 78 | "l12": { | ||
83 | 79 | "file_name": "Luther_1912.sqlite", | ||
84 | 80 | "sha256": "2606b991f3254699cd236c6420b59789238118338e2778f7ed4c494861eb05ad", | ||
85 | 81 | "title": "Luther 1912" | ||
86 | 82 | }, | ||
87 | 83 | "mb": { | ||
88 | 84 | "file_name": "Menge_Bibel.sqlite", | ||
89 | 85 | "sha256": "cad8ce0974e1b1823c8830738258941c95af2cf3a79dd3eb9e27659eb02fbdf6", | ||
90 | 86 | "title": "Menge" | ||
91 | 87 | } | ||
92 | 88 | } | ||
93 | 89 | }, | ||
94 | 90 | "en": { | ||
95 | 91 | "title": "English", | ||
96 | 92 | "translations": { | ||
97 | 93 | "asv": { | ||
98 | 94 | "file_name": "ASV.sqlite", | ||
99 | 95 | "sha256": "064637d15c1dd9940682460b8040f6fe1d025dd8f40637ca13c5fbdb14012d09", | ||
100 | 96 | "title": "American Standard Version" | ||
101 | 97 | }, | ||
102 | 98 | "kjv": { | ||
103 | 99 | "file_name": "KJV.sqlite", | ||
104 | 100 | "sha256": "09e2d9d68777c75acc8b587b6be1f5253f86274774529e57a2902c14d9802d3d", | ||
105 | 101 | "title": "King James Version" | ||
106 | 102 | } | ||
107 | 103 | } | ||
108 | 104 | }, | ||
109 | 105 | "eo": { | ||
110 | 106 | "title": "Esperanto", | ||
111 | 107 | "translations": { | ||
112 | 108 | "esb": { | ||
113 | 109 | "file_name": "Esperanto_Bible.sqlite", | ||
114 | 110 | "sha256": "58c716f18382be192a077cb85934720315847e6b168340784df896d365ca495b", | ||
115 | 111 | "title": "Esperanto Biblio" | ||
116 | 112 | } | ||
117 | 113 | } | ||
118 | 114 | }, | ||
119 | 115 | "es": { | ||
120 | 116 | "title": "Español", | ||
121 | 117 | "translations": { | ||
122 | 118 | "lse": { | ||
123 | 119 | "file_name": "Las_Sagradas_Escrituras.sqlite", | ||
124 | 120 | "sha256": "c6654ef283f1139ba2b8d36238f38ad88a31b71599c79be3fad88db4350de939", | ||
125 | 121 | "title": "Las Sagradas Escrituras" | ||
126 | 122 | } | ||
127 | 123 | } | ||
128 | 124 | }, | ||
129 | 125 | "fi": { | ||
130 | 126 | "title": "Suomi", | ||
131 | 127 | "translations": { | ||
132 | 128 | "fi3338": { | ||
133 | 129 | "file_name": "FI_33_38_OpenLP.sqlite", | ||
134 | 130 | "sha256": "3a3dd8b5ec16a7cf5547f13b9ce4490e83ddc032b87b9a0efb383da6ab35fd70", | ||
135 | 131 | "title": "33/38 - Vanha kirkkoraamattu" | ||
136 | 132 | }, | ||
137 | 133 | "fi92": { | ||
138 | 134 | "file_name": "FI_92_OpenLP.sqlite", | ||
139 | 135 | "sha256": "c0f0b0de574c65db60daa88b5f54d514901ae7bc86cf9933478d76575016a050", | ||
140 | 136 | "title": "92 - Uusi kirkkoraamattu" | ||
141 | 137 | }, | ||
142 | 138 | "firk": { | ||
143 | 139 | "file_name": "FI_Raamattu_Kansalle_OpenLP.sqlite", | ||
144 | 140 | "sha256": "6982cb2b5b1061611211e62e8910289ff8702f934ddf785b7978524d3f8f9544", | ||
145 | 141 | "title": "Raamattu Kansalle -käännös" | ||
146 | 142 | } | ||
147 | 143 | } | ||
148 | 144 | }, | ||
149 | 145 | "fr": { | ||
150 | 146 | "title": "Français", | ||
151 | 147 | "translations": { | ||
152 | 148 | "lsb": { | ||
153 | 149 | "file_name": "Louis_Segon_Bible.sqlite", | ||
154 | 150 | "sha256": "8e548c384f92ee54ea46930a1547fcc574f039c3f8eaa918707f5692ceafc069", | ||
155 | 151 | "title": "Louis Segon" | ||
156 | 152 | } | ||
157 | 153 | } | ||
158 | 154 | }, | ||
159 | 155 | "hu": { | ||
160 | 156 | "title": "Magyar", | ||
161 | 157 | "translations": { | ||
162 | 158 | "ma": { | ||
163 | 159 | "file_name": "Magyar_jford_t_s.sqlite", | ||
164 | 160 | "sha256": "5509b117616e64da2486b71c344a4b58ec87634d29b0ddda528185fae19779d2", | ||
165 | 161 | "title": "Magyar Újfordítású" | ||
166 | 162 | } | ||
167 | 163 | } | ||
168 | 164 | }, | ||
169 | 165 | "nl": { | ||
170 | 166 | "title": "Nederlandse", | ||
171 | 167 | "translations": { | ||
172 | 168 | "sta": { | ||
173 | 169 | "file_name": "Statenvertaling.sqlite", | ||
174 | 170 | "sha256": "b2a699caff81c81ae11b705b09bfc85da832953ae28d838bef536e8a6c406822", | ||
175 | 171 | "title": "Statenvertaling" | ||
176 | 172 | } | ||
177 | 173 | } | ||
178 | 174 | }, | ||
179 | 175 | "no": { | ||
180 | 176 | "title": "Nederlandse", | ||
181 | 177 | "translations": { | ||
182 | 178 | "no1921": { | ||
183 | 179 | "file_name": "Norsk-SMB-1921.sqlite", | ||
184 | 180 | "sha256": "a7afc5b77cd54eb11c9b7d20813d56e164e935cf69ee0b38ae4126ce809a5fcd", | ||
185 | 181 | "title": "Studentmållagsbibelen (1921)" | ||
186 | 182 | }, | ||
187 | 183 | "no1930": { | ||
188 | 184 | "file_name": "Norsk-NB-1930.sqlite", | ||
189 | 185 | "sha256": "641a3b52ed7fb8b2027703a1f7241577929ac97f91cf18c6e0ad9c235032b9f8", | ||
190 | 186 | "title": "Norsk bokmål (1930)" | ||
191 | 187 | } | ||
192 | 188 | } | ||
193 | 189 | }, | ||
194 | 190 | "pt": { | ||
195 | 191 | "title": "Português", | ||
196 | 192 | "translations": { | ||
197 | 193 | "jo": { | ||
198 | 194 | "file_name": "Jo_o_Ferreira_de_Almeida_Atualizada.sqlite", | ||
199 | 195 | "sha256": "ada5f15802a5c80cdf27ef188858d4c64e2a5d92b158c4bec7c5ca54e7cddcb1", | ||
200 | 196 | "title": "João Ferreira de Almeida Atualizada" | ||
201 | 197 | } | ||
202 | 198 | } | ||
203 | 199 | }, | ||
204 | 200 | "ru": { | ||
205 | 201 | "title": "Русский", | ||
206 | 202 | "translations": { | ||
207 | 203 | "rst": { | ||
208 | 204 | "file_name": "RST.sqlite", | ||
209 | 205 | "sha256": "86cf69addcbd93ea53842916bc7b90c77154415880b04c933679ea9dac1cf976", | ||
210 | 206 | "title": "Синодальный перевод" | ||
211 | 207 | } | ||
212 | 208 | } | ||
213 | 209 | }, | ||
214 | 210 | "sv": { | ||
215 | 211 | "title": "Slovak", | ||
216 | 212 | "translations": { | ||
217 | 213 | "ssv": { | ||
218 | 214 | "file_name": "Sv_t_P_smo_Katol_cky_Preklad.sqlite", | ||
219 | 215 | "sha256": "2d9ed24fe3eece4a20ecfb0228a92729d5d681bb8b65cb7f6dde18ca2839f5d8", | ||
220 | 216 | "title": "Sväté Písmo (Katolícky Preklad)" | ||
221 | 217 | } | ||
222 | 218 | } | ||
223 | 219 | }, | ||
224 | 220 | "th": { | ||
225 | 221 | "title": "ภาษาไทย", | ||
226 | 222 | "translations": { | ||
227 | 223 | "tkjv": { | ||
228 | 224 | "file_name": "TKJV.sqlite", | ||
229 | 225 | "sha256": "b053589c2d8f760556e5df2018d77b2bfda6c658e79835046d5e173ab2d341d9", | ||
230 | 226 | "title": "พระคัมภีร์ภาษาไทยฉบับ KJV" | ||
231 | 227 | } | ||
232 | 228 | } | ||
233 | 229 | }, | ||
234 | 230 | "tl": { | ||
235 | 231 | "title": "Tagalog", | ||
236 | 232 | "translations": { | ||
237 | 233 | "ang": { | ||
238 | 234 | "file_name": "Ang_Dating_Biblia.sqlite", | ||
239 | 235 | "sha256": "226b74a02323f56bb146e10e522e186d2387bbe2e3082b74297f1c97ce420673", | ||
240 | 236 | "title": "Ang Dating" | ||
241 | 237 | } | ||
242 | 238 | } | ||
243 | 239 | }, | ||
244 | 240 | "uma": { | ||
245 | 241 | "title": "Uma (Indonesia)", | ||
246 | 242 | "translations": { | ||
247 | 243 | "uma": { | ||
248 | 244 | "file_name": "Uma_Version.sqlite", | ||
249 | 245 | "sha256": "59ea6b77e246790794172cae0ecf70a34e59b602f0791d19789763faad12e368", | ||
250 | 246 | "title": "Uma Version" | ||
251 | 247 | } | ||
252 | 248 | } | ||
253 | 249 | } | ||
254 | 250 | }, | ||
255 | 251 | "songs": { | ||
256 | 252 | "ar": { | ||
257 | 253 | "file_name": "songs_ar.sqlite", | ||
258 | 254 | "sha256": "2113f239e2c470d4d464f08e21008a7f77fd001bc01ebea3f6857852c2708712", | ||
259 | 255 | "title": "Arabic" | ||
260 | 256 | }, | ||
261 | 257 | "de": { | ||
262 | 258 | "file_name": "songs_de.sqlite", | ||
263 | 259 | "sha256": "bff85ee11f7f7d667cd2867a639f59f15958d5df6ac0eeedf4da7cc4facd8165", | ||
264 | 260 | "title": "Deutsch" | ||
265 | 261 | }, | ||
266 | 262 | "en": { | ||
267 | 263 | "file_name": "songs_en.sqlite", | ||
268 | 264 | "sha256": "8a5e862f0ce651a9ae8cc93c938b0bb5059f2380ac445096a346480e928bb045", | ||
269 | 265 | "title": "English" | ||
270 | 266 | }, | ||
271 | 267 | "fi": { | ||
272 | 268 | "file_name": "songs_fi.sqlite", | ||
273 | 269 | "sha256": "601ac772d9a9a685059456186437aae128d5da30573ff08595c7f8752613a851", | ||
274 | 270 | "title": "Suomi" | ||
275 | 271 | }, | ||
276 | 272 | "hu": { | ||
277 | 273 | "file_name": "songs_hu.sqlite", | ||
278 | 274 | "sha256": "1cd693f2c829eb6274dfce606cc52478cfdc6a05f00e07bdd20d0f72a18167e4", | ||
279 | 275 | "title": "Magyar" | ||
280 | 276 | }, | ||
281 | 277 | "ru": { | ||
282 | 278 | "file_name": "songs_ru.sqlite", | ||
283 | 279 | "sha256": "1416c3e6b551c90c4e4cb797df368a617b7a5cfec814f0fad8882ab21024aee0", | ||
284 | 280 | "title": "Русский" | ||
285 | 281 | }, | ||
286 | 282 | "th": { | ||
287 | 283 | "file_name": "songs_th.sqlite", | ||
288 | 284 | "sha256": "1066596a3941d2bcb1fad83ae81ccce146ea10ce73be57615e55f7cb02e2ceb7", | ||
289 | 285 | "title": "ภาษาไทย" | ||
290 | 286 | } | ||
291 | 287 | }, | ||
292 | 288 | "themes": { | ||
293 | 289 | "bb": { | ||
294 | 290 | "file_name": "BlueBurst.otz", | ||
295 | 291 | "sha256": "6105626b6da8b358adb8eedb9da986f1149667a1bff324f8bd4549345d2fad56", | ||
296 | 292 | "thumbnail": "BlueBurst.png", | ||
297 | 293 | "title": "Blue Burst" | ||
298 | 294 | }, | ||
299 | 295 | "cl": { | ||
300 | 296 | "file_name": "Clouds.otz", | ||
301 | 297 | "sha256": "d28eafd838be33df58e7ff160d29b0c3ec7024927b62fa2308aa5b259f31d5ea", | ||
302 | 298 | "thumbnail": "Clouds.png", | ||
303 | 299 | "title": "Clouds" | ||
304 | 300 | }, | ||
305 | 301 | "geop": { | ||
306 | 302 | "file_name": "Geo_Purple.otz", | ||
307 | 303 | "sha256": "aee81f16183122d14c0ca9f7582d3adbe1eb8c932c635885fcfb2c50fc36c1aa", | ||
308 | 304 | "thumbnail": "Geo_Purple.png", | ||
309 | 305 | "title": "Geo Purple" | ||
310 | 306 | }, | ||
311 | 307 | "mot": { | ||
312 | 308 | "file_name": "Moss_on_tree.otz", | ||
313 | 309 | "sha256": "b3b9d286610f7639fedf21a04670f011801f79c06004d7d4295c947a0c584462", | ||
314 | 310 | "thumbnail": "Moss_on_tree.png", | ||
315 | 311 | "title": "Moss on tree" | ||
316 | 312 | }, | ||
317 | 313 | "swt": { | ||
318 | 314 | "file_name": "Sea_with_trees.otz", | ||
319 | 315 | "sha256": "66a9c831fa8c6805ba22502f2544469a717bf74c1f2a206a1b45e09b95493eed", | ||
320 | 316 | "thumbnail": "Sea_with_trees.png", | ||
321 | 317 | "title": "Sea with trees" | ||
322 | 318 | }, | ||
323 | 319 | "wt": { | ||
324 | 320 | "file_name": "Wheat.otz", | ||
325 | 321 | "sha256": "63fde97b7d35722c8fe06e1cfe8236e6d212d944d43c04f6b77f5156b83f5a3f", | ||
326 | 322 | "thumbnail": "Wheat.png", | ||
327 | 323 | "title": "Wheat" | ||
328 | 324 | } | ||
329 | 325 | } | ||
330 | 326 | } | ||
331 | 0 | \ No newline at end of file | 327 | \ No newline at end of file |
332 | 1 | 328 | ||
333 | === modified file 'scripts/hashgen.py' | |||
334 | --- scripts/hashgen.py 2017-03-07 18:42:08 +0000 | |||
335 | +++ scripts/hashgen.py 2019-02-12 10:51:53 +0000 | |||
336 | @@ -5,7 +5,7 @@ | |||
337 | 5 | ############################################################################### | 5 | ############################################################################### |
338 | 6 | # OpenLP - Open Source Lyrics Projection # | 6 | # OpenLP - Open Source Lyrics Projection # |
339 | 7 | # --------------------------------------------------------------------------- # | 7 | # --------------------------------------------------------------------------- # |
341 | 8 | # Copyright (c) 2008-2015 OpenLP Developers # | 8 | # Copyright (c) 2008-2019 OpenLP Developers # |
342 | 9 | # --------------------------------------------------------------------------- # | 9 | # --------------------------------------------------------------------------- # |
343 | 10 | # This program is free software; you can redistribute it and/or modify it # | 10 | # This program is free software; you can redistribute it and/or modify it # |
344 | 11 | # under the terms of the GNU General Public License as published by the Free # | 11 | # under the terms of the GNU General Public License as published by the Free # |
345 | 12 | 12 | ||
346 | === added file 'scripts/jsongen.py' | |||
347 | --- scripts/jsongen.py 1970-01-01 00:00:00 +0000 | |||
348 | +++ scripts/jsongen.py 2019-02-12 10:51:53 +0000 | |||
349 | @@ -0,0 +1,85 @@ | |||
350 | 1 | #!/usr/bin/env python3 | ||
351 | 2 | # -*- coding: utf-8 -*- | ||
352 | 3 | # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 | ||
353 | 4 | |||
354 | 5 | ############################################################################### | ||
355 | 6 | # OpenLP - Open Source Lyrics Projection # | ||
356 | 7 | # --------------------------------------------------------------------------- # | ||
357 | 8 | # Copyright (c) 2008-2019 OpenLP Developers # | ||
358 | 9 | # --------------------------------------------------------------------------- # | ||
359 | 10 | # This program is free software; you can redistribute it and/or modify it # | ||
360 | 11 | # under the terms of the GNU General Public License as published by the Free # | ||
361 | 12 | # Software Foundation; version 2 of the License. # | ||
362 | 13 | # # | ||
363 | 14 | # This program is distributed in the hope that it will be useful, but WITHOUT # | ||
364 | 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # | ||
365 | 16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # | ||
366 | 17 | # more details. # | ||
367 | 18 | # # | ||
368 | 19 | # You should have received a copy of the GNU General Public License along # | ||
369 | 20 | # with this program; if not, write to the Free Software Foundation, Inc., 59 # | ||
370 | 21 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # | ||
371 | 22 | ############################################################################### | ||
372 | 23 | """ | ||
373 | 24 | This script (re)generates a SHA256 hash for each file in the download_3.0.json file | ||
374 | 25 | """ | ||
375 | 26 | import json | ||
376 | 27 | from hashlib import sha256 | ||
377 | 28 | from pathlib import Path | ||
378 | 29 | |||
379 | 30 | CONFIG_FILE_NAME = 'download_3.0.json' | ||
380 | 31 | |||
381 | 32 | def hash_file(file_path, block_size=65536): | ||
382 | 33 | """ | ||
383 | 34 | Hash the given file block by block for memory efficiency | ||
384 | 35 | |||
385 | 36 | :param pathlib.Path file_path: Path to file to hash. | ||
386 | 37 | :param int block_size: Size of blocks to process the file in. | ||
387 | 38 | :return: The sha256 hash of the file. | ||
388 | 39 | :rtype: str | ||
389 | 40 | """ | ||
390 | 41 | with file_path.open(mode='rb') as file: | ||
391 | 42 | print(f'Calculating hash for {file_path}') | ||
392 | 43 | hasher = sha256() | ||
393 | 44 | buf = file.read(block_size) | ||
394 | 45 | while len(buf) > 0: | ||
395 | 46 | hasher.update(buf) | ||
396 | 47 | buf = file.read(block_size) | ||
397 | 48 | return hasher.hexdigest() | ||
398 | 49 | |||
399 | 50 | |||
400 | 51 | def main(): | ||
401 | 52 | """ | ||
402 | 53 | Parse the json resource file and calculate a hash for each file | ||
403 | 54 | """ | ||
404 | 55 | cfg_file_path = Path('..', CONFIG_FILE_NAME) | ||
405 | 56 | if not cfg_file_path.exists(): | ||
406 | 57 | print(f'Can\'t find {cfg_file_path}. You need to run hashgen.py from the scripts directory.') | ||
407 | 58 | return False | ||
408 | 59 | |||
409 | 60 | with cfg_file_path.open(mode='r', encoding='utf-8') as config_file: | ||
410 | 61 | config = json.load(config_file) | ||
411 | 62 | |||
412 | 63 | meta = config['_meta'] | ||
413 | 64 | song_folder = Path('..', meta['songs_dir']) | ||
414 | 65 | for lang in config['songs'].values(): | ||
415 | 66 | song_db_path = song_folder / lang['file_name'] | ||
416 | 67 | lang['sha256'] = hash_file(song_db_path) | ||
417 | 68 | |||
418 | 69 | bible_folder = Path('..', meta['bibles_dir']) | ||
419 | 70 | for lang in config['bibles'].values(): | ||
420 | 71 | for translation in lang['translations'].values(): | ||
421 | 72 | bible_db_path = bible_folder / translation['file_name'] | ||
422 | 73 | translation['sha256'] = hash_file(bible_db_path) | ||
423 | 74 | |||
424 | 75 | theme_folder = Path('..', meta['themes_dir']) | ||
425 | 76 | for theme in config['themes'].values(): | ||
426 | 77 | theme_db_path = theme_folder / theme['file_name'] | ||
427 | 78 | theme['sha256'] = hash_file(theme_db_path) | ||
428 | 79 | |||
429 | 80 | with cfg_file_path.open(mode='w', encoding='utf-8') as config_file: | ||
430 | 81 | json.dump(config, config_file, sort_keys=True, indent=2, ensure_ascii=False) | ||
431 | 82 | |||
432 | 83 | |||
433 | 84 | if __name__ == '__main__': | ||
434 | 85 | main() |
Two things:
1. Please add a commit message or a description ^^
2. Your new JSON file is either "download_3.0.json" or "download_3.0.conf" depending on whether you look at the file name, or the constant on line 366 of the diff below. Please choose one.