Return line number of the first version-like header.  We check for
    patterns like '2.10 (unreleased)', so with either 'unreleased' or a date
    between parenthesis as that's the format we're using.  As an alternative,
    we support an alternative format used by some zope/plone paster templates:
    '2.10 - unreleased' or '2.10 ~ unreleased' Note that new headers are in our
    preferred form (so 'version (date)').

def get_header(changelog):
    """Return line number of the first version-like header.  We check for
    patterns like '2.10 (unreleased)', so with either 'unreleased' or a date
    between parenthesis as that's the format we're using.  As an alternative,
    we support an alternative format used by some zope/plone paster templates:
    '2.10 - unreleased' or '2.10 ~ unreleased' Note that new headers are in our
    preferred form (so 'version (date)').
    """
    pattern = re.compile(r"""
    (?P<version>.+)  # Version string
    \(               # Opening (
    (?P<date>.+)     # Date
    \)               # Closing )
    \W*$             # Possible whitespace at end of line.
    """, re.VERBOSE)
    alt_pattern = re.compile(r"""
    ^                # Start of line
    (?P<version>.+)  # Version string
    \ [-~]\          # space dash/twiggle space
    (?P<date>.+)     # Date
    \W*$             # Possible whitespace at end of line.
    """, re.VERBOSE)
    with changelog.open('rt') as f:
        for line_number, line in enumerate(f):
            match = pattern.search(line)
            alt_match = alt_pattern.search(line)
            if match or alt_match:
                return line_number