Ë
    eûeUj  ã                   óÌ   — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ej                  j                  Z G d	„ d
ej                  «      Z G d„ dej"                  «      Zy)aÅ  
Copyright (c) 2022, Ian Santopietro
All rights reserved.

This file is part of RepoLib.

RepoLib is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

RepoLib is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with RepoLib.  If not, see <https://www.gnu.org/licenses/>.
é    N)ÚPath©Údeb822é   )ÚParseDeb)Ú	SourceKey)Úutilc                   ó(   ‡ — e Zd ZdZddœˆ fd„
Zˆ xZS )ÚSourceErrorz  Exception from a source object.r   )Úcodec                ó2   •— t        ‰| �  |i |¤Ž || _        y)z�Exception with a source object

        Arguments:
            code (:obj:`int`, optional, default=1): Exception error code.
    N)ÚsuperÚ__init__r   )Úselfr   ÚargsÚkwargsÚ	__class__s       €ú0/usr/lib/python3/dist-packages/repolib/source.pyr   zSourceError.__init__%   s   ø€ ô 	‰Ñ˜$Ð) &Ò)Øˆ�	ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__©r   s   @r   r   r   "   s   ø„ Ù*à#$÷ ò r   r   c                   óf  ‡ — e Zd ZdZeZededefd„«       Z	ddœdZˆ fd„Z
d„ Zdefd	„Zdefd
„Zd[dedefd„ZdZd„Zdeddfˆ fd„Zedefd„«       Zej*                  dZd„«       Zd\defd„Zdefd„Zd]deddfd„ZdZd„Zdefd„Zdefd„Zdefd„Zdededdfd„ZdZd„Zedefd„«       Zedefd„«       Z e j*                  d eddfd!„«       Z edefd"„«       Z!e!j*                  d#eddfd$„«       Z!ede"jF                  fd%„«       Z$e$j*                  dZd&„«       Z$edefd'„«       Z%e%j*                  d(eddfd)„«       Z%edefd*„«       Z&e&j*                  d+eddfd,„«       Z&edefd-„«       Z'e'j*                  d.eddfd/„«       Z'edefd0„«       Z(e(j*                  d1eddfd2„«       Z(edefd3„«       Z)e)j*                  d4eddfd5„«       Z)ed6„ «       Z*e*j*                  d7„ «       Z*edefd8„«       Z+e+j*                  dZd9„«       Z+edefd:„«       Z,e,j*                  dZd;„«       Z,edefd<„«       Z-e-j*                  dZd=„«       Z-edefd>„«       Z.e.j*                  dZd?„«       Z.edefd@„«       Z/e/j*                  dZdA„«       Z/edefdB„«       Z0e0j*                  dZdC„«       Z0edefdD„«       Z1e1j*                  dZdE„«       Z1edefdF„«       Z2e2j*                  dZdG„«       Z2edefdH„«       Z3e3j*                  dZdI„«       Z3edefdJ„«       Z4e4j*                  dZdK„«       Z4edefdL„«       Z5e5j*                  dZdM„«       Z5edefdN„«       Z6e6j*                  dZdO„«       Z6edefdP„«       Z7e7j*                  dZdQ„«       Z7edefdR„«       Z8e8j*                  dZdS„«       Z8edefdT„«       Z9edefdU„«       Z:edefdV„«       Z;d^defdW„Z<defdX„Z=dZdY„Z>ˆ xZ?S )_ÚSourceaä  A DEB822 object representing a single software source.
    
    Attributes:
        ident(str): The unique id for this source
        name(str): The user-readable name for this source
        enabled(bool): Whether or not the source is enabled
        types([SourceType]): A list of repository types for this source
        uris([str]): A list of possible URIs for this source
        suites([str]): A list of enabled suites for this source
        components([str]): A list of enabled components for this source
        comments(str): Comments for this source 
        signed_by(Path): The path to this source's key file
        file(SourceFile): The file this source belongs to
        key(SourceKey): The key which signs this source
    ÚshortcutÚreturnc                 ó´   — | j                  «       }| j                  d«      syt        |«      dkD  syt        j                  syt        |«      dk(  rd|d   vryy)zÖDetermine whether a deb line is valid.
        
        Arguments:
            shortcut(str): The shortcut to validate
        
        Returns: bool
            `True` if the PPA is valid, otherwise False
        ÚdebFé   ú/éÿÿÿÿT)ÚsplitÚ
startswithÚlenr	   Úvalidate_debline)r   Úshortcut_lists     r   Ú	validatorzSource.validatorA   s\   € ð &Ÿ^™^Ó-ˆà×"Ñ" 5Ô)Øä�=Ó! AÒ%Øä×$Ò$Øäˆ}Ó Ò" s°-ÀÑ2CÑ'CØàr   N)Úfilec                óª   •— t        j                  t        «      | _        t	        ‰| �  |i |¤Ž | j                  «        || _        d| _        d| _	        y)zInitialize this source objectFN)
ÚloggingÚ	getLoggerr   Úlogr   r   Úreset_valuesr+   Útwin_sourceÚtwin_enabled)r   r+   r   r   r   s       €r   r   zSource.__init__[   sJ   ø€ ä×$Ñ$¤XÓ.ˆŒÜ‰Ñ˜$Ð) &Ò)Ø×ÑÔØˆŒ	Ø ˆÔØ!ˆÕr   c           
      óÚ  — | j                   r+d| d<   | dxx   dj                  | j                   «      z  cc<   ddj                  | j                  «       D ��cg c]  \  }}|›d|›�‘Œ c}}«      z  }d}| D ]!  }|t        j                  › d|› d	| |   › d
