2 # vim: set fileencoding=utf-8 :
4 # Hello. This is make-release-mail.py from the Telepathy project. It's
5 # designed to turn an item from a NEWS file into a mail suitable for sending
6 # to <telepathy@lists.freedesktop.org>. I hope that you enjoy your stay.
10 def extract_description(package, version, news_path):
14 with open(news_path) as f:
15 lines = (line for line in f.readlines())
17 # Find the 'telepathy-foo 0.1.2' header
18 if line.startswith("%s %s" % (package, version)):
21 # Skip the ====== line, and the first blank line
25 got_release_name = False
29 # If we hit the next version header, we're done
30 if line.startswith(package):
32 # Else, if we hit a blank line and we're still reading the release
33 # name, we're done with the release name.
34 elif not got_release_name and line == '':
35 got_release_name = True
36 # Otherwise, append this to the relevant list
37 elif not got_release_name:
38 release_name.append(line)
42 assert got_release_name, (release_name, details)
44 # We rstrip details because it picks up a trailing blank line
45 return ('\n'.join(release_name), '\n'.join(details).rstrip())
47 BASE_URL = 'http://telepathy.freedesktop.org/releases'
49 def main(package, version, news_path):
50 release_name, details = extract_description(package, version, news_path)
55 tarball: %(base_url)s/%(package)s/%(package)s-%(version)s.tar.gz
56 signature: %(base_url)s/%(package)s/%(package)s-%(version)s.tar.gz.asc
58 %(details)s""".strip().rstrip() % {
62 'release_name': release_name,
66 if __name__ == '__main__':
68 package, version, news_path = sys.argv[1:]
70 main(package, version, news_path)
73 'Usage: %s package-name package.version.number path/to/NEWS\n' %