
    )g:y                        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JrJr  SSKJrJrJrJrJr  SSKJrJr   SSKJr  \S   r\S   rS	r \!" \ /5      r"\RF                  " \$5      r% " S
 S\&5      r' " S S\'5      r( " S S\'\)5      r*S\+S\,SS4S jr- " S S5      r.S\+S\+4S jr/ " S S5      r0 " S S5      r1S\\+   S\\+   4S jr2S r3S r4S\+S\\+   4S jr5 " S  S!\Rl                  " S!S"5      5      r7S# r8 " S$ S%\95      r: " S& S'\:S(9r; " S) S*\;5      r< " S+ S,\;5      r= " S- S.\;5      r>g! \ a     Nf = f)/a9  Utilities for parsing and creating machine-readable debian/copyright files.

The specification for the format (also known as DEP5) is available here:
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Start from the Copyright docstring for usage information.

Copyright Classes
-----------------
    N)Any	FrozenSetIOIterableIteratorListOptionalPatternTextTupleUnioncast)parse_deb822_fileDeb822ParagraphElementDeb822FileElement'Deb822NoDuplicateFieldsParagraphElementSyntaxOrParseError)RestrictedFieldRestrictedFieldError)Deb822ValueType)FilesParagraphLicenseParagraph)Headerr   r   zBhttps://www.debian.org/doc/packaging-manuals/copyright-format/1.0/c                       \ rS rSrSrSrg)ErrorP   z)Base class for exceptions in this module. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       2/usr/lib/python3/dist-packages/debian/copyright.pyr   r   P   s    3r%   r   c                       \ rS rSrSrSrg)NotMachineReadableErrorT   zFRaised when the input is not a machine-readable debian/copyright file.r   Nr   r   r%   r&   r(   r(   T   s    Pr%   r(   c                       \ rS rSrSrSrg)MachineReadableFormatErrorX   zRaised when the input is not valid.

