aboutsummaryrefslogtreecommitdiff
path: root/releaselog/format/python.py
blob: 7c2a2180e485f89af29b66236a6ddd3d1ea2aef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
Implementation of two release log formats used in most Python packages.

The two formats are:

* Each entry begins with the line

    v<Version>, <Date> -- <String>

where <String> is the beginning of the description. More description lines
may follow.

* Each entry begins with the line

    <Version> (<Date>)

followed by the description text. This format is used, among others, by
GNU Texinfo.

The PythonLogFormat class discovers the actual format by finding the first
input line that matches any of the above patterns.

"""

import re
from releaselog import ReleaseHistory

class PythonLogFormat(ReleaseHistory):
    format = ['Python', 'python']
    header = None
    header_rx = [
        re.compile("""^[vV](?P<version>\d[\d.]*)\s*
                      ,\s*
                      (?P<date>.*?)
                      \s+-+\s*
                      (?P<rest>.*)$
                   """, re.X),
        re.compile("""^(?P<version>\d[\d.]*)
                      \s*
                      (?P<date>.*)
                   """, re.X)
    ]
    
    def parse_header(self, line):
        if self.header:
            return super(PythonLogFormat, self).parse_header(line)
        else:
            for rx in self.header_rx:
                if rx.match(line):
                    self.header = rx
                    return super(PythonLogFormat, self).parse_header(line)
        return (None, None, None)
        

Return to:

Send suggestions and report system problems to the System administrator.