build: remove -enumtypes rules
[empathy-mirror.git] / tools / make-release-mail.py
blob2bd7c2bcc3d9c6a61b31634f3f3f92e08f74d2f8
1 #!/usr/bin/env python
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.
8 import sys
10 def extract_description(package, version, news_path):
11 release_name = []
12 details = []
14 with open(news_path) as f:
15 lines = (line for line in f.readlines())
16 for line in lines:
17 # Find the 'telepathy-foo 0.1.2' header
18 if line.startswith("%s %s" % (package, version)):
19 break
21 # Skip the ====== line, and the first blank line
22 lines.next()
23 lines.next()
25 got_release_name = False
27 for line in lines:
28 line = line.rstrip()
29 # If we hit the next version header, we're done
30 if line.startswith(package):
31 break
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)
39 else:
40 details.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)
52 print """
53 %(release_name)s
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() % {
59 'base_url': BASE_URL,
60 'package': package,
61 'version': version,
62 'release_name': release_name,
63 'details': details,
66 if __name__ == '__main__':
67 try:
68 package, version, news_path = sys.argv[1:]
70 main(package, version, news_path)
71 except ValueError, e:
72 sys.stderr.write(
73 'Usage: %s package-name package.version.number path/to/NEWS\n' %
74 sys.argv[0])
75 sys.stderr.flush()
76 sys.exit(1)