mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Generate a hash of the hyphenation dicts for cache updates
This commit is contained in:
parent
2a8875f864
commit
5f46b06dc9
@ -4,6 +4,7 @@
|
|||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -97,7 +98,14 @@ class Hyphenation(Command):
|
|||||||
src = os.path.join(src, os.listdir(src)[0])
|
src = os.path.join(src, os.listdir(src)[0])
|
||||||
process_dictionaries(src, output_dir)
|
process_dictionaries(src, output_dir)
|
||||||
dics = [x for x in os.listdir(output_dir) if x.endswith('.dic')]
|
dics = [x for x in os.listdir(output_dir) if x.endswith('.dic')]
|
||||||
|
m = hashlib.sha1()
|
||||||
|
for dic in sorted(dics):
|
||||||
|
with open(os.path.join(output_dir, dic), 'rb') as f:
|
||||||
|
m.update(f.read())
|
||||||
|
hsh = type('')(m.hexdigest())
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'tar', '-cJf', os.path.join(self.hyphenation_dir, 'dictionaries.tar.xz')] + dics
|
'tar', '-cJf', os.path.join(self.hyphenation_dir, 'dictionaries.tar.xz')] + dics
|
||||||
, env={'XZ_OPT': '-9e -T0'}, cwd=output_dir)
|
, env={'XZ_OPT': '-9e -T0'}, cwd=output_dir)
|
||||||
shutil.copy(self.j(output_dir, 'locales.json'), self.hyphenation_dir)
|
shutil.copy(self.j(output_dir, 'locales.json'), self.hyphenation_dir)
|
||||||
|
with open(os.path.join(self.hyphenation_dir, 'sha1sum'), 'w') as f:
|
||||||
|
f.write(hsh)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user