�z  }Œ# |dd }|t        j                  j                  dd«      › z  }|dz  }| j                   r| j                  d«       |S c c}}w )ztype: () -> strú# ÚCommentsú # z{%s}z, z: ú{ú'z': 'z', Néþÿÿÿú Ú ú})ÚcommentsÚjoinÚitemsr	   ÚPRETTY_PRINTÚreplaceÚpop)r   ÚkÚvÚrepÚkeys        r   Ú__repr__zSource.__repr__d   sñ   € ð
 �=Š=Ø#ˆD�ÑØ�Ó §
¡
¨4¯=©=Ó 9Ñ9Óà˜4Ÿ9™9ÀDÇJÁJÃL×%Q¹D¸A¸q²!±QÒ&7Ó%QÓRÑRˆàˆØò 	BˆCØ”d×'Ñ'Ð(¨¨#¨¨d°4¸±9°+¸SÐAÑA‰Cð	Bð �#�2ˆhˆØ”$×#Ñ#×+Ñ+¨C°Ó4Ð5Ñ6ˆØˆs‰
ˆà�=Š=Ø�H‰H�ZÔ àˆ
ùó &Rs   ÁC'c                 ó¢   — t        | j                  «      dkD  }t        | j                  «      dkD  }t        | j                  «      dkD  }|r|r|ryy)Nr   TF)r'   ÚurisÚsuitesÚ
components)r   Úhas_uriÚ	has_suiteÚhas_components       r   Ú__bool__zSource.__bool__|   sG   € Ü˜4Ÿ9™9“~¨Ñ)ˆÜ˜TŸ[™[Ó)¨AÑ-ˆ	Ü  §¡Ó1°AÑ5ˆá‘y¡]ØØr   c                 ó   — | j                   S )z~Get a UI-compatible description for a source. 
        
        Returns: (str)
            The formatted description.
        )Úname©r   s    r   Úget_descriptionzSource.get_description†   s   € ð �y‰yÐr   Úhalt_errorsc                 ó  — | j                   r{| j                   j                  j                  «       }t        |«      dkD  rDd| j                  › dt        |«      › d�}|rt        |«      ‚| j                  j                  |«       |d   S i S )ae   Get a dictionary containing information for the signing key for
        this source.

        Arguments:
            halt_errors (bool): if there are errors or other unexpected data, 
                raise a SourceError exception. Otherwise, simply log a warning.
        
        Returns: dict
            The dictionary from gnupg with key info.
        r   zThe keyring for z
 contains z; keys. Check the keyring object for details about the keys.r   )rF   ÚgpgÚ	list_keysr'   Úidentr   r/   Úwarning)r   rT   ÚkeysÚ	error_msgs       r   Úget_key_infozSource.get_key_infoŽ   sƒ   € ð �8Š8ØŸ™Ÿ™×.Ñ.Ó0ˆDÜ�4‹y˜1Š}à*¨4¯:©:¨,°jÄÀTÃÀð LQð Qð ñ Ü% iÓ0Ð0Ø—‘× Ñ  Ô+Ø˜‘7ˆNàˆ	r   c                 óê  — | j                   j                  d«       d| _        d| _        d| _        t
        j                  j                  g| _        g | _	        g | _
        g | _        g | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        | j7                  «        d| _        d| _        y)z+Reset the default values for all attributeszResetting source infor;   TN)r/   ÚinforX   rQ   Úenabledr	   Ú
