o
    ½¼7eB  ã                	   @   s  d dl Z d dlZd dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ i dd“d	d“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“ddddddddœ¥ZdZd Zd!Zd"d#gZd$d%gZed  Zd&ZG d'd(„ d(eƒZdS ))é    N)Úgettext)ÚShortcutHandlerÚShortcutExceptionÚInvalidShortcutException)ÚSourcesListShortcutHandler)ÚURIShortcutHandler)ÚurlparseÚfolsomÚpreciseÚgrizzlyÚhavanaÚicehouseÚjunoÚtrustyÚkiloÚlibertyÚmitakaÚnewtonÚxenialÚocataÚpikeÚqueensÚrockyÚbionicÚsteinÚtrainÚussuriÚvictoriaÚfocalÚjammy)ÚwallabyÚxenaÚyogaÚzedÚantelopeÚbobcatÚcaracalzUbuntu Cloud Archivez.https://wiki.ubuntu.com/OpenStack/CloudArchivez0http://ubuntu-cloud.archive.canonical.com/ubuntuzcloud-archiveÚucaÚupdatesÚproposedzubuntu-cloud-keyringc                       sj   e Zd Z‡ fdd„Zedd„ ƒZedd„ ƒZdd„ Zd‡ fd
d„	Zdd„ Z	dd„ Z
dd„ Zdd„ Z‡  ZS )ÚCloudArchiveShortcutHandlerc           	         sŽ  t t| ƒj|fi |¤Ž d | _t|  |¡|  |¡|  |¡fƒs)tdƒ| }t	|ƒ‚| j 
¡ | _d| j | _| j 
¡ | _| jtvrKtdƒ| j }t|ƒ‚| jtvr[tdƒ| j }t|ƒ‚t| j }t|t d¡ph|fƒ}| j|vr�tdƒ| j ¡ | ¡ f }t|ƒ‚t› d| j ¡ › �| _| jdkr˜|  jd	7  _| jsÅ| j› d
| j› d| j› �}d | j¡p¯d}| j› dt› d|› d|› �}|  |¡ d S d S )Nz&not a valid cloud-archive format: '%s'zcloudarchive-%sz&not a valid cloud-archive pocket: '%s'znot a valid cloud-archive: '%s'ÚCA_ALLOW_CODENAMEz)cloud-archive for %s only supported on %sz for OpenStack r)   z [proposed]ú-ú/ú Úmain)Úsuperr*   Ú__init__ÚcanameÚanyÚ
_match_ucaÚ
_match_uriÚ_match_sourceslistÚ_r   ÚlowerÚ	_filebaseÚpocketÚUCA_VALID_POCKETSr   ÚRELEASE_MAPÚsetÚosÚgetenvÚcodenameÚ
capitalizeÚUCAÚ_descriptionÚ_source_entryÚjoinÚ
componentsÚbinary_typeÚUCA_ARCHIVEÚ_set_source_entry)	ÚselfÚshortcutÚkwargsÚmsgr@   Ú
validnamesÚdistÚcompsÚline©Ú	__class__© úA/usr/lib/python3/dist-packages/softwareproperties/cloudarchive.pyr1   I   sB   
þ



ÿ
üz$CloudArchiveShortcutHandler.__init__c                 C   s   | j S ©N)rC   ©rJ   rT   rT   rU   Údescriptionr   s   z'CloudArchiveShortcutHandler.descriptionc                 C   s   t S rV   )ÚWEB_LINKrW   rT   rT   rU   Úweb_linkv   s   z$CloudArchiveShortcutHandler.web_linkc                 C   s   t jdt› � ¡ dd� d S )Nzapt-get install -y T)Úcheck)Ú
subprocessÚrunÚUCA_KEYRING_PACKAGEÚsplitrW   rT   rT   rU   Úadd_keyz   s   z#CloudArchiveShortcutHandler.add_keyNc                    s   t t| ƒ ¡ S rV   )r0   r*   Ú_encode_filebase)rJ   ÚsuffixrR   rT   rU   ra   ~   s   z,CloudArchiveShortcutHandler._encode_filebasec                 C   sR   |  d¡\}}}| ¡ tvrdS | d¡\}}}|sdS || _|p%| jp%t| _dS )Nú:Fr,   T)Ú
rpartitionr8   ÚUCA_PREFIXESÚ	partitionr2   r:   ÚUCA_DEFAULT_POCKET)rJ   rK   Úprefixr7   r'   r2   r:   rT   rT   rU   r4   ‚   s   z&CloudArchiveShortcutHandler._match_ucac                 C   ó&   z|   t|ƒ¡W S  ty   Y dS w ©NF)Ú_match_handlerr   r   ©rJ   rK   rT   rT   rU   r5   �   ó
   ÿz&CloudArchiveShortcutHandler._match_uric                 C   ri   rj   )rk   r   r   rl   rT   rT   rU   r6   •   rm   z.CloudArchiveShortcutHandler._match_sourceslistc                 C   s‚   t | ¡ jƒ}|jt tƒjkrdS | ¡ j d¡\}}}| d¡\}}}t||fƒs,dS || _|p5| j	p5t
| _	|  | ¡ j¡ dS )NFr-   r,   T)r   ÚSourceEntryÚuriÚhostnamerH   rO   rf   Úallr2   r:   rg   rI   rQ   )rJ   ÚhandlerÚparsedr@   r7   r2   r:   rT   rT   rU   rk   ›   s   z*CloudArchiveShortcutHandler._match_handlerrV   )Ú__name__Ú
__module__Ú__qualname__r1   ÚpropertyrX   rZ   r`   ra   r4   r5   r6   rk   Ú__classcell__rT   rT   rR   rU   r*   H   s    )

r*   )r>   r\   r   r7   Ú"softwareproperties.shortcuthandlerr   r   r   Úsoftwareproperties.sourceslistr   Úsoftwareproperties.urir   Úurllib.parser   r<   rB   rY   rH   re   r;   rg   r^   r*   rT   rT   rT   rU   Ú<module>   st   ÿþýüûúùø	÷
öõôóòñðïè