Ë
    ëSûe®  ã                   óÚ   — d Z ddlZddlmZ ddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZ ej                  j                  Zd	Zd
ZdZej                  j                  ZdZdZ G d„ de«      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)Ú	SourceKeyé   )ÚSourceÚSourceError)Ú
SourceFile)Úutilzhttp://apt.pop-os.org/stagingÚmainzDhttps://raw.githubusercontent.com/pop-os/pop/master/scripts/.iso.ascÚpopdevú:c            	       óš   ‡ — e Zd ZdZ ed«      ZeZede	de
fd„«       Zdddœˆ fd	„
Zdˆ fd„Zde	fd„Zdedd
fd„Zdde	de
de
dd
fd„Zˆ xZS )ÚPopdevSourcez˜ PopDev Source shortcut

    These are given in the format popdev:branchname. 

    Arguments:
        shortcut (str): The ppa: shortcut to process
    z/etc/apt/preferences.dÚshortcutÚreturnc                 óÎ   — d| v ry| j                  d«      }	 |d   sy	 | j                  t        › d�«      r | j                  d«      }t	        |«      dkD  ryy# t        $ r Y yw xY w)zÚDetermine whether a PPA shortcut is valid.
        
        Arguments:
            shortcut(str): The shortcut to validate
        
        Returns: bool
            `True` if the PPA is valid, otherwise False
        ú/Fr   é   r   T)ÚsplitÚ
IndexErrorÚ
startswithÚprefixÚlen)r   Úshortcut_splitÚ	shortlists      ú:/usr/lib/python3/dist-packages/repolib/shortcuts/popdev.pyÚ	validatorzPopdevSource.validator7   s{   € ð �(‰?Øà!Ÿ™¨Ó,ˆð	Ø! !Ò$Øð %ð
 ×Ñ¤& ¨˜|Ô,Ø Ÿ™ sÓ+ˆIÜ�9‹~ Ò!Øàøô ò 	Ùð	ús   ˜A Á	A$Á#A$Ú T)ÚlineÚ
fetch_datac                ó  •— |r |j                  d«      st        d|› d�«      ‚t        ‰| �  ||«       t	        j
                  t        «      | _        || _        d| _	        d | _
        d| _        d| _        |r| j                  |«       y y )Nzppa:zThe PPA shortcut ú is malformedTr   )r   r   ÚsuperÚ__init__ÚloggingÚ	getLoggerÚ__name__Úlogr   Útwin_sourceÚ
prefs_pathÚbranch_nameÚ
branch_urlÚload_from_shortcut)Úselfr   r   ÚargsÚkwargsÚ	__class__s        €r   r#   zPopdevSource.__init__R   sƒ   ø€ ÙØ—?‘? 6Ô*Ü!Ð$5°d°V¸=Ð"IÓJÐJÜ‰Ñ˜˜vÔ&Ü×$Ñ$¤XÓ.ˆŒØˆŒ	Ø $ˆÔØˆŒØ!ˆÔØ ˆŒÙØ×#Ñ# DÕ)ð ó    Nc                 ó  •— t        ‰| �  |i |¤Ž | j                  j                  d| j                  «       d}|d| j
                  › d�z  }|dz  }| j                  j                  d| j                  |«       	 t        | j                  d¬«      5 }|j                  |«       d d d «       | j                  j                  d| j                  «       y # 1 sw Y   Œ0xY w# t        $ rš t        j                  «       }	 |j                  d	d