SourceTypeÚBINARYÚtypesrI   rJ   rK   r=   Ú	signed_byÚarchitecturesÚ	languagesÚtargetsÚpdiffsÚby_hashÚallow_insecureÚ
allow_weakÚallow_downgrade_to_insecureÚtrustedÚcheck_valid_untilÚvalid_until_minÚvalid_until_maxÚprefsÚ_update_legacy_optionsr+   rF   rR   s    r   r0   zSource.reset_values§   sá   € à�‰�‰Ð-Ô.ØˆŒ
ØˆŒ	ØˆŒÜ—o‘o×,Ñ,Ð-ˆŒ
ØˆŒ	ØˆŒØˆŒØˆŒØˆŒØˆÔØˆŒØˆŒØˆŒØˆŒØ ˆÔØˆŒØ+-ˆÔ(ØˆŒØˆŒØ!#ˆÔØ!ˆÔØ!ˆÔØˆŒ
Ø×#Ñ#Ô%ØˆŒ	Øˆ�r   Údatac                 ó>  •— | j                   j                  d«       | j                  «        t        j                  |d   «      �r,t        |«      dkD  rt        dt        |«      › d�«      ‚t        «       }|j                  |d   «      }|d   | _	        |d   | _
        |d   | _        |d	   g| _        |d
   g| _        |d   g| _        |d   | _        |d   D ]  }|d   |   | |<   Œ | j!                  «        |d   D ]  }| j"                  j%                  |«       Œ | j"                  dgk(  rg | _        | j                  s| j'                  «       | _
        | j(                  r| j+                  «        yt,        ‰| �]  |¬«       | j(                  r| j+                  «        y)a  Loads source information from the provided data

        Should correctly load either a lecagy Deb line (optionally with 
        preceeding comment) or a DEB822 source.
        
        Arguments:
            data(list): the data to load into the source.
        zLoading source from datar   r   z+The source is a legacy source but contains z( entries. It may only contain one entry.rX   rQ   r_   Ú	repo_typeÚuriÚsuiterK   Úoptionsr=   r;   N)Úsequence)r/   r^   r0   r	   r(   r'   r   r   Ú
parse_linerX   rQ   r_   rb   rI   rJ   rK   rq   r=   ÚappendÚgenerate_default_namerc   Úload_keyr   r   )r   rr   Ú
deb_parserÚparsed_deblinerF   Úcommentr   s         €r   Úload_from_datazSource.load_from_dataÅ   s™  ø€ ð 	�‰�‰Ð0Ô1Ø×ÑÔä× Ñ   a¡Õ)Ü�4‹y˜1Š}Ü!ØAÄ#ÀdÃ)Àð M5ð 5óð ô "›ˆJØ'×2Ñ2°4¸±7Ó;ˆNØ'¨Ñ0ˆDŒJØ& vÑ.ˆDŒIØ)¨)Ñ4ˆDŒLØ(¨Ñ5Ð6ˆDŒJØ'¨Ñ.Ð/ˆDŒIØ)¨'Ñ2Ð3ˆDŒKØ,¨\Ñ:ˆDŒOØ% iÑ0ò ;�Ø*¨9Ñ5°cÑ:��S’	ð;à×'Ñ'Ô)Ø)¨*Ñ5ò .�Ø—‘×$Ñ$ WÕ-ð.à�}‰}  Ò$Ø "�”à—9’9Ø ×6Ñ6Ó8�”	à�~Š~Ø—‘”Øô 	‰Ñ $ÐÔ'Ø�>Š>Ø�M‰MŒOØr   c                 óR   — t         j                  j                  | j                  v ryy)zB`True` if this source also provides source code, otherwise `False`TF)r	   r`   Ú
SOURCECODErb   rR   s    r   Úsourcecode_enabledzSource.sourcecode_enabledõ   s    € ô �?‰?×%Ñ%¨¯©Ñ3ØØr   c                 ó¾   — t         j                  j                  g}|t         j                  v r)|j	                  t         j                  j
                  «       || _        y)z Accept a variety of input valuesN)r	   r`   ra   Útrue_valuesrz   r‚   rb   )r   r_   rb   s      r   rƒ   zSource.sourcecode_enabledü   sA   € ô —‘×'Ñ'Ð(ˆØ”d×&Ñ&Ñ&Ø�L‰LœŸ™×3Ñ3Ô4Øˆ�
r   c                 ó|  — d}t        | j                  «      dkD  r^| j                  d   j                  dd«      }|j                  «       }dj	                  |dd «      }t        j                  |«      }|› |› �}|d| j                  d   j                  «       › �z  }	 | d   s|| d<   |S # t        $ r	 || d<   Y |S w xY w)	zkGenerates a suitable ID for the source
        
        Returns: str
            A sane default-id
        r;   r   r#   r:   ú-r   NúX-Repolib-ID)
r'   rI   rA   r%   r>   r	   Úscrub_filenamerb   rX   ÚKeyError)r   ÚprefixrX   ru   Úuri_listÚuri_strÚbranch_names          r   Úgenerate_default_identzSource.generate_default_ident  sÑ   € ð ˆÜˆt�y‰y‹>˜AÒØ—i‘i ‘l×*Ñ*¨3°Ó4ˆCØŸI™I›KˆHØŸ(™( 8¨A¨B <Ó0ˆGÜ"×1Ñ1°'Ó:ˆKØ�h˜{˜mÐ,ˆEØ�1�T—Z‘Z ‘]×(Ñ(Ó*Ð+Ð,Ñ,ˆð	)Ø˜Ò'Ø',��^Ñ$ð ˆøô ò 	)Ø#(ˆD�Ò Øˆð	)ús   Â
B) Â)B;Â:B;c                 ó˜   — | j                   }	 | d   }|s| j                   | d<   | d   S # t        $ r | j                   | d<   | d   cY S w xY w)zwGenerate a default name based on the ident
        
        Returns: str
            A name based on the ident
        úX-Repolib-Name)rX   rŠ   ©r   rQ   s     r   r{   zSource.generate_default_name  si   € ð —:‘:ˆð	*ØÐ(Ñ)ˆDñ
 Ø%)§Z¡ZˆDÐ!Ñ"àÐ$Ñ%Ð%øô ò 	*Ø%)§Z¡ZˆDÐ!Ñ"ØÐ(Ñ)Ò)ð	*ús   Ž) ©A	ÁA	Úignore_errorsc                 óô  — | j                   j                  d| j                  «       | j                  s4|r'| j                   j	                  d| j                  «       nt        d«      ‚| j                  t        j                  vrTt        «       }|j                  | j                  ¬«       || _
        |t        j                  t        |j                  «      <   yt        j                  | j                     | _
        y)zéFinds and loads the signing key from the system
        
        Arguments:
            ignore_errors(bool): If `False`, throw a SourceError exception if
                the key can't be found/doesn't exist (Default: `True`)
        zFinding key for source %szNo key configured for source %sz)No key configured for source {self.ident})ÚpathN)r/   r^   rX   rc   rY   r   r	   rZ   r   Ú
reset_pathrF   Ústrr•   )r   r“   Únew_keys      r   r|   zSource.load_key,  s¨   € ð 	�‰�‰Ð1°4·:±:Ô>Ø�~Š~ÙØ—‘× Ñ Ð!BÀDÇJÁJÕOä!Ð"MÓNÐNà�>‰>¤§¡Ñ*Ü“kˆGØ×Ñ D§N¡NÐÔ3ØˆDŒHØ+2ŒD�I‰I”c˜'Ÿ,™,Ó'Ò(ä—y‘y §¡Ñ0ˆD�Hr   c                 óX   — | j                   dk(  s| j                   j                  «        yy)zProxy method to save the sourceN)r+   ÚsaverR   s    r   rš   zSource.saveB  s!   € à�y‰y˜DÒ Ø�I‰I�N‰NÕð !r   c                 ó   — | j                   S )a8  Outputs a legacy representation of this source
        
        Note: this is expected to fail if there is more than one type, URI, or
        Suite; the one-line format does not support having multiple of these
        properties.

        Returns: str
            The source output formatted as Legacy
        )ÚlegacyrR   s    r   Úoutput_legacyzSource.output_legacyG  s   € ð �{‰{Ðr   c                 ó   — | j                   S )z‡Outputs a DEB822 representation of this source
        
        Returns: str
            The source output formatted as Deb822
        r   rR   s    r   Ú
output_822zSource.output_822S  s   € ð �{‰{Ðr   c                 ó   — | j                   S )z‰Outputs a string representation of this source for use in UIs
        
        Returns: str
            The source output string
        )ÚuirR   s    r   Ú	output_uizSource.output_ui[  s   € ð �w‰wˆr   ÚpropÚitemc                 ó.   — |}|j                  |«       |}y)a  Appends an item to a list property of this source.
        NOTE: List properties are `types`, `uris`, `suites`, and `components`.

        Arguments:
            prop(list): The property on which to append the item.
            item(str): The item to append to the propery
        N)rz   )r   r£   r¤   Ú_lists       r   Úprop_appendzSource.prop_appendc  s   € ð ˆØ�‰�TÔØ‰r   c                  ó   — y)z+Extra tasks to perform when saving a sourceN© )r   r   r   s      r   Ú
tasks_savezSource.tasks_saveo  s   € àr   c                 óN   — g d¢}|D ]  }t        t        | |«      «      dk  sŒ y y)z>(RO) True if all required attributes are set, otherwise false.)rI   rJ   rX   r   FT)r'   Úgetattr)r   Úrequired_partsÚattrs      r   Úhas_required_partszSource.has_required_partst  s4   € ò 5ˆà"ò 	ˆDÜ”7˜4 Ó&Ó'¨!Ó+Ùð	ð r   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)z)The ident for this source within the filerˆ   r;   ©rŠ   rR   s    r   rX   zSource.ident€  s$   € ð	Ø˜Ñ'Ð'øÜò 	Ùð	úó   ‚ ‡	’rX   c                 ó8   — t        j                  |«      }|| d<   y )Nrˆ   )r	   r‰   )r   rX   s     r   rX   zSource.ident‰  s   € ä×#Ñ# EÓ*ˆØ$ˆˆ^Òr   c                 ó^   — 	 | d   }|s| j                  «        | d   S # t         $ r d}Y Œ$w xY w)z'The human-friendly name for this sourcer‘   r;   )rŠ   r{   )r   Ú_names     r   rQ   zSource.name�  sE   € ð	ØÐ)Ñ*ˆEñ Ø×&Ñ&Ô(ØÐ$Ñ%Ð%øô ò 	ØŠEð	úó   ‚ ž,«,rQ   c                 ó   — || d<   y )Nr‘   r©   r’   s     r   rQ   zSource.name›  s   € à!%ˆÐÒr   c                 ó  — 	 | d   t         j                  v }|r&| j
                  rt         j                  j                  S t         j                  j                  S # t        $ r t         j                  j                  cY S w xY w)z+Whether or not the source is enabled/activeÚEnabled)r	   r…   rŠ   ÚAptSourceEnabledÚFALSEr¯   ÚTRUE©r   r_   s     r   r_   zSource.enabled   so   € ð	/Ø˜9‘o¬×)9Ñ)9Ð9ˆGñ �t×.Ò.Ü×(Ñ(×-Ñ-Ð-Ü×$Ñ$×*Ñ*Ð*øô ò 	/Ü×(Ñ(×.Ñ.Ò.ð	/ús   ‚A Á#A?Á>A?c                 ó>   — d| d<   |t         j                  v rd| d<   yy)z<For convenience, accept a wide varietry of input value typesÚnor¹   ÚyesN)r	   r…   r½   s     r   r_   zSource.enabled¬  s)   € ð ˆˆY‰Ø”d×&Ñ&Ñ&Ø#ˆD�ŠOð 'r   c                 ó¦   — g }	 | d   j                  «       D ]&  }|j                  t        j                  |«      «       Œ( 	 |S # t        $ r Y |S w xY w)z(The list of source types for this sourcerb   )r%   rz   r	   r`   rŠ   )r   Ú_typesÚ
