diff options
author | Papoteur <papoteur@mageialinux-online.org> | 2015-10-31 14:18:10 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageialinux-online.org> | 2015-10-31 14:18:10 +0100 |
commit | 4f6dd20936e22ebeee7ec13c4952bfae0142e783 (patch) | |
tree | 31785b088cc64340f37af9b431e26766a7a48256 /MgaRepo/log.py | |
parent | a2b80fd90065a5d2711ebc2edd8b74a17562e1fa (diff) | |
download | mgarepo-4f6dd20936e22ebeee7ec13c4952bfae0142e783.tar mgarepo-4f6dd20936e22ebeee7ec13c4952bfae0142e783.tar.gz mgarepo-4f6dd20936e22ebeee7ec13c4952bfae0142e783.tar.bz2 mgarepo-4f6dd20936e22ebeee7ec13c4952bfae0142e783.tar.xz mgarepo-4f6dd20936e22ebeee7ec13c4952bfae0142e783.zip |
Replace cheetah template with hardcoded templates default and revno
Select default template in mgarepo.conf
Diffstat (limited to 'MgaRepo/log.py')
-rw-r--r-- | MgaRepo/log.py | 116 |
1 files changed, 55 insertions, 61 deletions
diff --git a/MgaRepo/log.py b/MgaRepo/log.py index fba00dd..2622f72 100644 --- a/MgaRepo/log.py +++ b/MgaRepo/log.py @@ -3,11 +3,6 @@ from MgaRepo import Error, config, layout from MgaRepo.svn import SVN from MgaRepo.util import execcmd -try: - from Cheetah.Template import Template -except ImportError: - raise Error("mgarepo requires the package python-cheetah") - from io import StringIO import sys @@ -23,47 +18,6 @@ import subprocess locale.setlocale(locale.LC_ALL, "C") -default_template = """ -#if not $releases_by_author[-1].visible - ## Hide the first release that contains no changes. It must be a - ## reimported package and the log gathered from misc/ already should - ## contain a correct entry for the version-release: - #set $releases_by_author = $releases_by_author[:-1] -#end if -#for $rel in $releases_by_author -* $rel.date $rel.author_name <$rel.author_email> $rel.version-$rel.release -+ Revision: $rel.revision -## #if not $rel.released -##+ Status: not released -## #end if - #if not $rel.visible -+ rebuild (emptylog) - #end if - #for $rev in $rel.release_revisions - #for $line in $rev.lines -$line - #end for - #end for - - #for $author in $rel.authors - #if not $author.visible - #continue - #end if - ##alternatively, one could use: - ###if $author.email == "root" - ## #continue - ###end if - + $author.name <$author.email> - #for $rev in $author.revisions - #for $line in $rev.lines - $line - #end for - #end for - - #end for -#end for -""" - def getrelease(pkgdirurl, rev=None, macros=[], exported=None): """Tries to obtain the version-release of the package for a yet-not-markrelease revision of the package. @@ -324,23 +278,63 @@ def make_release(author=None, revision=None, date=None, lines=None, def dump_file(releases, currentlog=None, template=None): - templpath = template or config.get("template", "path", - "/usr/share/mgarepo/default.chlog") - params = {} - if templpath is None or not os.path.exists(templpath): - params["source"] = default_template - sys.stderr.write("warning: %s not found. using built-in template.\n"% - templpath) - else: - params["file"] = templpath + ''' Template cheetah suppressed and replaced by hard code. The template is selectable with the "name" in "template" section of config file.''' + templname = template or config.get("template", "name", + "default") + draft="" releases_author = group_releases_by_author(releases) revisions_author = group_revisions_by_author(currentlog) - params["searchList"] = [{"releases_by_author" : releases_author, - "releases" : releases, - "revisions_by_author": revisions_author}] - t = Template(**params) - return t.respond() - + if templname == 'revno': + ''' a specific template''' + for rel in releases_author: + if not rel.released: + draft = " (not released yet)\n" + draft = draft + "* {0} {1} <{2}> {3}-{4}\n\n".format(rel.date, rel.author_name, rel.author_email, rel.version, rel.release) + for rev in rel.release_revisions: + first=True + spaces = " " * (len(str(rev.revision)) +3) + for line in rev.lines: + if first: + draft = draft +"[{0}] {1}\n".format(rev.revision, line) + first = False + else: + draft = draft + spaces + line + "\n" + for author in rel.authors: + if not author.visible: + continue + draft += "+ {0} <{1}>\n".format(author.name, author.email) + for rev in author.revisions: + first=True + spaces = " " * (len(str(rev.revision)) + 3) + for line in rev.lines: + if first: + draft = draft +"[{0}] {1}\n".format(rev.revision, line) + first = False + else: + draft = draft + spaces + line + "\n" + else: + # default template + if not releases_author[-1].visible: + releases_author = releases_author[:-1] + for rel in releases_author: + if not rel.released: + draft = " (not released yet)\n" + draft = draft + "* {0} {1} <{2}> {3}-{4}\n+ Revision: {5}\n".format(rel.date, rel.author_name, rel.author_email, rel.version, rel.release, rel.revision) + if not rel.visible: + draft = draft + "+ rebuild (emptylog)\n" + for rev in rel.release_revisions: + for line in rev.lines: + draft = draft + line + "\n" + for author in rel.authors: + if not author.visible: + continue + draft += "+ {0} <{1}>\n".format(author.name, author.email) + for rev in author.revisions: + for line in rev.lines: + draft = draft + line + "\n" + draft += "\n" + draft += "\n" + return draft class InvalidEntryError(Exception): pass |