~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_release_notes.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import sys
21
21
from optparse import OptionParser
22
22
 
23
 
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
24
 
 
25
23
 
26
24
def split_into_topics(lines, out_file, out_dir):
27
25
    """Split a large NEWS file into topics, one per release.
32
30
    """
33
31
    topic_file = None
34
32
    for index, line in enumerate(lines):
35
 
        maybe_new_topic = line[:4] in ['bzr ', 'bzr-0',]
 
33
        maybe_new_topic = line[:4] in ('bzr ', 'bzr-',)
36
34
        if maybe_new_topic and lines[index + 1].startswith('####'):
37
35
            release = line.strip()
38
36
            if topic_file is None:
45
43
        elif topic_file:
46
44
            topic_file.write(line)
47
45
        else:
 
46
            # FIXME: the 'content' directive is used for rst2html (and
 
47
            # conflicts with the 'toctree' we insert), we should get rid of
 
48
            # that once we fully switch to sphinx -- vila 20100505
 
49
            if (line.startswith('.. contents::')
 
50
                or line.startswith('   :depth:')):
 
51
                    continue
48
52
            # Still in the header - dump content straight to output
49
53
            out_file.write(line)
 
54
    if topic_file is not None:
 
55
        # Close the last topic_file opened
 
56
        topic_file.close()
50
57
 
51
58
 
52
59
def open_topic_file(out_file, out_dir, release):
53
60
    topic_name = release.replace(' ', '-')
54
 
    out_file.write("   %s\n" % (topic_name,))
 
61
    out_file.write("   %s <%s>\n" % (release, topic_name,))
55
62
    topic_path = os.path.join(out_dir, "%s.txt" % (topic_name,))
56
63
    result = open(topic_path, 'w')
57
64
    result.write("%s\n" % (release,))