sourcetypes      r   rb   zSource.types´  s_   € ð ˆð	Ø" 7™m×1Ñ1Ó3ò ;�
Ø—‘œdŸo™o¨jÓ9Õ:ñ;ð ˆøô ò 	ØØˆð	ús   „<A Á	AÁArb   c                 óº   — d| d<   g }|D ]  }||vsŒ|j                  |«       Œ |D ]  }| dxx   |j                  › d�z  cc<   Œ | d   j                  «       | d<   y)z2Turn this list into a string of values for storager;   ÚTypesr:   N)rz   ÚvalueÚstrip)r   rb   rÂ   rÃ   s       r   rb   zSource.types¿  sx   € ð ˆˆW‰ØˆØò 	*ˆJØ Ò'Ø—‘˜jÕ)ð	*ð !ò 	4ˆJØ�‹M 
× 0Ñ 0Ð1°Ð3Ñ3ŒMð	4à˜W™×+Ñ+Ó-ˆˆWŠr   c                 óL   — 	 | d   j                  «       S # t        $ r g cY S w xY w)ú The list of URIs for this sourceÚURIs©r%   rŠ   rR   s    r   rI   zSource.urisÌ  s.   € ð	Ø˜‘<×%Ñ%Ó'Ð'øÜò 	ØŠIð	úó   ‚ •#¢#rI   c                 óH   — dj                  |«      j                  «       | d<   y )Nr:   rÊ   ©r>   rÇ   )r   rI   s     r   rI   zSource.urisÔ  s   € à—x‘x “~×+Ñ+Ó-ˆˆVŠr   c                 óL   — 	 | d   j                  «       S # t        $ r g cY S w xY w)rÉ   ÚSuitesrË   rR   s    r   rJ   zSource.suitesÙ  s.   € ð	Ø˜‘>×'Ñ'Ó)Ð)øÜò 	ØŠIð	úrÌ   rJ   c                 óH   — dj                  |«      j                  «       | d<   y )Nr:   rÐ   rÎ   )r   rJ   s     r   rJ   zSource.suitesá  s   € àŸ™ &Ó)×/Ñ/Ó1ˆˆXŠr   c                 óL   — 	 | d   j                  «       S # t        $ r g cY S w xY w)rÉ   Ú
ComponentsrË   rR   s    r   rK   zSource.componentsæ  s/   € ð	Ø˜Ñ%×+Ñ+Ó-Ð-øÜò 	ØŠIð	úrÌ   rK   c                 óH   — dj                  |«      j                  «       | d<   y )Nr:   rÓ   rÎ   )r   rK   s     r   rK   zSource.componentsî  s   € à ŸX™X jÓ1×7Ñ7Ó9ˆˆ\Òr   c                 ó   — | j                   S )zThe options for this source)Ú_optionsrR   s    r   rw   zSource.optionsó  s   € ð �}‰}Ðr   rw   c                 óh   — d|v r'|d   | _         | j                   r|j                  d«       || _        y ©Nú	Signed-By)rc   rB   rÖ   )r   rw   s     r   rw   zSource.optionsø  s0   € à˜'Ñ!Ø$ [Ñ1ˆDŒNØ�~Š~Ø—‘˜KÔ(Øˆ�r   c                 ó^   — 	 | d   }|rt        |«      S t        «       S # t         $ r d}Y Œ$w xY w)z6The path to any apt preferences files for this source.úX-Repolib-Prefsr;   )rŠ   r   )r   rp   s     r   rp   zSource.prefs   s>   € ð	ØÐ*Ñ+ˆEñ Ü˜“;ÐÜ‹vˆøô ò 	ØŠEð	úr¶   c                 óP   — 	 | d= |rt        |«      }|| d<   yy# t         $ r Y Œw xY w)z"Accept a str or a Path-like objectrÛ   N)rŠ   r—   )r   rp   Ú	prefs_strs      r   rp   zSource.prefs  sB   € ð	ØÐ&Ð'ñ Ü˜E›
ˆIØ&/ˆDÐ"Ò#ð øô ò 	Ùð	ús   ‚ ™	%¤%c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zarchitectures optionÚArchitecturesr;   r±   rR   s    r   rd   zSource.architectures  s$   € ð	Ø˜Ñ(Ð(øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrß   ©rB   rŠ   rq   ©r   rr   s     r   rd   zSource.architectures#  sB   € ð	Ø�H‰H�_Ô%ñ Ø$(ˆD�Ñ!Ø×#Ñ#Õ%øô ò 	Ùð	úó   ‚+ «	7¶7c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zlanguages optionÚ	Languagesr;   r±   rR   s    r   re   zSource.languages/  ó$   € ð	Ø˜Ñ$Ð$øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrå   rá   râ   s     r   re   zSource.languages7  óB   € ð	Ø�H‰H�[Ô!ñ Ø $ˆD�ÑØ×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)ztargets optionÚTargetsr;   r±   rR   s    r   rf   zSource.targetsC  ó#   € ð	Ø˜	‘?Ð"øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrê   rá   râ   s     r   rf   zSource.targetsK  óA   € ð	Ø�H‰H�YÔñ Ø"ˆD�‰OØ×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zpdiffs optionÚPdiffsr;   r±   rR   s    r   rg   zSource.pdiffsW  s#   € ð	Ø˜‘>Ð!øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrï   rá   râ   s     r   rg   zSource.pdiffs_  sA   € ð	Ø�H‰H�XÔñ Ø!ˆD�‰NØ×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zby_hash optionúBy-Hashr;   r±   rR   s    r   rh   zSource.by_hashk  rë   r²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrò   rá   râ   s     r   rh   zSource.by_hashs  rí   rã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zallow_insecure optionúAllow-Insecurer;   r±   rR   s    r   ri   zSource.allow_insecure  s%   € ð	ØÐ(Ñ)Ð)øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrõ   rá   râ   s     r   ri   zSource.allow_insecure‡  sD   € ð	Ø�H‰HÐ%Ô&ñ Ø%)ˆDÐ!Ñ"Ø×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zallow_weak optionú
Allow-Weakr;   r±   rR   s    r   rj   zSource.allow_weak“  s$   € ð	Ø˜Ñ%Ð%øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrø   rá   râ   s     r   rj   zSource.allow_weak›  sB   € ð	Ø�H‰H�\Ô"ñ Ø!%ˆD�ÑØ×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)z"allow_downgrade_to_insecure optionúAllow-Downgrade-To-Insecurer;   r±   rR   s    r   rk   z"Source.allow_downgrade_to_insecure§  s%   € ð	ØÐ5Ñ6Ð6øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrû   rá   râ   s     r   rk   z"Source.allow_downgrade_to_insecure¯  sD   € ð	Ø�H‰HÐ2Ô3ñ Ø26ˆDÐ.Ñ/Ø×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)ztrusted optionÚTrustedr;   r±   rR   s    r   rl   zSource.trusted»  rë   r²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nrþ   rá   râ   s     r   rl   zSource.trustedÃ  rí   rã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zsigned_by optionrÙ   r;   r±   rR   s    r   rc   zSource.signed_byÏ  ræ   r²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY wrØ   rá   râ   s     r   rc   zSource.signed_by×  rè   rã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zcheck_valid_until optionúCheck-Valid-Untilr;   r±   rR   s    r   rm   zSource.check_valid_untilã  s%   € ð	ØÐ+Ñ,Ð,øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nr  rá   râ   s     r   rm   zSource.check_valid_untilë  sD   € ð	Ø�H‰HÐ(Ô)ñ Ø(,ˆDÐ$Ñ%Ø×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zvalid_until_min optionúValid-Until-Minr;   r±   rR   s    r   rn   zSource.valid_until_min÷  ó%   € ð	ØÐ)Ñ*Ð*øÜò 	Ùð	úr²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nr  rá   râ   s     r   rn   zSource.valid_until_minÿ  óD   € ð	Ø�H‰HÐ&Ô'ñ Ø&*ˆDÐ"Ñ#Ø×#Ñ#Õ%øô ò 	Ùð	úrã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)zvalid_until_max optionúValid-Until-Maxr;   r±   rR   s    r   ro   zSource.valid_until_max  r  r²   c                 ót   — 	 | j                  d«       |r|| d<   | j                  «        y # t        $ r Y Œ#w xY w)Nr  rá   râ   s     r   ro   zSource.valid_until_max  r	  rã   c                 ó,   — 	 | d   S # t         $ r Y yw xY w)z%The default mirror/URI for the sourceúX-Repolib-Default-Mirrorr;   r±   rR   s    r   Údefault_mirrorzSource.default_mirror  s%   € ð	ØÐ2Ñ3Ð3øÜò 	Ùð	úr²   c                 ó   — |r|| d<   y d| d<   y )Nr  r;   r©   )r   Úmirrors     r   r  zSource.default_mirror&  s   € áØ/5ˆDÐ+Ò,à/1ˆDÐ+Ò,r   c                 óô   — | j                  «        | j                  r+d| d<   | dxx   dj                  | j                  «      z  cc<   | j                  «       }| j                  r| j	                  d«       |r|S y)z(The DEB822 representation of this sourcer4   zX-Repolib-Commentsr6   r;   )rq   r=   r>   ÚdumprB   )r   Ú_deb822s     r   r   zSource.deb822/  sl   € ð 	×#Ñ#Ô%ð �=Š=Ø)-ˆDÐ%Ñ&ØÐ%Ó&¨%¯*©*°T·]±]Ó*CÑCÓ&Ø—)‘)“+ˆØ�=Š=Ø�H‰HÐ)Ô*ÙØˆNØr   c                 ó\  — | j                  «        | j                  j                  d«      }| j                  › d�}|D ]4  }|j                  d«      d   }|t        j
                  vsŒ*|sŒ-||› d�z  }Œ6 t        j                  D ]%  }|j                  |t        j                  |   «      }Œ' |S )z-The UI-friendly representation of this sourceú
