cli: fix changelog encode for PY3

relates [issue#577](https://pagure.io/koji/issue/577)
This commit is contained in:
Yuming Zhu 2017-09-01 17:40:08 +08:00
parent ac2d2c5935
commit 3464adae2e
3 changed files with 35 additions and 5 deletions

View file

@ -48,9 +48,11 @@ try:
except ImportError: # pragma: no cover
from sha import new as sha1_constructor
def _changelogDate(cldate):
return time.strftime('%a %b %d %Y', time.strptime(koji.formatTime(cldate), '%Y-%m-%d %H:%M:%S'))
def formatChangelog(entries):
"""Format a list of changelog entries (dicts)
into a string representation."""
@ -59,9 +61,9 @@ def formatChangelog(entries):
result += """* %s %s
%s
""" % (_changelogDate(entry['date']), entry['author'].encode("utf-8"),
entry['text'].encode("utf-8"))
""" % (_changelogDate(entry['date']),
koji.fixPrint(entry['author']),
koji.fixPrint(entry['text']))
return result
DATE_RE = re.compile(r'(\d+)-(\d+)-(\d+)')