~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_release_notes.py

  • Committer: Martin Pool
  • Date: 2010-04-01 04:41:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5128.
  • Revision ID: mbp@sourcefrog.net-20100401044118-shyctqc02ob08ngz
ignore .testrepository

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
 
23
25
 
24
26
def split_into_topics(lines, out_file, out_dir):
25
27
    """Split a large NEWS file into topics, one per release.
30
32
    """
31
33
    topic_file = None
32
34
    for index, line in enumerate(lines):
33
 
        maybe_new_topic = line[:4] in ('bzr ', 'bzr-',)
 
35
        maybe_new_topic = line[:4] in ['bzr ', 'bzr-0',]
34
36
        if maybe_new_topic and lines[index + 1].startswith('####'):
35
37
            release = line.strip()
36
38
            if topic_file is None:
43
45
        elif topic_file:
44
46
            topic_file.write(line)
45
47
        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
52
48
            # Still in the header - dump content straight to output
53
49
            out_file.write(line)
54
 
    if topic_file is not None:
55
 
        # Close the last topic_file opened
56
 
        topic_file.close()
57
50
 
58
51
 
59
52
def open_topic_file(out_file, out_dir, release):
60
53
    topic_name = release.replace(' ', '-')
61
 
    out_file.write("   %s <%s>\n" % (release, topic_name,))
 
54
    out_file.write("   %s\n" % (topic_name,))
62
55
    topic_path = os.path.join(out_dir, "%s.txt" % (topic_name,))
63
56
    result = open(topic_path, 'w')
64
57
    result.write("%s\n" % (release,))