z:
ú:r   )rq   r   r%   rX   r	   Úoutput_skip_keysÚkeys_maprA   )r   Ú_ui_listÚ	ui_outputÚlinerF   s        r   r¡   z	Source.ui?  s®   € ð 	×#Ñ#Ô%ØŸ™×)Ñ)¨$Ó/ˆØ ŸJ™J˜< sÐ+ˆ	Øò 	-ˆDØ—*‘*˜S“/ !Ñ$ˆCØœ$×/Ñ/Ò/ÚØ D 6¨ Ñ,‘Ið		-ô
 —=‘=ò 	CˆCØ!×)Ñ)¨#¬t¯}©}¸SÑ/AÓB‰Ið	CàÐr   c                 ó~  — | j                  «        t        | j                  «      dk7  rt        d«      ‚| j                  }t        | j                  «      dkD  r)d| _        t        j                  j                  g| _        d}d}|| j                  «       z  }| j                  r|dz  }|| j                  d|¬«      z  }|S )z8The legacy/one-line format representation of this sourceú.zBApt Preferences files can only be used with DEB822-format sources.r   Tr;   r  )Ú
sourcecoder_   )rq   r—   rp   r   rƒ   r'   rb   r1   r	   r`   ra   Ú_generate_legacy_output)r   r  rœ   s      r   rœ   zSource.legacyN  s·   € ð 	×#Ñ#Ô%äˆt�z‰z‹?˜cÒ!ÜØTóð ð ×,Ñ,ˆ
Üˆt�z‰z‹?˜QÒØ#ˆDÔÜŸ/™/×0Ñ0Ð1ˆDŒJØˆJàˆà�$×.Ñ.Ó0Ñ0ˆØ×ÒØ�d‰NˆFØ�d×2Ñ2¸dÈJÐ2ÓWÑWˆFàˆr   c                 ó˜  — d}t        | j                  «      dkD  r'd| _        t        j                  j
                  g| _        dD ]7  }t        t        | |«      «      dkD  sŒd|› d�}|d|dd	 › d
