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.
11 def looks_like_a_header(line
, package
, version
=None):
13 pattern
= "^%s .* \(.*\)$" % package
15 pattern
= "^%s %s \(.*\)$" % (package
, version
)
17 return re
.match(pattern
, line
) is not None
19 def extract_description(package
, version
, news_path
):
23 with
open(news_path
) as f
:
24 lines
= (line
for line
in f
.readlines())
26 # Find the 'telepathy-foo 0.1.2' header
27 if looks_like_a_header(line
, package
, version
):
30 # Skip the ====== line, and the first blank line
34 got_release_name
= False
38 # If we hit the next version header, we're done
39 if looks_like_a_header(line
, package
):
41 # Else, if we hit a blank line and we're still reading the release
42 # name, we're done with the release name.
43 elif not got_release_name
and line
== '':
44 got_release_name
= True
45 # Otherwise, append this to the relevant list
46 elif not got_release_name
:
47 release_name
.append(line
)
51 assert got_release_name
, (release_name
, details
)
53 # We rstrip details because it picks up a trailing blank line
54 return ('\n'.join(release_name
), '\n'.join(details
).rstrip())
56 BASE_URL
= 'http://telepathy.freedesktop.org/releases'
57 GIT_URL
= 'http://cgit.freedesktop.org/telepathy'
59 def main(package
, version
, news_path
):
60 release_name
, details
= extract_description(package
, version
, news_path
)
65 tarball: %(base_url)s/%(package)s/%(package)s-%(version)s.tar.gz
66 signature: %(base_url)s/%(package)s/%(package)s-%(version)s.tar.gz.asc
67 git: %(git_url)s/%(package)s
69 %(details)s""".strip().rstrip() % {
74 'release_name': release_name
,
78 if __name__
== '__main__':
80 package
, version
, news_path
= sys
.argv
[1:]
82 main(package
, version
, news_path
)
85 'Usage: %s package-name package.version.number path/to/NEWS\n' %