This is both a `copyright.Error` and a `ValueError` to ease handling of
errors coming from this module.
r   Nr   r   r%   r&   r+   r+   X   s    r%   r+   msgstrictreturnc                 R    U(       a  [        U 5      e[        R                  U 5        g N)r+   loggerwarning)r-   r.   s     r&   	_complainr4   `   s    (--
NN3r%   c                      ^  \ rS rSrSrSU 4S jjr\S 5       r\R                  S 5       rS r	S r
S rS	 rS
 rS rS rSS jrSrU =r$ )	Copyrightf   a%  Represents a debian/copyright file.

A Copyright object contains a Header paragraph and a list of additional
Files or License paragraphs.  It provides methods to iterate over those
paragraphs, in addition to adding new ones.  It also provides a mechanism
for finding the Files paragraph (if any) that matches a particular
filename.

Typical usage::

    with io.open('debian/copyright', 'rt', encoding='utf-8') as f:
        c = copyright.Copyright(f)

        header = c.header
        # Header exposes standard fields, e.g.
        print('Upstream name: ', header.upstream_name)
        lic = header.license
        if lic:
            print('Overall license: ', lic.synopsis)
        # You can also retrieve and set custom fields.
        header['My-Special-Field'] = 'Very special'

        # Find the license for a given file.
        paragraph = c.find_files_paragraph('debian/rules')
        if paragraph:
            print('License for debian/rules: ', paragraph.license)

        # Dump the result, including changes, to another file.
        with io.open('debian/copyright.new', 'wt', encoding='utf-8') as f:
            c.dump(f=f)

It is possible to build up a Copyright from scratch, by modifying the
header and using add_files_paragraph and add_license_paragraph.  See the
associated method docstrings.
c                   > [         [        U ]  5         / U l        Ub  Sn [	        XU(       + S9U l        U R
                   Hz  nUc  [        U5      nM  SU;   a'  [        XcUS9nU R                  R                  U5        M@  SU;   a(  [        Xc5      nU R                  R                  U5        Mn  [        SU5        M|     U(       d  [        S5      eX@l        g[        R                   " 5       U l        [        5       U l        U R
                  R                  U R                  R"                  5        U R                  R                  U R                  5        g! [         a  n[        [        U5      5      eSnAff = f)ay  Create a new copyright file in the current format.

:param sequence: Sequence of lines, e.g. a list of strings or a
    file-like object.  If not specified, a blank Copyright object is
    initialized.
:param encoding: Encoding to use, in case input is raw byte strings.
    It is recommended to use unicode objects everywhere instead, e.g.
    by opening files in text mode.
:param strict: Raise if format errors are detected in the data.

Raises:
    :class:`NotMachineReadableError` if 'sequence' does not contain a
        machine-readable debian/copyright file.
    MachineReadableFormatError if 'sequence' is not a valid file.
N)sequenceencoding#accept_files_with_duplicated_fieldsFiles)r.   Licensez=Non-header paragraph has neither "Files" nor "License" fieldszno paragraphs in input)superr6   __init___Copyright__paragraphsr   _Copyright__filer   r(   strr   r   appendr   r4   _Copyright__headerr   new_empty_file_underlying_paragraph)
selfr9   r:   r.   headereppfpl	__class__s
            r&   r?   Copyright.__init__   s?   " 	i')F6/!)@FJH
 [[>#AYF\'&AB%%,,R0!^)!4B%%,,R0 128: ! -.FGG"M ,::<DK"HDMKKt}}BBC$$T]]3- & 6-c!f556s   E 
E9 E44E9c                     U R                   $ )zThe file header paragraph.)rD   rG   s    r&   rH   Copyright.header   s     }}r%   c                 P    [        U[        5      (       d  [        S5      eXl        g )Nzvalue must be a Header object)
isinstancer   	TypeErrorrD   )rG   hdrs     r&   rH   rQ      s"     #v&&;<<r%   c                 h    [         R                  " U R                  /S U R                   5       5      $ )zReturns an iterator over all paragraphs (header, Files, License).

The header (returned first) will be returned as a Header object; file
paragraphs as FilesParagraph objects; license paragraphs as
LicenseParagraph objects.

c              3   $   #    U  H  ov   M     g 7fr1   r   .0rJ   s     r&   	<genexpr>+Copyright.all_paragraphs.<locals>.<genexpr>   s     .L:KQq:Ks   )	itertoolschainrH   r@   rP   s    r&   all_paragraphsCopyright.all_paragraphs   s'     }.L$:K:K.LMMr%   c                 "    U R                  5       $ )zHIterate over all paragraphs

see all_paragraphs() for more information

)r^   rP   s    r&   __iter__Copyright.__iter__   s     ""$$r%   c                 (    S U R                    5       $ )z>Returns an iterator over the contained FilesParagraph objects.c              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fr1   )rS   r   rX   s     r&   rZ   1Copyright.all_files_paragraphs.<locals>.<genexpr>   s     N,a
1n0M,   (	(r@   rP   s    r&   all_files_paragraphsCopyright.all_files_paragraphs   s     O4,,NNr%   c                 l    SnU R                  5        H  nUR                  U5      (       d  M  UnM     U$ )zReturns the FilesParagraph for the given filename.

In accordance with the spec, this method returns the last FilesParagraph
that matches the filename.  If no paragraphs matched, returns None.
N)rh   matches)rG   filenameresultrJ   s       r&   find_files_paragraphCopyright.find_files_paragraph   s7     **,Ayy"" - r%   c                 F   [        U[        5      (       d  [        S5      eSn[        U R                  5       H  u  p4[        U[        5      (       d  M  UnM      U R                  R                  US-   U5        U R                  R                  US-   UR                  5        g)zAdds a FilesParagraph to this object.

The paragraph is inserted directly after the last FilesParagraph (which
might be before a standalone LicenseParagraph).
z+paragraph must be a FilesParagraph instance      N)rS   r   rT   	enumerater@   insertrA   rF   )rG   	paragraphlast_iirJ   s        r&   add_files_paragraphCopyright.add_files_paragraph   s     )^44IJJd//0DA!^,, 1 	  !Y76A:y'F'FGr%   c                 (    S U R                    5       $ )z=Returns an iterator over standalone LicenseParagraph objects.c              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fr1   )rS   r   rX   s     r&   rZ   3Copyright.all_license_paragraphs.<locals>.<genexpr>  s     P,a
1>N0O,rf   rg   rP   s    r&   all_license_paragraphs Copyright.all_license_paragraphs  s     Q4,,PPr%   c                     [        U[        5      (       d  [        S5      eU R                  R	                  U5        U R
                  R	                  UR                  5        g)z_Adds a LicenceParagraph to this object.

The paragraph is inserted after any other paragraphs.
z-paragraph must be a LicenseParagraph instanceN)rS   r   rT   r@   rC   rA   rF   )rG   rv   s     r&   add_license_paragraphCopyright.add_license_paragraph  sJ     )%566KLL  +9::;r%   c                 d    U R                   R                  5       nUb  UR                  U5        gU$ )a9  Dumps the contents of the copyright file.

If f is None, returns a unicode object.  Otherwise, writes the contents
to f, which must be a file-like object that is opened in text mode
(i.e. that accepts unicode objects directly).  It is thus up to the
caller to arrange for the file to do any appropriate encoding.
N)rA   dumpwrite)rG   fss      r&   r   Copyright.dump  s.     KK=GGAJr%   )__file__header__paragraphs)Nzutf-8Tr1   )r   r    r!   r"   r#   r?   propertyrH   setterr^   ra   rh   rn   ry   r~   r   r   r$   __classcell__rM   s   @r&   r6   r6   f   sl    "H14f  
 ]] 	N%O
H"Q
	< r%   r6   r   c                 (    SU ;   a  [        S5      eU $ )zNReturns s if it is a single line; otherwise raises MachineReadableFormatError.
zmust be single line)r+   r   s    r&   _single_liner   #  s    qy()>??Hr%   c                   8    \ rS rSrSr\S 5       r\S 5       rSrg)
_LineBasedi*  z@Namespace for conversion methods for line-based lists as tuples.c                 ~    [        S S U =(       d    SR                  5       R                  5        5        5       5      $ )z?Returns the lines in 's', with whitespace stripped, as a tuple.c              3   8   #    U  H  nU(       d  M  Uv   M     g 7fr1   r   rY   vs     r&   rZ   &_LineBased.from_str.<locals>.<genexpr>2  s      N  QNs   	c              3   @   #    U  H  oR                  5       v   M     g 7fr1   )strip)rY   lines     r&   rZ   r   3  s     N/Mtjjll/Ms    )tupler   
splitlinesr   s    r&   from_str_LineBased.from_str.  s7      NR/@/K/K/MN  	r%   c                     [        U 5      nU(       d  gS n[        U5      S:X  a  U" US   5      $ S/nU H  nUR                  SU" U5      -   5        M     SR                  U5      $ )zReturns the sequence as a string with each element on its own line.

If 'seq' has one element, the result will be on a single line.
Otherwise, the first line will be blank.
Nc                 l    U R                  5       n U (       d  [        S5      eSU ;   a  [        S5      eU $ )Nvalues must not be emptyr   z values must not contain newlines)r   r+   r   s    r&   process_and_validate/_LineBased.to_str.<locals>.process_and_validateB  s8    	A01KLLqy068 8Hr%   rr   r   r    r   )listlenrC   join)seqlr   tmpr   s        r&   to_str_LineBased.to_str6  sj     I	 q6Q;'!--dAJJs1!445 yy~r%   r   N)	r   r    r!   r"   r#   staticmethodr   r   r$   r   r%   r&   r   r   *  s-    J    r%   r   c                   \    \ rS rSrSr\R                  " S5      r\S 5       r	\
S 5       rSrg)_SpaceSeparatediU  zENamespace for conversion methods for space-separated lists as tuples.z\sc                 T    [        S U =(       d    SR                  5        5       5      $ )z>Returns the values in s as a tuple (empty if only whitespace).c              3   6   #    U  H  o(       d  M  Uv   M     g 7fr1   r   r   s     r&   rZ   +_SpaceSeparated.from_str.<locals>.<genexpr>_  s     7 11QQQ 1s   
	r   )r   splitr   s    r&   r   _SpaceSeparated.from_str[  s      7b 1777r%   c                    [        U5      nU(       d  g/ nU Ha  nU R                  R                  U5      (       a  [        S5      eUR	                  5       nU(       d  [        S5      eUR                  U5        Mc     SR                  U5      $ )zAReturns the sequence as a space-separated string (None if empty).Nz"values must not contain whitespacer   r   )r   
_has_spacesearchr+   r   rC   r   )clsr   r   r   r   s        r&   r   _SpaceSeparated.to_stra  s|     IA~~$$Q''08: :	A01KLLJJqM  xx}r%   r   N)r   r    r!   r"   r#   recompiler   r   r   classmethodr   r$   r   r%   r&   r   r   U  s;    O E"J8 8
  r%   r   c                 <    U c  g[        U R                  5       5      $ )zFormats multiline text for insertion in a Deb822ParagraphElement field.

Each line except for the first one is prefixed with a single space.  Lines
that are blank or only whitespace are replaced with ' .'
N)format_multiline_linesr   r   s    r&   format_multiliner   v  s     	y!!,,.11r%   c                     / n[        U 5       H8  u  p#US:w  a  UR                  5       (       d  SnSU-   nUR                  U5        M:     SR                  U5      $ )z?Same as format_multline, but taking input pre-split into lines.r   .r   r   )rt   r   rC   r   )lines	out_linesrx   r   s       r&   r   r     sY     IU#6::<<:D $ 99Yr%   c                 >    U c  gSR                  [        U 5      5      $ )aO  Inverse of format_multiline.

Technically it can't be a perfect inverse, since format_multline must
replace all-whitespace lines with ' .'.  Specifically, this function:

  - Does nothing to the first line
  - Removes first character (which must be ' ') from each proceeding line.
  - Replaces any line that is '.' with an empty line.
Nr   )r   parse_multiline_as_linesr   s    r&   parse_multiliner     s!     	y99-a011r%   c                     U R                  5       n[        U5       H@  u  p#US:X  a  M  UR                  S5      (       a  USS nO[        S5      eUS:X  a  SnX1U'   MB     U$ )zhSame as parse_multiline, but returns a list of lines.

(This is the inverse of format_multiline_lines.)
r   r   rr   Nz"continued line must begin with " "r   r   )r   rt   
startswithr+   )r   r   rx   r   s       r&   r   r     sn    
 LLNEU#6??38D,46 63;Da $ Lr%   c                   N   ^  \ rS rSrSrSU 4S jjr\S 5       rS\4S jr	Sr
U =r$ )	r=   i  z7Represents the contents of a License field.  Immutable.c                 N   > [         [        U ]  U [        U5      U=(       d    SS9$ )at  Creates a new License object.

:param synopsis: The short name of the license, or an expression giving
    alternatives.  (The first line of a License field.)
:param text: The full text of the license, if any (may be None).  The
    lines should not be mangled for "deb822"-style wrapping - i.e. they
    should not have whitespace prefixes or single '.' for empty lines.
r   )synopsistext)r>   r=   __new__r   )r   r   r   rM   s      r&   r   License.__new__  s0     Wc*,x0
 + E 	Er%   c           
          Uc  g [        U5      nU(       d  U " S5      $ U " US   SR                  [        R                  " USS 5      5      S9$ )Nr   r   r   rr   )r   )r   r   r\   islice)r   r   r   s      r&   r   License.from_str  sK     9(+r7N58$))I,<,<UAt,L"MNNr%   r/   c                 d    [        U R                  /U R                  R                  5       -   5      $ r1   )r   r   r   r   rP   s    r&   r   License.to_str  s%    %t}}o		8L8L8N&NOOr%   r   )r   )r   r    r!   r"   r#   r   r   r   rB   r   r$   r   r   s   @r&   r=   r=     s6    AE O OP P Pr%   r=   zsynopsis textc                    [         R                  " 5       n[        U 5       H  u  p#US:w  a  UR                  S5        Sn[	        U5      nX$:  d  M0  X2   nUS-  nUS:X  a  UR                  S5        OUS:X  a  UR                  S5        OUS:X  aT  X$:  a
  X2   nUS-  nO[        S	5      eUS
;   a&  UR                  [        R                  " U5      5        O3[        SU-  5      eUR                  [        R                  " U5      5        X$:  a  M  M     [        R                  " UR                  5       [        R                  [        R                  -  5      $ )a  Returns an re object for the given globs.

Only * and ? wildcards are supported.  Literal * and ? may be matched via
\* and \?, respectively.  A literal backslash is matched \\.  Any other
character after a backslash is forbidden.

Empty globs match nothing.

The pattern should be used with the `re.fullmatch` function to provide
anchoring.

Raises MachineReadableFormatError if any of the globs is illegal.
r   |rr   *z.*?r   \z#single backslash not allowed at endz\?*zinvalid escape sequence: \%s)ioStringIOrt   r   r   r+   r   escaper   getvalue	MULTILINEDOTALL)globsbufrx   globncs         r&   globs_to_rer     s    ++-CU#6IIcNIeAFACx		$c		#d5AFA4=? ?;IIbiil+47!;= = 		"))A,') e $6 ::cllnbllRYY&>??r%   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_ClassInitMetai  am  Metaclass for classes that can be initialized at creation time.

Implement the method::

  @classmethod
  def _class_init(cls, new_attrs):
      pass

on a class, and apply this metaclass to it.  The _class_init method will be
called right after the class is created.  The 'new_attrs' param is a dict
containing the attributes added in the definition of the class.
c                 P   > [         [        U ]  XU5        U R                  U5        g r1   )r>   r   r?   _class_init)r   namebasesattrsrM   s       r&   r?   _ClassInitMeta.__init__  s"     	nc+D?r%   r   )r   r    r!   r"   r#   r?   r$   r   r   s   @r&   r   r     s     r%   r   c                      ^  \ rS rSrSr\" 5       r\S 5       r\S 5       r	SU 4S jjr
\S 5       rS rS rS	 rS
 rS\4S jr   SS jrSrU =r$ )_RestrictedWrapperi  a  Base class to wrap a Deb822 object, restricting write access to some keys.

The underlying data is hidden internally.  Subclasses may keep a reference
to the data before giving it to this class's constructor, if necessary, but
RestrictedField should cover most use-cases.  The dump method from
Deb822 is directly proxied.

Typical usage::

    class Foo:
        def __init__(self, ...):
            # ...

        @staticmethod
        def from_str(self, s):
            # Parse s...
            return Foo(...)

        def to_str(self):
            # Return in string format.
            return ...

    class MyClass(deb822._RestrictedWrapper):
        def __init__(self):
            data = Deb822ParagraphElement.new_empty_paragraph()
            data['Bar'] = 'baz'
            super(MyClass, self).__init__(data)

        foo = deb822.RestrictedField(
                'Foo', from_str=Foo.from_str, to_str=Foo.to_str)

        bar = deb822.RestrictedField('Bar', allow_none=False)

    d = MyClass()
    d['Bar'] # returns 'baz'
    d['Bar'] = 'quux' # raises RestrictedFieldError
    d.bar = 'quux'
    d.bar # returns 'quux'
    d['Bar'] # returns 'quux'

    d.foo = Foo(...)
    d['Foo'] # returns string representation of foo
c                     / nUR                  5        HV  u  p4[        U[        5      (       d  M  UR                  UR                  R                  5       5        U R                  X45        MX     [        U5      U l        g r1   )	itemsrS   r   rC   r   lower)_RestrictedWrapper__init_restricted_field	frozenset%_RestrictedWrapper__restricted_fields)r   	new_attrsrestricted_fields	attr_namevals        r&   r   _RestrictedWrapper._class_initI  s_    'oo/NI#//!(()9:++I; 0 #,,=">r%   c           
      `   ^ U4S jnU4S jn[        X[        X4S TR                  5      5        g )Nc                    > U R                   R                  TR                  5      nTR                  b  TR                  U5      $ U$ r1   )_RestrictedWrapper__datagetr   r   rG   r   fields     r&   getter:_RestrictedWrapper.__init_restricted_field.<locals>.getterT  s7    ++//%**-C~~)~~c**Jr%   c                   > Ub  TR                   b  TR                  U5      nUcO  TR                  (       a3  TR                  U R                  ;   a  U R                  TR                  	 g g [	        S5      eXR                  TR                  '   g )Nzvalue must not be None)r   
allow_noner   r   rT   r  s     r&   r   :_RestrictedWrapper.__init_restricted_field.<locals>.setter[  sp    5<<#;ll3'{##zzT[[0 KK

3 1 $$<==*-EJJ'r%   )setattrr   r   )r   r   r  r  r   s     `  r&   __init_restricted_field*_RestrictedWrapper.__init_restricted_fieldR  s&    		. 	uzz JKr%   c                    > [         [        U ]  5         U(       a@  [        U[        5      (       d+  [        S[        UR                  R                  5      -   5      eXl	        g)zEInitializes the wrapper over 'data', a Deb822ParagraphElement object.z!Paragraph has duplicated fields: N)
r>   r   r?   rS   r   
ValueErrorrB   rM   r!   r   rG   data_internal_validaterM   s      r&   r?   _RestrictedWrapper.__init__j  sH     	 $02j7^&_&_@3t~~GbGbCccddr%   c                     U R                   $ r1   r   rP   s    r&   rF   (_RestrictedWrapper._underlying_paragraphr  s     {{r%   c                      U R                   U   $ r1   r  rG   keys     r&   __getitem___RestrictedWrapper.__getitem__w  s    {{3r%   c                 x    UR                  5       U R                  ;   a  [        SU-  5      eX R                  U'   g Nz<%s may not be modified directly; use the associated propertyr   r   r   r   )rG   r  values      r&   __setitem___RestrictedWrapper.__setitem__{  s>    99;$222&!"# # !Cr%   c                 v    UR                  5       U R                  ;   a  [        SU-  5      eU R                  U	 g r  r  r  s     r&   __delitem___RestrictedWrapper.__delitem__  s>    99;$222&!"# # KKr%   c                 (    S U R                    5       $ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr1   )rB   )rY   ks     r&   rZ   ._RestrictedWrapper.__iter__.<locals>.<genexpr>  s     ,1As   r  rP   s    r&   ra   _RestrictedWrapper.__iter__  s    ,,,r%   r/   c                 ,    [        U R                  5      $ r1   )r   r   rP   s    r&   __len___RestrictedWrapper.__len__  s    4;;r%   c                 r   Ub  Uc-  U(       d&  U R                   R                  [        SU5      5        gU R                   R                  5       nUb+  [        SU5      R                  UR	                  U5      5        gU(       a  [        SU5      R                  U5        gU R                   R                  5       $ )zSCalls dump() on the underlying data object.

See Deb822.dump for more information.
Nz	IO[bytes]zIO[str])r   r   r   r   encode)rG   fdr:   	text_modeas_strs        r&   r   _RestrictedWrapper.dump  s     >	  k2!67[[%%'F#["%++FMM(,CD  Y#))&1{{!!r%   )__dataT)NNF)r   r    r!   r"   r#   r   r   r   r   r   r?   r   rF   r  r  r!  ra   intr)  r   r$   r   r   s   @r&   r   r     s    *X $+? ? L L.   !-    " "r%   r   )	metaclassc                     ^  \ rS rSrSr\R                  " S5      rSU 4S jjr\	S 5       r
S rS r\" S\R                  \R                   S	S
9r\" SS	S9r\" S\R                  \R                   S	S
9r\" S5      rSrU =r$ )r   i  zRepresents a Files paragraph of a debian/copyright file.

This kind of paragraph is used to specify the copyright and license for a
particular set of files in the package.
r   c                   > [         [        U ]  X5        U(       aR  SU;  a  [        S5      eSU;  a  [	        SU5        SU;  a  [	        SU5        U R
                  (       d  [	        SU5        SU R                  4U l        g )	Nr<   z"Files" field requiredr6   z'Files paragraph missing Copyright fieldr=   z%Files paragraph missing License fieldz%Files paragraph has empty Files fieldr   )r>   r   r?   r+   r4   files_default_re!_FilesParagraph__cached_files_pat)rG   r  r  r.   rM   s       r&   r?   FilesParagraph.__init__  st    nd,TFd"01IJJ$&CVL$A6J::A6J#%t'7'7"8r%   c                 ^    U " [         R                  " 5       SS9nXl        X$l        X4l        U$ )zCreate a new FilesParagraph from its required parts.

:param files: The list of file globs.
:param copyright: The copyright for the files (free-form text).
:param license: The Licence for the files.
Fr  )r   new_empty_paragraphr7  	copyrightlicense)r   r7  r>  r?  rJ   s        r&   createFilesParagraph.create  s/     &::<QVW	r%   c                     U S   nU R                   S   U:w  a  U[        U R                  5      4U l         U R                   S   $ )zReturns a regular expression equivalent to the Files globs.

Caches the result until files is set to a different value.

Raises ValueError if any of the globs are invalid.
r7  r   rr   )r9  r   r7  )rG   	files_strs     r&   files_patternFilesParagraph.files_pattern  sG     M	""1%2'0+djj2I&JD#&&q))r%   c                 P    U R                  5       nUc  gUR                  U5      SL$ )z8Returns True iff filename is matched by a glob in Files.NF)rD  	fullmatch)rG   rl   pats      r&   rk   FilesParagraph.matches  s.       ";}}X&d22r%   r<   Fr   r   r  r6   )r  r=   Comment)__cached_files_pat)TT)r   r    r!   r"   r#   r   r   r8  r?   r   r@  rD  rk   r   r   r   r   r7  r>  r=   r?  commentr$   r   r   s   @r&   r   r     s     **R.K9"  (*3 /22%%%9E  >IG,,W^^G i(Gr%   r   c                      ^  \ rS rSrSrSU 4S jjr\S 5       r\" S\	R                  \	R                  SS9r\" S5      r\" S	5      rS
rU =r$ )r   i  a  Represents a standalone license paragraph of a debian/copyright file.

Minimally, this kind of paragraph requires a 'License' field and has no
'Files' field.  It is used to give a short name to a license text, which
can be referred to from the header or files paragraphs.
c                    > [         [        U ]  X5        U(       a#  SU;  a  [        S5      eSU;   a  [        S5      eg g )Nr=   z"License" field requiredr<   z%input appears to be a Files paragraph)r>   r   r?   r+   r  s      r&   r?   LicenseParagraph.__init__  sK    .tH$01KLL$0;= =  r%   c                     [        U[        5      (       d  [        S5      eU " [        R                  " 5       SS9nXl        U$ )z2Returns a LicenseParagraph with the given license.z"license must be a License instanceFr<  )rS   r=   rT   r   r=  r?  )r   r?  rv   s      r&   r@  LicenseParagraph.create  s@    
 '7++@AA.BBDY^_	#r%   r=   FrJ  rK  r<   r   r2  )r   r    r!   r"   r#   r?   r   r@  r   r=   r   r   r?  rM  _LicenseParagraph__filesr$   r   r   s   @r&   r   r     sY    =   G,,W^^G i(G g&Gr%   r   c                     ^  \ rS rSrSrSU 4S jjrS\4S jrS\4S jr\	" S\
SS	9r\	" S
\
S9r\	" S\R                  \R                  S9r\	" S5      r\	" S5      r\	" S5      r\	" S\R                  \R                  S9r\	" S5      r\	" S\R                  \R                  S9r\	" S\R                  \R                  S9rSrU =r$ )r   i%  zRepresents the header paragraph of a debian/copyright file.

Property values are all immutable, such that in order to modify them you
must explicitly set them (rather than modifying a returned reference).
c                   > Uc  [         R                  " 5       n[        US'   SU;   a   [        R	                  S5        US   US'   US	 [
        [        U ]  U5        [        5       nU R                  nU[        :w  aa  Ub^  UR                  S5      (       d  US-  nUR                  S5      (       a  SUSS -  nU[        ;   a  [        R	                  S	5        X l	        Uc  [        S
5      eU[        ;  a  [        R	                  SU5        gg)zyInitializer.

:param data: A Deb822ParagraphElement object for underlying data.  If None, a
    new one will be created.
NFormatzFormat-SpecificationzEuse of deprecated "Format-Specification" field; rewriting as "Format"/zhttp:zhttps:%s   zFixing Format URLz0input is not a machine-readable debian/copyrightzformat not known: %r)r   r=  _CURRENT_FORMATr2   r3   r>   r   r?   rB   formatendswithr   _KNOWN_FORMATSr(   )rG   r  fmtrM   s      r&   r?   Header.__init__,  s    <)==?D,DN!T)NN 4 5!"89DN+,fd$T*ekk/!co<<$$s
 ~~g&& 3qr7*n$23!;)BD Dn$NN137 %r%   r/   c                 (    U R                   [        ;   $ )z%Returns True iff the format is known.)rZ  r\  rP   s    r&   known_formatHeader.known_formatT  s    {{n,,r%   c                 (    U R                   [        :H  $ )z2Returns True iff the format is the current format.)rZ  rY  rP   s    r&   current_formatHeader.current_formatX  s    {{o--r%   rV  F)r   r  zUpstream-Name)r   zUpstream-Contact)r   r   Source
DisclaimerrK  r=   r6   zFiles-ExcludedzFiles-Included)rZ  r1   )r   r    r!   r"   r#   r?   boolr`  rc  r   r   rZ  upstream_namer   r   r   upstream_contactsource
disclaimerrM  r=   r?  r>  files_excludedfiles_includedr$   r   r   s   @r&   r   r   %  s    &8P-d -. .
 %9F $.M 'Z%8%8  " X&F .Ji(GG,,W^^EG  ,I$:#6#6  "N %:#6#6  "Nr%   r   )?r#   collectionsr\   loggingr   r   typingr   r   r   r   r   r   r	   r
   r   r   r   r   debian._deb822_repror   r   r   r   r   debian.deb822r   r   r   ImportErrorParagraphTypesAllParagraphTypesrY  r   r\  	getLoggerr   r2   	Exceptionr   r(   r  r+   rB   rg  r4   r6   r   r   r   r   r   r   r   
namedtupler=   r   typer   r   r   r   r   r   r%   r&   <module>rz     s  	8    	 	     @	-
 ;<HI  I   
 
		8	$4I 4Qe Q
 3   z zzC C ( (V B2 2(3- 2
 2  S	 (Pk$$Y@ PD+@\T 0M"> M"`N)' N)b'') ''TS" S"Q  		s   
E E
	E