�z  }t        |«      ‚ | j                  j                  «       s|s|dz  }|r|s|dz  }|r|dz  }n!|| j                  d   j                  z  }|dz  }| j                  «       }|r|dz  }||z  }|j                  «       }|dz  }|| j                  d   › d�z  }|| j                  d   › d�z  }|dj                  | j                   «      z  }|S )z8Generate a string of the current source in legacy formatr;   r   T)rb   rI   rJ   zThe source has too many r  z"Legacy-format sources support one Nr$   z only.r4   zdeb-src r   r:   ú[z] )r'   rb   r1   r	   r`   ra   r¬   r   r_   Úget_boolrÆ   Ú_legacy_optionsrÇ   rI   rJ   r>   rK   )r   r  r_   rœ   r®   ÚmsgÚoptions_strings          r   r   zSource._generate_legacy_outputg  sm  € àˆäˆt�z‰z‹?˜QÒØ#ˆDÔÜŸ/™/×0Ñ0Ð1ˆDŒJØ/ò 	'ˆDÜ”7˜4 Ó&Ó'¨!Ó+Ø0°°°aÐ8�ØÐ;¸DÀÀ"¸I¸;ÀfÐMÑM�Ü! #Ó&Ð&ð		'ð �|‰|×$Ñ$Ô&©zØ�d‰NˆFá™gØ�d‰NˆFáØ�jÑ ‰Fà�d—j‘j ‘m×)Ñ)Ñ)ˆFØ�c‰MˆFà×-Ñ-Ó/ˆÙØ�c‰MˆFØ�nÑ$ˆFØ—\‘\“^ˆFØ�d‰NˆFà�T—Y‘Y˜q‘\�N !Ð$Ñ$ˆØ�T—[‘[ ‘^Ð$ AÐ&Ñ&ˆð 	�#—(‘(˜4Ÿ?™?Ó+Ñ+ˆð ˆr   c                 ó¢   — d}| j                   D ]=  }| j                   |   dk7  sŒ||› d| j                   |   j                  dd«      › d�z  }Œ? |S )zŠTurn the current options into a oneline-style string
        
        Returns: str
            The one-line-format options string
        r;   ú=r:   ú,)rw   rA   )r   Úoptions_strrF   s      r   r$  zSource._legacy_options•  se   € ð ˆØ—<‘<ò 	OˆCØ�|‰|˜CÑ  BÓ&Ø #  a¨¯©°SÑ(9×(AÑ(AÀ#ÀsÓ(KÐ'LÈAÐNÑN‘ð	Oð Ðr   c                 ó2  — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  dœ| _        y)z)Updates the current set of legacy options)ÚarchÚlangÚtargetrg   zby-hashzallow-insecurez