«      }|j                  t        | j                  «      |«       nJ# t        j                   j"                  $ r* | j                  j%                  d«       t'        d«       Y Y y w xY wY ŒÕw xY w)NzSaving prefs file for %szPackage: *
zPin: release o=pop-os-staging-ú
zPin-Priority: 1002
z%s prefs for pin priority:
%sÚw)Úmodezorg.pop_os.repolibz/RepozDBus service not found!z%Permission denied. Please use `sudo`.zPin priority saved for %s)r"   Ú
tasks_saver'   ÚinfoÚidentr+   ÚdebugÚopenÚprefsÚwriteÚPermissionErrorÚdbusÚ	SystemBusÚ
get_objectÚoutput_prefs_to_diskÚstrÚ
exceptionsÚDBusExceptionÚcriticalÚprint)r-   r.   r/   Úprefs_contentsÚ
prefs_fileÚbusÚprivileged_objectr0   s          €r   r6   zPopdevSource.tasks_save`   sF  ø€ Ü‰Ñ˜DÐ+ FÒ+Ø�‰�‰Ð0°$·*±*Ô=Ø'ˆØÐ:¸4¿?¹?Ð:KÈ2ÐNÑNˆØÐ0Ñ0ˆà�‰�‰Ð7¸¿¹À^ÔTð	Ü�d—j‘j sÔ+ð 1¨zØ× Ñ  Ô0÷1ð 	�‰�‰Ð2°D·J±JÕ?÷1ð 1ûäò 	Ü—.‘.Ó"ˆCðØ$'§N¡NÐ3GÈÓ$QÐ!Ø!×6Ñ6´s¸4¿:¹:³ÈÕWøÜ—?‘?×0Ñ0ò Ø—‘×!Ñ!Ð";Ô<ÜÐ=Ô>Úðúñ Xð		úsO   Á9C ÂCÂ"C ÃCÃC ÃF Ã;7D3Ä2F Ä3AE:Å6F Å9E:Å:F Å?F c                  ó   — y)NzPop Development Staging branch© )r-   s    r   Úget_descriptionzPopdevSource.get_descriptiony   s   € Ø0r1   Údatac                 ól   — | j                   j                  d|d   «       | j                  |d   ¬«       y )NzLoading line %sr   )r   )r'   r9   r,   )r-   rN   s     r   Úload_from_datazPopdevSource.load_from_data}   s.   € Ø�‰�‰Ð(¨$¨q©'Ô2Ø×Ñ¨¨a©ÐÕ1r1   ÚmetaÚget_keyc                 óÎ  — | j                  «        |r|| _        | j                  st        d«      ‚| j                  | j                  «      st        d| j                  › d�«      ‚| j                  j                  d| j                  «       |j                  t        «      | _        dj                  | j                  dd «      | _
        t        j                  | j                  ¬«      | _        | j                  j                  d	| j                  «       t        › d
| j                  › �| _        | j                  › dt         j"                  › �t        j$                  vrct'        | j                  ¬«      }t         |_        || _        | j*                  t        j$                  t-        | j*                  j.                  «      <   n5t        j$                  t-        | j*                  j.                  «         | _        | j*                  j1                  | «       d| j                  › �| _        t4        › d| j                  › �g| _        t        j8                  g| _        t<        g| _        tA        d¬«      }|jC                  tD        ¬«       || _#        t-        | jF                  j.                  «      | _$        | jJ                  d| j                  › �z  | _&        | jL                  | _'        d| _(        y)z£Translates the shortcut line into a full repo.
        
        Arguments:
            shortcut(str): The shortcut to load, if one hasn't been loaded yet.
        zNo PPA shortcut providedz	The line r!   zLoading shortcut %sr   r   N)ÚnamezPopdev branch name: %sú-ú.zPop Development Branch r   r   )Úurlzpop-os-staging-T))Úreset_valuesr   r   r   r'   r9   r   Ú
delineatorÚ
info_partsÚjoinr+   r	   Úscrub_filenamer*   r   r8   ÚBASE_FORMATÚvalueÚfilesr   ÚformatÚfilerB   ÚpathÚ
add_sourcerT   ÚBASE_URLÚurisÚDISTRO_CODENAMEÚsuitesÚ
BASE_COMPSÚ
componentsr   Úload_key_dataÚBASE_KEYURLÚkeyÚ	signed_byÚ	prefs_dirr)   r;   Úenabled)r-   r   rQ   rR   Únew_filerl   s         r   r,   zPopdevSource.load_from_shortcut�   s  € ð 	×ÑÔÙØ ˆDŒIà�yŠyÜÐ8Ó9Ð9à�~‰~˜dŸi™iÔ(Ü 	¨$¯)©)¨°MÐBÓCÐCà�‰�‰Ð,¨d¯i©iÔ8à"Ÿ.™.¬Ó4ˆŒØŸ(™( 4§?¡?°1°2Ð#6Ó7ˆŒÜ×.Ñ.°D·O±OÔDˆÔØ�‰�‰Ð/°×1AÑ1AÔBä�x˜q ×!1Ñ!1Ð 2Ð3ˆŒ
Ø�j‰jˆ\˜œ;×,Ñ,Ð-Ð.´d·j±jÑ@Ü! t§z¡zÔ2ˆHÜ)ˆHŒOØ ˆDŒIØ.2¯i©iŒD�J‰J”s˜4Ÿ9™9Ÿ>™>Ó*Ò+äŸ
™
¤3 t§y¡y§~¡~Ó#6Ñ7ˆDŒIà�	‰	×Ñ˜TÔ"à-¨d×.>Ñ.>Ð-?Ð@ˆŒ	Ü �z  4§?¡?Ð"3Ð4Ð5ˆŒ	Ü×+Ñ+Ð,ˆŒÜ%˜,ˆŒä˜XÔ&ˆØ×ÑœkÐÔ*ØˆŒÜ˜TŸX™XŸ]™]Ó+ˆŒàŸ.™.¨_¸T×=MÑ=MÐ<NÐ+OÑOˆŒØ—_‘_ˆŒ
àˆ�r1   )r   N)r   TT)r&   Ú
__module__Ú__qualname__Ú__doc__r   rn   r]   Údefault_formatÚstaticmethodrB   Úboolr   r#   r6   rM   ÚlistrP   r,   Ú__classcell__)r0   s   @r   r   r   ,   s�   ø„ ññ Ð-Ó.€IØ €Nàð˜3ð  4ò ó ðð4 $&°$ö *õ@ð21 ó 1ð2 4ð 2¨Dó 2ñ/¨#ð /°tð /È$ð /ÐX\÷ /r1   r   )rs   r$   Úpathlibr   r>   Úrepolib.keyr   Úsourcer   r   ra   r   r   r	   ÚSourceFormatÚDEFAULTr]   rd   rh   rk   ÚDEFAULT_FORMATr   rY   r   rL   r1   r   ú<module>r      sj   ðñó( Ý ã å !ç (Ý Ý à×Ñ×'Ñ'€Ø*€Ø€
ØT€à×"Ñ"×*Ñ*€à	€Ø€
ôD�6õ Dr1   