upcoming.py: get header template from external file

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2017-10-02 22:33:57 +02:00
parent a9514c2b8a
commit 392e64c3b3
1 changed files with 27 additions and 24 deletions

View File

@ -17,34 +17,36 @@ from helpers import (
UPCOMING_FILE = "{}/upcoming.txt".format(CACHEDIR) UPCOMING_FILE = "{}/upcoming.txt".format(CACHEDIR)
UPCOMING_HEADER = "{}/upcoming-header.txt".format(CACHEDIR)
UPCOMING_HEADER = """ # Header is like:
Message-Id: <{messageId}> #
Date: {date} #Message-Id: <{messageId}>
From: {name} <{email}> #Date: {date}
To: {mailinglist} #From: {name} <{email}>
Cc: {ccList} #To: {mailinglist}
Subject: [ANNOUNCE] upcoming offlineimap v{expectedVersion} #Cc: {ccList}
#Subject: [ANNOUNCE] upcoming offlineimap v{expectedVersion}
# Notes #
## Notes
I think it's time for a new release. #
#I think it's time for a new release.
I aim to make the new release in one week, approximately. If you'd like more #
time, please let me know. ,-) #I aim to make the new release in one week, approximately. If you'd like more
#time, please let me know. ,-)
Please, send me a mail to confirm it works for you. This will be written in the #
release notes and the git logs. #Please, send me a mail to confirm it works for you. This will be written in the
#release notes and the git logs.
#
# Authors #
## Authors
""" #
if __name__ == '__main__': if __name__ == '__main__':
offlineimapInfo = OfflineimapInfo() offlineimapInfo = OfflineimapInfo()
print("Will read headers from {}".format(UPCOMING_HEADER))
Git.chdirToRepositoryTopLevel() Git.chdirToRepositoryTopLevel()
oVersion = offlineimapInfo.getVersion() oVersion = offlineimapInfo.getVersion()
ccList = Testers.listTestersInTeam() ccList = Testers.listTestersInTeam()
@ -54,7 +56,8 @@ if __name__ == '__main__':
if email not in ccList: if email not in ccList:
ccList.append(email) ccList.append(email)
with open(UPCOMING_FILE, 'w') as upcoming: with open(UPCOMING_FILE, 'w') as upcoming, \
open(UPCOMING_HEADER, 'r') as fd_header:
header = {} header = {}
header['messageId'] = Git.buildMessageId() header['messageId'] = Git.buildMessageId()
@ -64,7 +67,7 @@ if __name__ == '__main__':
header['expectedVersion'] = User.request("Expected new version?") header['expectedVersion'] = User.request("Expected new version?")
header['ccList'] = ", ".join(ccList) header['ccList'] = ", ".join(ccList)
upcoming.write(UPCOMING_HEADER.format(**header).lstrip()) upcoming.write(fd_header.read().format(**header).lstrip())
upcoming.write(Git.getShortlog(oVersion)) upcoming.write(Git.getShortlog(oVersion))
upcoming.write("\n\n# Diffstat\n\n") upcoming.write("\n\n# Diffstat\n\n")