0
 ?÷     rom an existing changelog,
      or instantiating a Version object directly to assign to the version
      attribute of a Changelog object.

    If you have a changelog that may have no author information yet as
    it is still a work in progress, i.e. the author line is just::

        --

    rather than::

        -- Author <author@debian.org>  Thu, 12 Dec 2006 12:23:34 +0000

    then you can pass ``allow_empty_author=True`` to the Changelog
    constructor. If you do this then the ``author`` and ``date``
    attributes may be ``None``.

    """

    # TODO(jsw): Avoid masking the 'file' built-in.
    def __init__(self,
                 file=None,                 # type: Optional[IterableDataSource]
                 max_blocks=None,           # type: Optional[int]
                 allow_empty_author=False,  # type: bool
                 strict=False,              # type: bool
                 encoding='utf-8',          # type: str
                 ):
        # type: (...) -> None
        self._encoding = encoding
        self._blocks = []   # type: List[ChangeBlock]
        self.initial_blank_lines = []   # type: List[Text]
        if file is not None:
            self.parse_changelog(
                file, max_blocks=max_blocks,
                allow_empty_author=allow_empty_author,
                strict=strict)

    @staticmethod
    def _parse_error(message, strict):
        # type: (str, bool) -> None
        if strict:
            raise ChangelogParseError(message)
        logger.warning(message)

    def parse_changelog(self,
                        file,             # type: Optional[IterableDataSource]
                        max_blocks=None,  # type: Optional[int]
                        allow_empty_author=False,  # type: bool
                        strict=True,      # type: bool
                        encoding=None,    # type: Optional[str]
                       ):
        # type: (...) -> None
        """ Read and parse a changelog file

        If you create an Changelog object without specifying a changelog
        file, you can parse a changelog file with this method. If the
        changelog doesn't parse cleanly, a :class:`ChangelogParseError`
        exception is thrown. The constructor will parse the changelog on
        a best effort basis.
        """
        first_heading = "first heading"
        next_heading_or_eof = "next heading of EOF"
        start_of_change_data = "start of change data"
        more_changes_or_trailer = "more change data or trailer"
        slurp_to_end = "slurp to end"

        encoding = encoding or self._encoding

        if file is None:
            self._parse_error('Empty changelog file.', strict)
            return

        self._blocks = []
        self.initial_blank_lines = []

        current_block = ChangeBlock(encoding=encoding)
        changes = []

        state = first_heading
        old_state = None
        if isinstance(file, bytes):
            file = file.decode(encoding)
        if isinstance(file, str):
            # Make sure the changelog file is not empty.
            if not file.strip():
                self._parse_error('Empty changelog file.', strict)
                return

            file = file.splitlines()
        for line in file:
            if not isinstance(line, str):
                line = line.decode(encoding)
            # Support both lists of lines without the trailing newline and
            # those with trailing newlines (e.g. when given a file object
            # directly)
            line = line.rstrip('\n')
            if state in (first_heading, next_heading_or_eof):
                top_match = topline.match(line)
                blank_match = blankline.match(line)
                if top_match is not None:
                    if (max_blocks is not None
                            and len(self._blocks) >= max_blocks):
                        return
                    current_block.package = top_match.group(1)
                    current_block._raw_version = top_match.group(2)
                    current_block.