Make the calibre changelog available as a resource

This commit is contained in:
Kovid Goyal 2020-10-29 10:57:21 +05:30
parent 49af5de171
commit 06e9f8f8b8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 14 additions and 2 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ docs
resources/localization
resources/hyphenation
resources/scripts.calibre_msgpack
resources/changelog.json
resources/ebook-convert-complete.calibre_msgpack
resources/builtin_recipes.xml
resources/builtin_recipes.zip

View File

@ -5,7 +5,7 @@
from datetime import date
def parse(raw):
def parse(raw, parse_dates=True):
entries = []
current_entry = None
current_section = 'new features'
@ -21,7 +21,10 @@ def parse(raw):
if current_entry is not None:
raise ValueError(f'Start of entry while previous entry is still active at line: {linenum}')
version, draw = parts
if parse_dates:
d = date(*map(int, draw.split('-')))
else:
d = draw
current_entry = {'version': version, 'date': d, 'new features': [], 'bug fixes': [], 'improved recipes': [], 'new recipes': []}
current_section = 'new features'
return in_entry

View File

@ -310,6 +310,14 @@ class Resources(Command): # {{{
d[lc] = stats['translated'] / float(total)
dump_json(d, self.j(self.RESOURCES, 'user-manual-translation-stats.json'))
src = self.j(self.SRC, '..', 'Changelog.txt')
dest = self.j(self.RESOURCES, 'changelog.json')
if self.newer(dest, [src]):
self.info('\tCreating changelog.calibre_msgpack')
from setup.changelog import parse
with open(src) as f:
dump_json(parse(f.read(), parse_dates=False), dest)
def clean(self):
for x in ('scripts', 'ebook-convert-complete'):
x = self.j(self.RESOURCES, x+'.pickle')