File: //proc/1233/cwd/usr/lib/python3/dist-packages/debian/__pycache__/changelog.cpython-38.pyc
U
���aЗ � @ s\ d Z ddlZddlZddlZddlZddlZzddlZW n ek
rL Y nX zZddl m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZ eeeee ee ee f ZW n ek
r� Y nX ddlmZ G dd� de�ZG dd� de�ZG d d
� d
e�ZG dd� de�Ze� d
ddi ej!�Z"e� d�Z#e� d�Z$e� d�Z%e� d�Z&e� d�Z'e� dej!�Z(e� dej!�Z)e� dej!�Z*e� dej!�Z+e� dej!�Z,e� d�Z-e� d�Z.e� d�Z/e� dej!�Z0e� dej!�Z1e� d�Z2e� d �Z3e� d!ej!�Z4e� d"ej!�Z5e� d#ej!�Z6e� d$ej!�Z7e� d%ej!�Z8e� d&�Z9G d'd(� d(e�Z:d)d*� Z;d.d,d-�Z<dS )/a�
Facilities for reading and writing Debian changelogs
The aim of this module is to provide programmatic access to Debian changelogs
to query and manipulate them. The format for the changelog is defined in
`deb-changelog(5)
<https://manpages.debian.org/stretch/dpkg-dev/deb-changelog.5.html>`_
Stability: The API is not marked as stable but hasn't changed incompatibly
since 2007. Potential users of these classes are asked to work with the
`python-debian` maintainers to improve, extend and stabilise this API.
Overview
========
Create a changelog object using the constuctor. Pass it the contents of the
file if there are some entries, or ``None`` to create an empty changelog::
>>> import debian.changelog
>>> ch = debian.changelog.Changelog()
>>> maintainer, email = 'John Doe', 'joe@example.com'
>>> timestamp = 1617222715
>>> # You might want to use get_maintainer() a la:
>>> # maintainer, email = debian.changelog.get_maintainer()
>>> ch.new_block(
... package='example',
... version='0.1',
... distributions='unstable',
... urgency='low',
... author="%s <%s>" % (maintainer, email),
... # You can also omit timestamp, if you are fine with "now"
... # We use a hard-coded timestamp for deterministic output
... date=debian.changelog.format_date(timestamp=1617222715, localtime=False)
... )
>>> ch.add_change('')
>>> ch.add_change(' * Some change')
>>> ch.add_change('')
>>> print(ch, end='')
example (0.1) unstable; urgency=low
<BLANKLINE>
* Some change
<BLANKLINE>
-- John Doe <joe@example.com> Wed, 31 Mar 2021 20:31:55 -0000
<BLANKLINE>
If you have the full contents of a changelog, but are only interested in the
most recent versions you can pass the ``max_blocks`` keyword parameter to the
constuctor to limit the number of blocks of the changelog that will be parsed.
If you are only interested in the most recent version of the package then pass
``max_blocks=1``::
>>> import gzip
>>> from debian.changelog import Changelog
>>> with gzip.open('/usr/share/doc/dpkg/changelog.Debian.gz') as fh:
... ch = Changelog(fh, max_blocks=1)
>>> print('''
... Package: %s
... Version: %s
... Urgency: %s''' % (ch.package, ch.version, ch.urgency)) # doctest: +SKIP
Package: dpkg
Version: 1.18.24
Urgency: medium
See `/usr/share/doc/python-debian/examples/changelog/` or the
`git repository
<https://salsa.debian.org/python-debian-team/python-debian/tree/master/
examples/changelog>`_
for examples of usage.
The :class:`Changelog` class is the key class within this module.
Changelog Classes
-----------------
� N)�Any�Dict�Iterable�Iterator�IO�List�Optional�Pattern�Union�Text�Tuple�TypeVar)�Versionc s, e Zd ZdZdZ� fdd�Zdd� Z� ZS )�ChangelogParseErrorz0Indicates that the changelog could not be parsedTc s || _ tt| ��� d S �N)�_line�superr �__init__��self�line�� __class__� �2/usr/lib/python3/dist-packages/debian/changelog.pyr � s zChangelogParseError.__init__c C s
d| j S )NzCould not parse changelog: )r �r r r r �__str__� s zChangelogParseError.__str__��__name__�
__module__�__qualname__�__doc__Z
is_user_errorr r �
__classcell__r r r r r � s r c @ s e Zd ZdZdS )�ChangelogCreateErrorz`Indicates that changelog could not be created, as all the information
required was not givenN)r r r r! r r r r r# � s r# c s, e Zd ZdZdZ� fdd�Zdd� Z� ZS )�VersionErrorzBIndicates that the version does not conform to the required formatTc s || _ tt| ��� d S r )�_versionr r$ r �r �versionr r r r � s zVersionError.__init__c C s
d| j S )NzCould not parse version: )r% r r r r r � s zVersionError.__str__r r r r r r$ � s r$ c
@ s� e Zd ZdZd!dd�Zdd� Zdd � Zeeed
d�Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
edd� �Zedd� �Zd"dd�Zdd� Zdd � ZdS )#�ChangeBlocka! Holds all the information about one block from the changelog.
See `deb-changelog(5)
<https://manpages.debian.org/stretch/dpkg-dev/deb-changelog.5.html>`_
for more details about the format of the changelog block and the
necessary data.
:param package: str, name of the package
:param version: str or Version, version of the package
:param distributions: str, distributions to which the package is
released
:param urgency: str, urgency of the upload
:param urgency_comment: str, comment about the urgency setting
:param changes: list of str, individual changelog entries for this
block
:param author: str, name and email address of the changelog author
:param date: str, date of the changelog in RFC822 (`date -R`) format
:param other_pairs: dict, key=value pairs from the header of the
changelog, other than the urgency value that is specified
separately
:param encoding: specify the encoding to be used; note that Debian
Policy mandates the use of UTF-8.
N�utf-8c C sl d | _ | �|� || _|| _|p"d| _|p,d| _|p6g | _|| _|| _g | _ | pRi | _
|
| _d| _d| _
d S )N�unknown� F� )�_raw_version�_set_version�package�
distributions�urgency�urgency_comment�_changes�author�date� _trailing�other_pairs� _encoding�_no_trailer�_trailer_separator)r r/ r'