/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/generate_release_notes.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
 
1
#!/usr/bin/python
2
2
 
3
3
# Copyright 2009-2010 Canonical Ltd.
4
4
#
35
35
 
36
36
preamble_plain = """\
37
37
####################
38
 
Breezy Release Notes
 
38
Bazaar Release Notes
39
39
####################
40
40
 
41
41
 
46
46
 
47
47
preamble_sphinx = """\
48
48
####################
49
 
Breezy Release Notes
 
49
Bazaar Release Notes
50
50
####################
51
51
 
52
52
 
58
58
 
59
59
def natural_sort_key(file_name):
60
60
    """Split 'aaa-N.MMbbb' into ('aaa-', N, '.' MM, 'bbb')
61
 
 
 
61
    
62
62
    e.g. 1.10b1 will sort as greater than 1.2::
63
63
 
64
64
        >>> natural_sort_key('brz-1.10b1.txt') > natural_sort_key('brz-1.2.txt')
86
86
 
87
87
 
88
88
def output_news_file_plain(out_file, news_file_name):
89
 
    with open(news_file_name, 'r') as f:
 
89
    f = open(news_file_name, 'rb')
 
90
    try:
90
91
        lines = f.readlines()
 
92
    finally:
 
93
        f.close()
91
94
    title = os.path.basename(news_file_name)[len('brz-'):-len('.txt')]
92
95
    for line in lines:
93
96
        if line == '####################\n':
94
97
            line = '#' * len(title) + '\n'
95
 
        elif line == 'Breezy Release Notes\n':
 
98
        elif line == 'Bazaar Release Notes\n':
96
99
            line = title + '\n'
97
100
        elif line == '.. toctree::\n':
98
101
            continue
121
124
        preamble = preamble_plain
122
125
        output_news_file = output_news_file_plain
123
126
 
124
 
    with open(out_file_name, 'w') as out_file:
 
127
    out_file = open(out_file_name, 'w')
 
128
    try:
125
129
        out_file.write(preamble)
126
130
        for news_file_name in news_file_names:
127
131
            output_news_file(out_file, news_file_name)
 
132
    finally:
 
133
        out_file.close()
128
134
 
129
135
 
130
136
if __name__ == '__main__':