
    )g                        S r SSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJrJrJrJrJrJr   SSKrSSKJr  \\\\\   \	\   \	\   4   r\R0                  " S5      r " S S\5      r " S S	\5      r " S
 S\5      r " S S5      r\R>                  " SSS0-  \R@                  5      r!\R>                  " S5      r"\R>                  " S5      r#\R>                  " S5      r$\R>                  " S5      r%\R>                  " S\R@                  5      r&\R>                  " S\R@                  5      r'\R>                  " S\R@                  5      r(\R>                  " S\R@                  5      r)\R>                  " S\R@                  5      r*\R>                  " S5      r+\R>                  " S5      r,\R>                  " S5      r-\R>                  " S\R@                  5      r.\R>                  " S\R@                  5      r/\R>                  " S5      r0\R>                  " S 5      r1\R>                  " S!\R@                  5      r2\R>                  " S"\R@                  5      r3\R>                  " S#\R@                  5      r4\R>                  " S$\R@                  5      r5\R>                  " S%\R@                  5      r6\R>                  " S&5      r7 " S' S(5      r8S) r9S.S*\\:   S+\;S,\<4S- jjr=g! \ a     GNf = f)/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


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:  # doctest: +SKIP
    ...     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)
DictIterableIteratorIOListOptionalPatternUnionTextTuple)Versionzdebian.changelogc                   J   ^  \ rS rSrSrSrS\SS4U 4S jjrS\4S jrS	r	U =r
$ )
ChangelogParseError   z0Indicates that the changelog could not be parsedTlinereturnNc                 6   > Xl         [        [        U ]  5         g N)_linesuperr   __init__)selfr   	__class__s     2/usr/lib/python3/dist-packages/debian/changelog.pyr   ChangelogParseError.__init__   s    
!413    c                      SU R                   -   $ )NzCould not parse changelog: r   r   s    r   __str__ChangelogParseError.__str__   s    ,TZZ77r   r   __name__
__module____qualname____firstlineno____doc__is_user_errorstrr   r    __static_attributes____classcell__r   s   @r   r   r      s/    :M4S 4T 48 8 8r   r   c                       \ rS rSrSrSrg)ChangelogCreateError   z\Indicates that changelog could not be created, as all the information
required was not given N)r#   r$   r%   r&   r'   r*   r0   r   r   r.   r.      s    r   r.   c                   J   ^  \ rS rSrSrSrS\SS4U 4S jjrS\4S jrS	r	U =r
$ )
VersionError   zBIndicates that the version does not conform to the required formatTversionr   Nc                 6   > Xl         [        [        U ]  5         g r   )_versionr   r2   r   )r   r4   r   s     r   r   VersionError.__init__   s    lD*,r   c                      SU R                   -   $ )NzCould not parse version: r6   r   s    r   r    VersionError.__str__   s    *T]]::r   r9   r"   r,   s   @r   r2   r2      s/    LM- - -; ; ;r   r2   c                       \ rS rSrSr          SS jrS rS r\" \\SS9r	S	 r
S
\\   4S jrS\S
S4S jrS\S
S4S jrS r\S
\\   4S j5       r\S
\\   4S j5       rSS jrS
\4S jrS rSrg)ChangeBlock   a  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.
Nc                    S U l         U R                  U5        Xl        X0l        U=(       d    SU l        U=(       d    SU l        U=(       d    / U l        Xpl        Xl        / U l	        U	=(       d    0 U l
        Xl        SU l        SU l        g )Nunknown F  )_raw_version_set_versionpackagedistributionsurgencyurgency_comment_changesauthordate	_trailingother_pairs	_encoding_no_trailer_trailer_separator)r   rD   r4   rE   rF   rG   changesrI   rJ   rL   encodings              r   r   ChangeBlock.__init__   s|     !'"*+).4"2	&,"! "&r   c                 H    U R                   c  g [        U R                   5      $ r   )rB   r   r   s    r   _get_versionChangeBlock._get_version   s"    $t(())r   c                 :    Ub  [        U5      U l        g S U l        g r   )r)   rB   r   r4   s     r   rC   ChangeBlock._set_version   s     #GD $Dr   z/The package version that this block pertains todocc                     0 nU R                   R                  5        HM  u  p#US   R                  5       USS R                  5       -   n[        R                  U5      nUc  SU-  nX1U'   MO     U$ )z9Obtain a dict from the block header (other than urgency) r      NzXS-%s)rL   itemsupperlowerxbcs_rematch)r   	norm_dictkeyvaluems        r   other_keys_normalised!ChangeBlock.other_keys_normalised   so     	 ,,224LSa&,,.3qr7==?2Cc"Aym"cN 5 r   r   c                     U R                   $ )z:Get the changelog entries for this block as a list of str )rH   r   s    r   rP   ChangeBlock.changes       }}r   r   c                 :    U R                   R                  U5        g)z+Add a sign-off (trailer) line to the block N)rK   append)r   r   s     r   add_trailing_lineChangeBlock.add_trailing_line  s    d#r   changec                 ^   U R                   (       d	  U/U l         gU R                   nUR                  5         Sn[        U5       H8  u  pEU(       d  M  UR                  5       (       a  M%  UR	                  XA5        Sn  O   UR                  5         U(       d  UR                  U5        X l         g)z#Append a change entry to the block FTN)rH   reverse	enumerateisspaceinsertrl   )r   ro   rP   addedich_entrys         r   