allow-weakzallow-downgrade-to-insecurerl   z	signed-byzcheck-valid-untilzvalid-until-minzvalid-until-maxN)rd   re   rf   rg   rh   ri   rj   rk   rl   rc   rm   rn   ro   rw   rR   s    r   rq   zSource._update_legacy_options¡  st   € ð ×&Ñ&Ø—N‘NØ—l‘lØ—k‘kØ—|‘|Ø"×1Ñ1ØŸ/™/Ø+/×+KÑ+KØ—|‘|ØŸ™Ø!%×!7Ñ!7Ø#×3Ñ3Ø#×3Ñ3ñ
ˆ�r   )r   N)F)r;   )T)FT)@r   r   r   r   ÚDEFAULT_FORMATÚdefault_formatÚstaticmethodr—   Úboolr*   r   rG   rO   rS   Údictr\   r0   Úlistr€   Úpropertyrƒ   Úsetterr�   r{   r|   rš   r�   rŸ   r¢   r§   rª   r¯   rX   rQ   r	   rº   r_   rb   rI   rJ   rK   rw   rp   rd   re   rf   rg   rh   ri   rj   rk   rl   rc   rm   rn   ro   r  r   r¡   rœ   r   r$  rq   r   r   s   @r   r   r   .   sÀ  ø„ ñð  $€Nàð˜3ð  4ò ó ðð2 $(÷ "òð0˜$ó ð ó ñ¨ð ¸ó ó2ð<. $ð .¨4õ .ð` ð Dò ó ðð ×Ñòó ðñ°3ó ð*& só &ñ$1 Tð 1°Tó 1ó,ð

˜só 
ð˜Có ð˜3ó ð
˜tð 
¨#ð 
°$ó 
óð
 ð Dò ó ðð ð�sò ó ðð ‡\�\ð%˜3ð % 4ò %ó ð%ð
 ð	&�cò 	&ó ð	&ð 
‡[�[ð&˜ð & ò &ó ð&ð ð	+˜×.Ñ.ò 	+ó ð	+ð ‡^�^ò$ó ð$ð ð�tò ó ðð ‡\�\ð	.˜4ð 	. Dò 	.ó ð	.ð ð�dò ó ðð 
‡[�[ð.˜ð . $ò .ó ð.ð ð˜ò ó ðð ‡]�]ð2˜Tð 2 dò 2ó ð2ð ð˜Dò ó ðð ×Ñð: Tð :¨dò :ó ð:ð ð˜ò ó ðð ‡^�^ð ˜dð   tò  ó ð ð ñ	ó ð	ð ‡\�\ñ	0ó ð	0ð ð ò ó ðð ×Ñò&ó ð&ð ð˜Cò ó ðð ×Ñò&ó ð&ð ð˜#ò ó ðð ‡^�^ò&ó ð&ð ð˜ò ó ðð ‡]�]ò&ó ð&ð ð˜#ò ó ðð ‡^�^ò&ó ð&ð ð ò ó ðð ×Ñò&ó ð&ð ð˜Sò ó ðð ×Ñò&ó ð&ð ð¨cò ó ðð !×'Ñ'ò&ó (ð&ð ð˜#ò ó ðð ‡^�^ò&ó ð&ð ð˜Cò ó ðð ×Ñò&ó ð&ð ð Cò ó ðð ×Ñò&ó ð&ð ð #ò ó ðð ×Ñò&ó ð&ð ð #ò ó ðð ×Ñò&ó ð&ð ð ò ó ðð ×Ñò2ó ð2ð ð˜ò ó ðð ð�Cò ó ðð ð˜ò ó ðñ0,Èó ,ð\
 ó 
÷
r   r   )r   r-   Úpathlibr   Údebianr   Úparsedebr   rF   r   r;   r	   ÚSourceFormatÚLEGACYr/  Ú	RepoErrorr   ÚDeb822r   r©   r   r   ú<module>r>     sQ   ðñó( Ý å å Ý Ý à×"Ñ"×)Ñ)€ô
�$—.‘.ô 
ôC
ˆV�]‰]õ C
r   