add_changeChangeBlock.add_change  s    }}#HDM mmGOOE(18H$4$4$6$6NN1- E	  2
 OOv&#Mr   c           	          SR                  U R                  5      n/ nUR                  U5       H[  nUR                  S5      n[        R                  " SU5       H,  nUR                  [        UR                  S5      5      5        M.     M]     U$ )N r   z\d+)joinrH   finditergrouprerl   int)r   type_rerP   bugsra   closes_listbugmatchs          r   _get_bugs_closed_generic$ChangeBlock._get_bugs_closed_generic  sq    ((4==)%%g.E++a.KKK<Cq 123 = / r   c                 ,    U R                  [        5      $ )z*List of (Debian) bugs closed by the block )r   closesr   s    r   bugs_closedChangeBlock.bugs_closed$  s     ,,V44r   c                 ,    U R                  [        5      $ )z+List of Launchpad bugs closed by the block )r   closeslpr   s    r   lp_bugs_closedChangeBlock.lp_bugs_closed)  s     ,,X66r   c                    SnU R                   c  [        S5      eX R                   S-   -  nU R                  c  [        S5      eUSU R                  -   S-   -  nU R                  c  [        S5      eX R                  S-   -  nU R                  c  [        S	5      eUS
U R                  -   U R
                  -   -  nU R                  R                  5        H  u  p4USU< SU< 3-  nM     US-  nU R                  5       c  [        S5      eU R                  5        H
  nX%S-   -  nM     U R                  (       dw  US-  nU R                  b  USU R                  -   -  nOU(       d  [        S5      eU R                  b  X R                  U R                  -   -  nOU(       d  [        S5      eUS-  nU R                   H
  nX&S-   -  nM     U$ )Nr@   zPackage not specifiedr{   zVersion not specified(z) zDistribution not specifiedz; zUrgency not specifiedzurgency=z, =
zChanges not specifiedz --zAuthor not specifiedzDate not specified)rD   r.   rB   rE   rF   rG   rL   r]   rP   rN   rI   rJ   rO   rK   )r   allow_missing_authorblockrc   rd   ro   r   s          r   _formatChangeBlock._format.  s    <<&'>??##$&'>??t(((4//%&'CDD##d**<<&'>??dll*T-A-AAA ,,224LS#u--E 5<<>!&'>??llnFd]"E %UNE{{&t{{**)*+ABByy$00499<<)*+?@@TMENNDD[ E #r   c                 "    U R                  5       $ r   r   r   s    r   r    ChangeBlock.__str__T      ||~r   c                 J    [        U 5      R                  U R                  5      $ r   r)   encoderM   r   s    r   	__bytes__ChangeBlock.__bytes__W       4y//r   )rH   rM   rN   rB   rO   rK   rI   rJ   rE   rL   rD   rF   rG   )
NNNNNNNNNutf-8F)r#   r$   r%   r&   r'   r   rT   rC   propertyr4   rf   r   r)   rP   rm   rx   r   r   r   r   r   r    r   r*   r0   r   r   r<   r<      s    2 #!%!!'8*% l=G

c $c $d $$ $ $( 5T#Y 5 5 7S	 7 7$L 0r   r<   z?^(\w%(name_chars)s*) \(([^\(\) \t]+)\)((\s+%(name_chars)s+)+)\;
name_charsz[-+0-9a-z.]z	^\s\s+.*$z[^ -- (.*) <(.*)>(  ?)((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4}\s*)$z`^ --(?: (.*) <(.*)>(  ?)((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4}))?\s*$z^(.*)\s+<(.*)>$z^([-0-9a-z]+)=\s*(.*\S)$z^([-0-9a-z]+)((\s+.*)?)$z	^X[BCS]+-z^(;;\s*)?Local variables:z^vim:z^\$\w+:.*\$z^\# z	^/\*.*\*/z5closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*zlp:\s+\#\d+(?:,\s*\#\d+)*zW^(\w+\s+\w+\s+\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\s+[\w\s]*\d{4})\s+(.*)\s+(<|\()(.*)(\)|>)z:^(\w+\s+\w+\s+\d{1,2},?\s*\d{4})\s+(.*)\s+(<|\()(.*)(\)|>)z&^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)\;?z"^([\w.+-]+)(-| )(\S+) Debian (\S+)z#^Changes from version (.*) to (.*):z$^Changes for [\w.+-]+-[\w.+-]+:?\s*$z^Old Changelog:\s*$z^(?:\d+:)?\w[\w.+~-]*:?\s*$c                      \ rS rSrSr     S8S jr\S\S\SS4S j5       r	    S9S	 jr
S
 rS r\" \\SS9r\" S SS9r\" S SS9r\" S SS9r\" S SS9r\" S SS9rS\\   4S jrS\SS4S jr\" \\SS9rS r\S 5       rS rS:S jrS\4S jrS  rS! rS" rS\ 4S# jr!S$\SS4S% jr"\" S& \"S'S9r#S(\SS4S) jr$\" S* \$S+S9r%S,\SS4S- jr&S. r'\" S/ \'S0S9r(S1\SS4S2 jr)\" S3 \)S4S9r*          S;S5 jr+S6 r,S7r-g)<	Changelogi  a  Represents a debian/changelog file.

To get the properly formatted changelog back out of the object
merely call `str()` on it. The returned string should be a properly
formatted changelog.

:param file: str, list of str, or file-like.
    The contents of the changelog, either as a ``str``, ``unicode`` object,
    or an iterator of lines such as a filehandle, (each line is either a
    ``str`` or ``unicode``)
:param max_blocks: int, optional (Default: ``None``, no limit)
    The maximum number of blocks to parse from the input.
:param allow_empty_author: bool, optional (Default: `False`),
    Whether to allow an empty author in the trailer line of a change
    block.
:param strict: bool, optional (Default: ``False``, use a warning)
    Whether to raise an exception if there are errors.
:param encoding: str,
    If the input is a str or iterator of str, the encoding to use when
    interpreting the input.

There are a number of errors that may be thrown by the module:

- :class:`ChangelogParseError`:
  Indicates that the changelog could not be parsed, i.e. there is a line
  that does not conform to the requirements, or a line was found out of
  its normal position. May be thrown when using the method
  `parse_changelog`.
  The constructor will not throw this exception.
- :class:`ChangelogCreateError`:
  Some information required to create the changelog was not available.
  This can be thrown when `str()` is used on the object, and will occur
  if a required value is `None`.
- :class:`VersionError`:
  The string used to create a Version object cannot be parsed as it
  doesn't conform to the specification of a version number. Can be
  thrown when creating a Changelog object from 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``.

Nc                 V    XPl         / U l        / U l        Ub  U R                  XUUS9  g g )N)
max_blocksallow_empty_authorstrict)rM   _blocksinitial_blank_linesparse_changelog)r   filer   r   r   rQ   s         r   r   Changelog.__init__  s?     "#%   #5 !  r   messager   r   c                 R    U(       a  [        U 5      e[        R                  U 5        g r   )r   loggerwarning)r   r   s     r   _parse_errorChangelog._parse_error  s    %g..wr   c                    SnSnSnSn	Sn
U=(       d    U R                   nUc  U R                  SU5        g/ U l        / U l        [	        US9n/ nUnSn[        U[        5      (       a  UR                  U5      n[        U[        5      (       a8  UR                  5       (       d  U R                  SU5        gUR                  5       nU GH  n[        U[        5      (       d  UR                  U5      nUR                  S	5      nXU4;   GaB  [        R                  U5      nUGb  Ub  [        U R                  5      U:  a    gUR                  S
5      Ul        UR                  S5      Ul        UR                  S5      R%                  5       Ul        UR)                  SS
5      S
   n0 n0 nUR)                  S5       GH  nUR                  5       n[*        R                  U5      nUc  U R                  SU-  U5        MC  UR                  S
5      nUR-                  5       nUR                  S5      nUU;   a  U R                  SU-  U5        UUU'   US:X  ad  [.        R                  U5      nUc  U R                  SU-  U5        M  UR                  S
5      Ul        UR                  S5      nUb	  UUl        M  M  UUU'   GM     UUl        UnGM	  U(       a  UR7                  5       (       aD  X:X  a  U R                  R9                  U5        GMH  U R                  S   R;                  U5        GMi  [<        R                  U5      n[>        R                  U5      n[@        R                  U5      n[B        R                  U5      n[D        R                  U5      nUc  Ub*  X:w  a%  U R                  S   R;                  U5        UnU
nGM  Uc  Uc  UbB  X:X  a  U R                  R9                  U5        OU R                  S   R;                  U5        GMM  [F        R                  U5      c  [H        R                  U5      c  [J        R                  U5      cn  [L        R                  U5      cX  [N        R                  U5      cB  [P        R                  U5      c,  [R        R                  U5      c  [T        R                  U5      b*  X:w  a%  U R                  S   R;                  U5        UnU
nGM'  U R                  SU< SU< 3U5        X:X  a  U R                  R9                  U5        GMd  U R                  S   R;                  U5        GM  XU	4;   Ga  [V        R                  U5      n [X        R                  U5      n!U b  UR9                  U5        U	nGM  U!b  U!R                  S5      S:w  a+  U R                  SU-  U5        U!R                  S5      Ul-        U!R                  S
5      < SU!R                  S5      < S3Ul.        U!R                  S5      Ul/        Xl0        U R                  R9                  U5        / n[	        US9nUnGM  [b        R                  U5      bP  U(       d  U R                  SU-  U5        GM  Xl0        U R                  R9                  U5        / n[	        US9nUnGM  U(       a  UR7                  5       (       a  UR9                  U5        GM  [@        R                  U5      n[B        R                  U5      n[D        R                  U5      nUc  Uc  Ub  UR9                  U5        GMy  U R                  SU< SU< 3U5        UR9                  U5        GM  X:X  a:  X:X  a!  U R                  S   R;                  U5        GM  UR9                  U5        GM   SU-  5       e   XU
4;  d
  X:X  aD  X:w  a>  U R                  SU-  U5        Xl0        SUl2        U R                  R9                  U5        ggg)a6  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.
zfirst headingznext heading of EOFzstart of change datazmore change data or trailerzslurp to endNzEmpty changelog file.rQ   r   r\         ;,z$Invalid key-value pair after ';': %szRepeated key-value: %srF   z!Badly formatted urgency value: %sz"Unexpected line while looking for z: rA   z Badly formatted trailer line: %sz <>   zUnknown state: %szFound eof where expected %sT)3rM   r   r   r   r<   
isinstancebytesdecoder)   strip
splitlinesrstriptoplinera   lenr~   rD   rB   lstriprE   splitkeyvaluer_   value_rerF   rG   rL   rs   rl   rm   emacs_variablesvim_variablescvs_keywordcommentsmore_commentsold_format_re1old_format_re2old_format_re3old_format_re4old_format_re5old_format_re6old_format_re7old_format_re8changereendlinerO   rI   rJ   rH   endline_nodetailsrN   )"r   r   r   r   r   rQ   first_headingnext_heading_or_eofstart_of_change_datamore_changes_or_trailerslurp_to_endcurrent_blockrP   state	old_stater   	top_matchpairsall_keysrL   pairkv_matchrc   	key_lowerrd   	val_matchcommentemacs_match	vim_match	cvs_matchcomments_matchmore_comments_matchchange_match	end_matchs"                                     r   r   Changelog.parse_changelog  s,     (35"?%-t~~<5v>#% #X6	dE"";;x(DdC  ::<<!!"96B??$DDdC(({{8, ;;t$D(;<<#MM$/	(". #DLL 1Z ?,5OOA,>M)1:1CM.2;//!2D2K2K2MM/ JJsA.q1E!H"$K %C 0#zz|#+>>$#7#+ -- F M &( %&nnQ/$'IIK	 (q 1$0 --!%'0!128: /4+$	1(0u(=I(0 $ 1 1$G$)%*+1!3 9B8J 5*3//!*<#*#6DKM$A $7 05K,9 !1: 1<M-0E-0077=R(::4@"1"7"7"=K - 3 3D 9I + 1 1$ 7I%-^^D%9N*7*=*=d*C'$0I4I % 6R(::4@$)	 , !-1K2> 1 44;;DA LL,>>tD '--d3?*006B*006B*006B*006B*006B*006B*006B % 6R(::4@$)	 , %%&'-/ -0077=R(::4@1HII'~~d3#MM$/	+NN4(3E* q)T1))>EvO;D??1;M8$??1-yq/A,CM()2);M&-4*LL''6 G$/$BM/E&,,T2>-))>EvO -4*LL''6 G$/$BM/ENN4( + 1 1$ 7I%-^^D%9N*7*=*=d*C'!-1K2>t, %%&'-/ NN4(&3LL$66t<NN4(91E99ua d |<<)!8-5v?%,"(,M%LL. 9 *r   c                 4    U R                   S   R                  $ )z,Return a Version object for the last versionr   r   r4   r   s    r   get_versionChangelog.get_version  s     ||A&&&r   c                 >    [        U5      U R                  S   l        g)zgSet the version of the last changelog block

version can be a full version string, or a Version object
r   N)r   r   r4   rW   s     r   set_versionChangelog.set_version  s     #*'"2Qr   zhVersion object for latest changelog block.
            (Property that can both get and set the version.)rY   c                 .    U R                   R                  $ r   )r4   full_versionr   s    r   <lambda>Changelog.<lambda>  s    T\\..r   z+The full version number of the last versionc                 .    U R                   R                  $ r   )r4   epochr   s    r   r   r     s    T\\''r   zFThe epoch number of the last revision, or `None` if no epoch was used.c                 .    U R                   R                  $ r   r4   debian_revisionr   s    r   r   r         T\\11r   z:The debian part of the version number of the last version.c                 .    U R                   R                  $ r   r  r   s    r   r   r     r  r   c                 .    U R                   R                  $ r   )r4   upstream_versionr   s    r   r   r     s    T\\22r   z<The upstream part of the version number of the last version.c                 4    U R                   S   R                  $ )z2Returns the name of the package in the last entry.r   r   rD   r   s    r   get_packageChangelog.get_package  s    ||A&&&r   rD   c                 *    XR                   S   l        g)z/set the name of the package in the last entry. r   Nr  )r   rD   s     r   set_packageChangelog.set_package  s    ")Qr   z'Name of the package in the last versionc                     U R                   $ r   )versionsr   s    r   get_versionsChangelog.get_versions  rj   r   c                 X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )zbReturns a list of :class:`debian.debian_support.Version` objects
that are listed in the changelog.r   r   r   s     r   r  Changelog.versions  s"    
 ,0<<8<%<888   'c                 X    U R                    Vs/ s H  oR                  PM     sn$ s  snf r   )r   rB   r  s     r   _raw_versionsChangelog._raw_versions  s"    04=u""===r  c                     / nU R                    H  nUR                  US-   5        M     U R                   H!  nUR                  UR                  US95        M#     SR	                  U5      $ )Nr   )r   r@   )r   rl   r   r   r|   )r   r   piecesr   r   s        r   r   Changelog._format  s[    ,,DMM$+& -\\EMM%--=Q-RS "wwvr   c                 "    U R                  5       $ r   r   r   s    r   r    Changelog.__str__  r   r   c                 J    [        U 5      R                  U R                  5      $ r   r   r   s    r   r   Changelog.__bytes__  r   r   c                 ,    [        U R                  5      $ r   )iterr   r   s    r   __iter__Changelog.__iter__  s    DLL!!r   c                     [        U[        5      (       a  U [        U5         $ [        U[        5      (       a  UnOU R                  R                  U5      nU R                  U   $ )zselect a changelog entry by number, version string, or Version

:param n: integer or str representing a version or Version object
)r   r)   r   r   r  indexr   )r   nidxs      r   __getitem__Changelog.__getitem__  sU     a
##aC--%%a(C||C  r   c                 ,    [        U R                  5      $ r   )r   r   r   s    r   __len__Changelog.__len__  s    4<<  r   rE   c                 *    XR                   S   l        g Nr   r   rE   )r   rE   s     r   set_distributionsChangelog.set_distributions  s    (5Q%r   c                 4    U R                   S   R                  $ r.  r/  r   s    r   r   r     s    T\\!_22r   zfA string indicating the distributions that the package will be uploaded to
in the most recent version.rF   c                 *    XR                   S   l        g r.  r   rF   )r   rF   s     r   set_urgencyChangelog.set_urgency  s    ")Qr   c                 4    U R                   S   R                  $ r.  r4  r   s    r   r   r   "  s    T\\!_,,r   zTA string indicating the urgency with which the most recent version will
be uploaded.ro   c                 @    U R                   S   R                  U5        g)a  and a new dot point to a changelog entry

Adds a change entry to the most recent version. The change entry
should conform to the required format of the changelog (i.e. start
with two spaces). No line wrapping or anything will be performed,
so it is advisable to do this yourself if it is a long entry. The
change will be appended to the current changes, no support is
provided for per-maintainer changes.
r   N)r   rx   )r   ro   s     r   rx   Changelog.add_change(  s     	Q""6*r   c                 *    XR                   S   l        g)z*set the author of the top changelog entry r   Nr   rI   )r   rI   s     r   
set_authorChangelog.set_author4  s     "(Qr   c                 4    U R                   S   R                  $ r.  r;  r   s    r   r   r   :  s    T\\!_++r   zj        The author of the most recent change.
        This should be a properly formatted name/email pair.rJ   c                 *    XR                   S   l        g)z~set the date of the top changelog entry

:param date: str
    a properly formatted date string (`date -R` format; see Policy)
r   Nr   rJ   )r   rJ   s     r   set_dateChangelog.set_date@  s      $Qr   c                 4    U R                   S   R                  $ r.  r@  r   s    r   r   r   I  s    T\\!_))r   z        The date associated with the current entry.
        Should be a properly formatted string with the date and timezone.
        See the :func:`format_date()` function.c                     U
=(       d    U R                   n
[        XUXEXgXU
5
      nU R                  (       a  UR                  S5        U R                  R	                  SU5        g)a  Add a new changelog block to the changelog

Start a new :class:`ChangeBlock` entry representing a new version
of the package. The arguments (all optional) are passed directly
to the :class:`ChangeBlock` constructor; they specify the values
that can be provided to the `set_*` methods of this class. If
they are omitted the associated attributes *must* be assigned to
before the changelog is formatted as a str or written to a file.
r@   r   N)rM   r<   r   rm   rt   )r   rD   r4   rE   rF   rG   rP   rI   rJ   rL   rQ   r   s               r   	new_blockChangelog.new_blockP  sV    , -t~~Gm##TJ <<##B'Au%r   c                 8    UR                  [        U 5      5        g)zWrite the changelog entry to a filehandle

Write the changelog out to the filehandle passed. The file argument
must be an open file object.
N)writer)   )r   
filehandles     r   write_to_open_fileChangelog.write_to_open_fileo  s     	T#r   )r   rM   r   )NNFFr   )NFTNr   )
NNNNNNNNNN).r#   r$   r%   r&   r'   r   staticmethodr)   boolr   r   r   r   r   r4   r   r   debian_versionr  r  r   r	  r  rD   r  r  r  r   r    r   r"  r(  r   r+  r0  rE   r5  rF   rx   r<  rI   rA  rJ   rE  rJ  r*   r0   r   r   r   r     s0   5r  $)!"  c  4  D     $(+0#!%F/P'
3 [AG .9L ' E
 1HN 1HO  2J
'Xc] '*3 *4 * [5G
 9 9> 0
"!! !6s 6t 6 24EM*3 *4 * ,kG
+ 
+ 
+(
 +Z@F$S $T $ )83D  $"&"&>$r   r   c                     [         R                  n SU ;   aM  [        R                  U S   5      nU(       a.  SU ;  a  UR	                  S5      U S'   UR	                  S5      U S'   SU ;  d  SU ;  aS  SU ;   aM  [        R                  U S   5      nU(       a.  SU ;  a  UR	                  S5      U S'   UR	                  S5      U S'   SnSU ;   a  U S   nOVSU ;   a  U S   nOJ [
        R                  " SS	[        R                  " [         R                  " 5       5      R                  5      nSnSU ;   a  U S   nX#4$ SU ;   a  U S   nX#4$ Sn[         R                  R                  S
5      (       a1  [!        S
SS9 nUR#                  5       R%                  5       nSSS5        U(       d  [&        R(                  " 5       nU(       aH   [        R                  " [         R                  " 5       5      R*                  nU(       d  SnO
U< SU< 3n U(       a  UnX#4$ ! [        [        [        4 a     GNf = f! , (       d  f       N= f! [        [        4 a    Sn NMf = f)a  Get the maintainer information in the same manner as dch.

This function gets the information about the current user for
the maintainer field using environment variables of gecos
information as appropriate.

It uses the same algorithm as dch to get the information, namely
DEBEMAIL, DEBFULLNAME, EMAIL, NAME, /etc/mailname and gecos.

:returns: a tuple of the full name, email pair as strings.
    Either of the pair may be None if that value couldn't
    be determined.
DEBEMAILDEBFULLNAMEr\   r   EMAILNNAMEz,.*r@   z/etc/mailnamezUTF-8r   @)osenvironmaintainerrera   r~   r   subpwdgetpwuidgetuidpw_gecosKeyErrorAttributeError	NameErrorpathexistsopenreadliner   socketgetfqdnpw_name)env	match_obj
maintaineremail_addressaddrfusers          r   get_maintainerrn  y  s    **C S &&s:7	C'%.__Q%7M"'ooa0C
OS 8c>$**3w<8I +)2);C&(q1G J'
	3[
	CLL,E,N,NOJ MSJ2 &&1 
CG. &&+ 77>>/**o8Azz|))+ 9>>#D	2||BIIK088
 D&*D1D M&&? .)4 		 98 #I. s1   A	H 5H/ 3I  H,+H,/
H= II	timestamp	localtimer   c                 @    [         R                  R                  X5      $ )a  format a datestamp in the required format for the changelog

:param timestamp: float, optional. The timestamp (seconds since epoch)
    for which the date string should be created. If not specified, the
    current time is used.
:param localtime: bool, optional (default True). Use the local timezone
    in the date string.

:returns: str, date stamp formatted according to the changelog
    specification (i.e. RFC822).
)emailutils
formatdate)ro  rp  s     r   format_dateru    s     ;;!!)77r   )NT)>r'   email.utilsrr  loggingrU  r   rd  typingr   r   r   r   r   r   r	   r
   r   r   rY  ImportErrordebian.debian_supportr   r   IterableDataSource	getLoggerr   	Exceptionr   r.   r2   r<   compile
IGNORECASEr   r   r   r   rW  r   r   r`   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn  floatrM  r)   ru  r0   r   r   <module>r     s  JF   	 	   	 * 	tHTNUO	  
		-	.	8) 	89 

;9 
;q0 q0h **!]#$ MM	
 ::l#
**23 JJ  zz,-::12==A::12==A
**["--
0**92==I

7BMM2jj(::g

<(	<MM
 ::2BMMB23  -MM )MM )MM +MM 2BMMB:;h$ h$VJ'Z88E? 8d 8c 8Y  		s   K K$#K$