%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/softwareproperties/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/softwareproperties/__pycache__/SoftwareProperties.cpython-312.pyc

�

� f�����ddlZddlZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZ	ddlm
Z
ddlZ	ddlZddl
mZddlmZ	ddlmZddlmZddlZddlZddlZdd	lmZdd
lmZm Z m!Z!ddl"m#Z#ddl$m%Z%dd
l&m'Z'Gd�de(�Z)e*dk(r/e)�Z+e,e+j[��e+j]d�yy#e$rejZ
Y��wxYw#e$rddlZY��wxYw#e$r	ddlmZY��wxYw)�N)�md5)�	maketrans)�NamedTemporaryFile)�escape)�ConfigParser)�gettext�)�AptAuth)�SourcesList�SourceEntry�Deb822SourceEntry)�InvalidShortcutException)�shortcut_handler)�Gioc��eZdZdZdZeed��\ZZZ	edede	diZ
d=d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d*�Z-d+�Z.d,�Z/d-�Z0d.�Z1d/�Z2d0�Z3d1�Z4d2�Z5d3�Z6d>d4�Z7d>d5�Z8d?d6�Z9d7�Z:d8�Z;d9�Z<d:�Z=d;�Z>e?d@d<��Z@y)A�SoftwarePropertiesz /usr/share/app-install/channels/z$/etc/update-manager/release-upgrades��normal�lts�neverNc�P�|dz|_||_|dk7r tjj	d|�|dk(rd}||_||_t|��|_tjj�|_
g|_d|_
|j�|j�|j!�g|_t%j&�|_t+|��|_t/j0�|_t5j6|j8�y)	z� Provides the core functionality to configure the used software
        repositories, the corresponding authentication keys and
        update automation z/etc/popularity-contest.conf�/�DirNz/usr/share/software-properties/)�deb822F)�rootdir)�
popconfiler�apt_pkg�config�set�options�datadirr�sourceslist�
aptsources�distro�
get_distro�seen_server�modified_sourceslist�reload_sourceslist�backup_sourceslist�backup_apt_conf�custom_mirrors�queue�Queue�myqueuer
�apt_keyr�Cancellable�cancellable�atexit�register�wait_for_threads)�selfr!r rrs     �G/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py�__init__zSoftwareProperties.__init__Ws����<�<�D�O��D�L��#�~�
�n�n�����(��$��1�g��D�L��D�L�"�&�1�D���#�#�.�.�0�D�K��D�� %�D���������������D���;�;�=�D�L��7�+�D�L����(�D��
�O�O�D�)�)�*�c��tj�D]>}|jtj�jk7s�/|j	��@y)z9 wait for all running threads (PPA key fetchers) to exit N)�	threading�	enumerate�ident�current_thread�join)r5�ts  r6r4z#SoftwareProperties.wait_for_threads�s>��
�
 �
 �
"���	
���I�,�,�.�4�4�	4�	����r8c���i|_tjj�D]A}tj
j
tj|�}||j|<�Cy)z$Backup all apt configuration optionsN)�apt_conf_backup�softwareproperties�CONF_MAP�keysrr�find_i)r5�option�values   r6r*z"SoftwareProperties.backup_apt_conf�sX���D��$�-�-�2�2�4�-�����%�%�&8�&A�&A�&�&I�J��',����V�$�-r8c���|jj�D]I}tjj	t
j|t|j|���K|j�y)z$Restore the stored apt configurationN)	rArDrrrrBrC�str�write_config)r5rFs  r6�restore_apt_confz#SoftwareProperties.restore_apt_conf�sa���&�&�+�+�-�>�������-�6�6�v�>��t�3�3�F�;�<�	>�>�	���r8c��tjjtjd�dkD�rOtjjtjd�dk(r/t
jjd�rtjStjjtjd�dk(rCtjjtjd�dk(rtjStjjtjd�dk(rCtjjtjd�dk(rtjSytjjtjd�dk(rCtjjtjd�dk(rtjSy)z� Parse the apt cron configuration. Try to fit a predefined use case
        and return it. Special case: if the user made a custom
        configurtation, that we cannot represent it will return None �
autoupdater�
unattendedr	z/usr/bin/unattended-upgrade�autodownloadN)rrrErBrC�os�path�exists�UPDATE_INST_SEC�UPDATE_DOWNLOAD�
UPDATE_NOTIFY�
UPDATE_MANUAL�r5s r6�get_update_automation_levelz.SoftwareProperties.get_update_automation_level�sg���~�~���/�8�8��F�G�!�K��>�>� � �!3�!<�!<�\�!J�K�q�P��w�w�~�~�;�<�%�5�5�5�
�^�^�
"�
"�#5�#>�#>�~�#N�
O�ST�
T�
�^�^�
"�
"�#5�#>�#>�|�#L�
M�QR�
R�%�5�5�5�
�^�^�
"�
"�#5�#>�#>�|�#L�
M�QR�
R�
�^�^�
"�
"�#5�#>�#>�~�#N�
O�ST�
T�%�3�3�3��	���	�	�1�:�:�<�H�	I�Q�	N�	���	�	�1�:�:�>�J�	K�q�	P�!�/�/�/�r8c��|tjk(rvtjj	tj
dt
d��tjj	tj
dt
d���n�|tjk(rvtjj	tj
dt
d��tjj	tj
dt
d���n6|tjk(rutjj	tj
dt
d��tjj	tj
dt
d��n�tjj	tj
dt
d��tjj	tj
dt
d��tjj	tj
dt
d��|j�y)z� Set the apt periodic configurtation to the selected
        update automation level. To synchronize the cache update and the
        actual upgrading function, the upgrade function, e.g. unattended,
        will run every day, if enabled. rNr	rOrrMN)
rBrSrrrrCrIrTrU�set_modified_config)r5�states  r6�set_update_automation_levelz.SoftwareProperties.set_update_automation_level�s���

�"�2�2�2������-�6�6�|�D�c�!�f�M������-�6�6�~�F��A��O�	�$�4�4�	4������-�6�6�~�F��A��O������-�6�6�|�D�c�!�f�M�	�$�2�2�	2������-�6�6�~�F��A��O������-�6�6�|�D�c�!�f�M������-�6�6�|�D�c�!�f�M������-�6�6�|�D�c�!�f�M������-�6�6�~�F��A��O����r8c��|tjjtjd�k(sKtjjtjdt
|��|j�yy)z8Set the interval in which we check for available updatesrMN)rrrErBrCrrIrZ)r5�dayss  r6�set_update_intervalz&SoftwareProperties.set_update_interval�s]���W�^�^�*�*�+=�+F�+F�|�+T�U�
U�
�.�.�
�
�/�8�8��F��D�	�
R�
�
"�
"�
$�Vr8c�b�tjjtjd�S)z3 Returns the interval of the apt periodic cron job rM)rrrErBrCrWs r6�get_update_intervalz&SoftwareProperties.get_update_interval�s#���>�>� � �!3�!<�!<�\�!J�K�Kr8c��tjj|j�s|jSt�}|j
|j�|jdd�rK|jdd�j�}|jj�D]\}}||k(s�|cS|jS)z�
    return the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
    �DEFAULT�Prompt)rPrQrR�RELEASE_UPGRADES_CONF�RELEASE_UPGRADES_NORMALr�read�
has_option�get�lower�release_upgrades_policy_map�items)r5�parser�type�k�vs     r6�get_release_upgrades_policyz.SoftwareProperties.get_release_upgrades_policy�s����7�7�>�>�$�4�4�5�
�
)�
)�)�
�^�F�
�K�K��*�*�+�
����8�,�
�Z�Z�	�(�
+�
1�
1�
3�d��2�2�8�8�:��$�!�Q���9��(���'�'�'r8c�(�tjj|j�sAt	|jd�5}|jd|j|z�ddd�yt	|jd�5}td��5}|D]g}|j�}|j�jd�r"|jd	|j|z��T|j|d
z��i|j�tj|j|j�tj|j|j�ddd�ddd�y#1swYyxYw#1swY�xYw#1swYyxYw)z
    set the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
     �wz[DEFAULT]
Prompt=%s
NT�rzw+)�mode�promptz
Prompt=%s
�
)rPrQrRre�open�writerkr�striprj�
startswith�flush�shutil�copymode�name�copy)r5�i�f�out�lines     r6�set_release_upgrades_policyz.SoftwareProperties.set_release_upgrades_policy�sC���7�7�>�>�$�4�4�5���*�*�3�/�O�1�	���(�$�*J�*J�1�*M�M�N�O�
�	
�d�(�(��	-�	8��4F�D�4Q�	8�UX���$��z�z�|���:�:�<�"�"�8�,�

�)�)�M�D�$D�$D�Q�$G�G�
H�

�)�)�D��I�
��
�i�i�k��o�o�d�0�0�#�(�(�;��k�k�#�(�(�D�6�6�7�	8�	8��O�
��	8�	8��	8��s1�"E0�
F�CE<�F�0E9�<F	�F�Fc��tjj|j�r�t	|j�5}|j�j
d�}ddd�D]@}	|j
d�\}}|dk(r$|jd�j�dk(ry�By#1swY�OxYw#t$rY�[wxYw)	z� Will return True if the user wants to participate in the popularity
        contest. Otherwise it will return False. Special case: if no
        popcon is installed it will return False rwN�=�PARTICIPATE�"�yesTF)
rPrQrRrrxrg�splitrzrj�
ValueError)r5r��linesr��keyrGs      r6�get_popcon_participationz+SoftwareProperties.get_popcon_participation�s���
�w�w�~�~�d�o�o�&�
�$�/�/�
"�	'�a��&�&�(�.�.��&�%�	'��	�D�
�"�j�j��o���U��-�'�E�K�K��,<�,B�,B�,D��,M���		��	'�	'���
��
�s� B-�-;B9�-B6�9	C�Cc	���|dk(rd}nd}tjj|j�rGt	|jd�5}|D�cgc]}tjdd|z|���}}ddd�n�t�}t	dd	�5}|j|jd
��ddd�|j�}g}|jd|z�|jdt|�z�|jd
�t	|jd�5}|j�ddd�ycc}w#1swY�?xYw#1swY��xYw#1swYyxYw)z? Enable or disable the participation in the popularity contest Tr��nortz^(PARTICIPATE=)(".+?")z\1"%s"Nz/dev/urandom�rbizMY_HOSTID="%s"
zPARTICIPATE="%s"
zUSE_HTTP="yes"
rs)rPrQrRrrx�re�subr�updaterg�	hexdigest�appendrI�
writelines)	r5�
is_helpfulrGrr�r��mr��ids	         r6�set_popcon_pariticipationz,SoftwareProperties.set_popcon_pariticipationsB���T������	�w�w�~�~�d�o�o�&��$�/�/�3�
'�	-�:�!+�-���V�V�5�y�5�7H�$�O�-�E�-�	-�	-�

�E��
�.�$�
'�	#�1�
�H�H�Q�V�V�D�\�"�	#�
�[�[�]����
���)�B�.�/�
���+�c�%�j�8�9�
���)�*�	
�d�o�o�s�	#��q�	���U�����-�	-�	-��	#�	#����s6�
E�!D?�0E�!E�$E�?E�E
�E�E%c��t|jj�dkrd|j_yd|j_i}g}|j	|jj
�|j	|jj�|D]b}|j|vr0|jD] }||jj|��"�At|j�||j<�dt|jj�dkDr-|jj||jj<|jjD]�}|j|vs�|j|vs� tt||j�t|j�z�dk(r�[tt|j�|jjz�dk(r��d|j_yy)z�Return True if all distro componets are also available as
       source code. Otherwise return Flase. Special case: If the
       configuration cannot be represented return Noner	FTrN)�lenr$�source_code_sources�get_source_code�extend�main_sources�
child_sources�template�comps�addr�
cdrom_sources�cdrom_comps�source_template�
enabled_comps)r5�	templates�sources�source�comps     r6�get_source_code_statez(SoftwareProperties.get_source_code_states���
�4�;�;�*�*�+�a�/�',����#��'+����#��	������t�{�{�/�/�0����t�{�{�0�0�1��	?�F����)�+�"�L�L�9�D��f�o�o�.�2�2�4�8�9�.1����->�	�&�/�/�*�	?��t�{�{�(�(�)�A�-�59�[�[�5L�5L�I�d�k�k�1�1�2��k�k�5�5�	�F����i�/����9�,��S��6�?�?�3�4�s�6�<�<�7H�H�I�Q�N���V�\�\�*�T�[�[�-F�-F�F�G�1�L�.3����+��
	�r8c�f�d|jfd|jfd|jfd|jffD]\}}t	d|�d|����|j
rId|j
jfd|j
jffD]\}}t	d|�d|����t	d�y	)
z4Print the data of a source entry to the command linezURI:zComps:zEnabled:zValid:� z	MatchURI:zBaseURI:rwN)�urir��disabled�invalid�printr��	match_uri�base_uri)r5r��labelrGs    r6�print_source_entryz%SoftwareProperties.print_source_entryEs���"�F�J�J�/�$�f�l�l�3�&�F�O�O�(;�<�$�&�.�.�&8�9�;�)����	�%��'�(�	)�
��� +�V�_�_�-F�-F�G� *�F�O�O�,D�,D�E�G�	-�N�U�E��e�U�+�,�	-�
�$�Kr8c��td�|jD]}t|j���td�y)zPrint the complete sources.listzSTART SOURCES.LIST:zEND SOURCES.LIST
N)r�r"rI�r5r�s  r6�massive_debug_outputz'SoftwareProperties.massive_debug_outputRs7��	�
� ��"�"���
�f�j�j�l���	�
�r8c�~�||j_|jj|�}|j�|S)z! change the main download server )r$�default_server�
change_server�set_modified_sourceslist)r5�server�ress   r6�change_main_download_serverz.SoftwareProperties.change_main_download_serverYs3��!'�D�K�K��
�+�+�
#�
#�F�
+�C��!�!�#��Jr8c�Z�|jj|�|j�y)z Enable a component of the distroN)r$�enable_componentr��r5r�s  r6r�z#SoftwareProperties.enable_component`s ���K�K� � ��&��!�!�#r8c�Z�|jj|�|j�y)z!Disable a component of the distroN)r$�disable_componentr�r�s  r6r�z$SoftwareProperties.disable_componentes ���K�K�!�!�$�'��!�!�#r8c�t�|jjjD]}|j|k(s�|cSy�N)r$r��childrenr)r5rr�s   r6�_find_template_from_stringz-SoftwareProperties._find_template_from_stringjs2���K�K�/�/�8�8���	���$�	���r8c�~�t|t�r|j|�}|jjD]-}|j
|k(s�|jj|��/|jjD]-}|j
|k(s�|jj|��/|j�y)�7Enable a child repo of the distribution main repositoryN)
�
isinstancerIr�r$r�r�r"�remover�r�)r5r�r�s   r6�disable_child_sourcez'SoftwareProperties.disable_child_sourceos����(�C� ��0�0��:�h��+�+�+�+�,���?�?�h�&����#�#�F�+�,��+�+�1�1�,���?�?�h�&����#�#�F�+�,�	�!�!�#r8c��t|t�r|j|�}|jdk(r|jj
}n|j}|jj
||j��|j�y)r�N)r��dist)	r�rIr�r�r$r��
add_sourcerr�)r5r��	child_uris   r6�enable_child_sourcez&SoftwareProperties.enable_child_source|sm���(�C� ��0�0��:�h����D� ��K�K�.�.�	��%�%�	��K�K���y�x�}�}��=��!�!�#r8c�(�g}|j|jj�|j|jj�|jjD]}|j
j
|��|j�y)z%Remove all distro source code sourcesN)r�r$r�r�r�r"r�r��r5r�r�s   r6�disable_source_code_sourcesz.SoftwareProperties.disable_source_code_sources�sl���G��N�N�4�;�;�+�+�,��N�N�4�;�;�,�,�-��+�+�1�1�(��������'�(��!�!�#r8c�X�g}|j|jj�|j|jj�|jjD]}|j
j
|��|D]i}|j
jd|j|j|jd|j
j|�dz|j|���k|jjD]�}|j
jd|jjj|jjj |jd|j
j|�dz|j|����|j#�y)z0Enable source code source for all distro sources�deb-srczAdded by software-propertiesr	)�parentN)r�r$r�r�r�r"r�r�r�r�r��index�filer�r�r�rr�r�s   r6�enable_source_code_sourcesz-SoftwareProperties.enable_source_code_sources�s`���G��N�N�4�;�;�+�+�,��N�N�4�;�;�,�,�-��+�+�1�1�(��������'�(��,�������Y�#�Z�Z�#�[�[�#�\�\�;�!�-�-�3�3�F�;�A�=�#�[�[�$*�	�	,�,��+�+�+�+�,�������Y�!�[�[�8�8�A�A�!�[�[�8�8�=�=�#�\�\�;�!�-�-�3�3�F�;�A�=�#�[�[�$*�	�	,�,�	�!�!�#r8c�b�g|_|jjD]�}t|t�r"t	|j
|j��}n@t|t�r"t|j
|j��}ntd|����|jj|���y)z+Store a backup of the source.list in memory�r�r���sectionr��Unknown source: N)
�sourceslist_backupr"�listr�rr�r�r
�	TypeErrorr�)r5r��
source_bkps   r6r)z%SoftwareProperties.backup_sourceslist�s��� �D���"�"�'�'�3���f�k�*�$�&�+�+�6�;�;�G�J�
�� 1�
2�*�6�;�;�V�[�[�Q�J��.�v�h�7�8�8����&�&�z�2�3r8c�~�|j�|jjD]}t|�|k(s�|cSyr�)r(r"r�rI)r5r�r�s   r6�_find_source_from_stringz+SoftwareProperties._find_source_from_string�sA��	�����"�"�'�'���	�V���	��
��r8c��t|t�r|j|�}|j|_|j	�y)z&Enable or disable the selected channelN)r�rIr�r�r�r�s  r6�toggle_source_usez$SoftwareProperties.toggle_source_use�s8���&�#���,�,�V�4�f� �/�/�)�F�O��!�!�#r8c��t|jj�D]�\}}t|�|k(s�|jj|j}t|t�r$t
||�|jj|<n#t||�|jj|<|j�yy)NTF)	r;r"r�rIr�r�r
rr�)r5�	old_entry�	new_entryr��entryr�s      r6�replace_source_entryz'SoftwareProperties.replace_source_entry�s���#�D�$4�$4�$9�$9�:�����	�U��y�	 ����$�$�U�+�0�0���e�.�/�+<�Y��+M�D���!�!�%�(�+6�y�$�+G�D���!�!�%�(��%�%�'���r8c�D�|j�|j�y)zMRevert all settings to the state when software-properties
       was launchedN)rK�revert_sourceslistrWs r6�revertzSoftwareProperties.revert�s��	�������r8c��g|j_|jD]�}t|t�r"t	|j
|j��}n@t|t�r"t|j
|j��}ntd|����|jjj|���|j�|j�y)z6Restore the source list from the startup of the dialogr�r�r�N)r"r�r�r�rr�r�r
r�r��save_sourceslistr()r5r��source_resets   r6r�z%SoftwareProperties.revert_sourceslist�s����D�����)�)�3���f�k�*�&�F�K�K�V�[�[�I�L�
�� 1�
2�,�V�[�[�v�{�{�S�L��.�v�h�7�8�8������$�$�\�2�3�	�������r8c��d|_|jr&|jjr|j�|j	�|j�y)zCThe sources list was changed and now needs to be saved and reloadedTN)r'r �
massive_debugr�r�r(rWs r6r�z+SoftwareProperties.set_modified_sourceslist�sA�� $�D���|�|����2�2��!�!�#��������r8c�$�|j�y)z+Write the changed apt configuration to fileN)rJrWs r6rZz&SoftwareProperties.set_modified_config�s�����r8c�@�|jdk(�r,|jr�t|j�dkDr0|jjdd�j	�dddznd}dt|��d|j��}t|j�d	kDr|jD]
}|d
|zz
}�|jdvr|d
td�zz
}|d
|jzz
}|Sd|j�d|j�d�}|jD]
}|d
|zz
}�|jdvr|d
td�zz
}|Sd|jjz}|jdvr|dtd�zz
}|jr|d
|jzz
}|jjdk(rr|jD]c}|jj|�r>|jjD]$}|j|k(s�|d
|jzz
}�&�\|d
|zz
}�e|S)z5Render a nice output to show the source in a treeviewN�Prwr�u[…]�z<b>z</b> r	z %s)r�zrpm-srcz
(Source Code)z
%sz</b>z	<b>%s</b>z (%s)zSource CodeF)r��commentr��replacerzrr�r�rn�_r��description�child�
has_component�
componentsr)r5r�r��contents�cr�s      r6�
render_sourcez SoftwareProperties.render_source�s��
���$���>�>�!����0�2�5����&�&�t�S�1�7�7�9�#�2�>���;=�
�*0���&�+�+�F�H��6�<�<� �1�$����*�A����	�)�H�*��{�{�4�4��E�A�o�$6�6�6�������+�+�H���'�*0���V�[�[�A�H��\�\�
&���E�A�I�%��
&��{�{�4�4��E�A�o�$6�6�6��������!<�!<�<���;�;�0�0���!�M�"2�2�2�H��>�>��u�v�~�~�-�-�H��?�?� � �E�)����
.���?�?�0�0��6�$�_�_�7�7�?���6�6�T�>�$�����(>�>�H�?����
�-�H�
.��r8c��d}d}d}d}tdd�}|jr>d}|jj}|jj|jk(r9d}n6|j
�d|j�d|j��}|jrd}|jjd�rd}|||||j|�fS)z&extract attributes to sort the sourcesr	�
0123456789�
9876543210rr��src)rr�r�distributionr$r�r�r�r�rn�find�	translate)r5r��cur_sys�has_template�has_comment�	is_source�revert_numbers�descs        r6�get_comparablez!SoftwareProperties.get_comparable(s����g��l��k��i� ��|�<�n�	��������*�*���?�?�'�'�4�;�;�6��G�%�z�z�6�;�;����E�$�
�^�^��k�	���	�	�%�	 ��)��|�[�)��n�n�^�,�.�.r8c�v�g}|jjD]�}|jr�||jjvs�)||jj
vs�B||jjvs�[||jjvs�t||jjvs��|j|���|S)z>Return a list of sources that are not part of the distribution)
r"r�r�r$r�r�r��disabled_sourcesr�r�)r5�isv_sourcesr�s   r6�get_isv_sourcesz"SoftwareProperties.get_isv_sources=s����K��"�"�'�'�'���~�~��$�+�+�2�2�2��$�+�+�3�3�3��$�+�+�3�3�3��$�+�+�6�6�6�����8�8�8����v�&�'��r8c�.�|jjS)z-Return the list of CDROM based distro sources)r$r�rWs r6�get_cdrom_sourcesz$SoftwareProperties.get_cdrom_sourcesJs���;�;�$�$�$r8c�J�|j|jjvdfS)z�Return a tuple: the first value describes if a component is enabled
       in the Internet repositories. The second value describes if the
       first value is inconsistent.F)rr$�download_compsr�s  r6�get_comp_download_statez*SoftwareProperties.get_comp_download_stateNs"��

�I�I����3�3�3�U�;�;r8c��g}|jjD]-}|j|k(s�|j|j��/t|�dkDr/t|jjt|�z�dk(ryt|�dkDr/t|jjt|�z�dk7ryy)z�Return a tuple: the first value describes if a component is enabled
       in one of the child source that matcth the given template.
       The second value describes if the first value is inconsistent.r)TF)FT)FF)r$r�r�r�r�r�r�r)r5r�r�rs    r6�get_comp_child_statez'SoftwareProperties.get_comp_child_stateUs���
�E����*�*�&���>�>�X�%��L�L����%�&��5�z�A�~��D�K�K�%�%��E�
�2�3�q�8��	�U��a���D�K�K�%�%��E�
�2�3�q�8��r8c��|jj�g|_|jj	|j�yr�)r"�refresh�sourceslist_visibler$�get_sourcesrWs r6r(z%SoftwareProperties.reload_sourceslistjs4���������D���K�K���D�,�,�-r8c�0�|jdz|jdz|jdzg}|D]#}tjj|�s�#n�t	d�tjj�}tjj
|�s%tj|�jd��t|dd�5}|jd	�d
d
d
�d}tjj
|�r]tj|�tj}|tjzs$t	d|z�tj|d
�|D�]}g}tjj|�s�&t|d�5}|j!�}d
d
d
�t"j$j'd�}t|d�5}|D]A}	|j)�D]}
|	j+d|
z�dk\s��0|j|	��C|j)�D])}|jd|�d|j-|��d���+	d
d
d
���y
#1swY���xYw#1swY��xYw#1swY��)xYw)z+Write the current apt configuration to filez/etc/apt/apt.conf.d/10periodicz#/etc/apt/apt.conf.d/20auto-upgradesz+/etc/apt/apt.conf.d/15adept-periodic-updatezNo config found, creating oneT)�parentsrrsr�Nz/etc/cron.daily/aptz file '%s' not executable, fixingi�rtz
APT::PeriodiczAPT::Periodic::%szAPT::Periodic::z "z";
)rrPrQ�isfiler��dirnamerR�pathlib�Path�mkdirrxry�stat�ST_MODE�S_IXUSR�chmod�	readlinesrr�subtreer�r
rE)r5�	conffilesr�r(�ac�perm�periodic�content�cnfr�r�r�s            r6rJzSoftwareProperties.write_configos5�����>�>����C�C����K�K�M�I�
�	��	������	�
�	��+�,�������"�g�
�W�W�^�^�G�
$����W��#�#�D�#�1��	�!��c�"��a�	������
�B�	�w�w�~�~�b��
�W�W�R�[����
&�d��T�\�\�!�
�0�2�5�6�
����U���H���g�	������	!�
�(�C�
 �	"�A��K�K�M�'�	"��n�n�$�$�_�5���(�C�
 �
	H�A���d��x�x�z�
�����.�#�6�7�1�<��
��g�g�d�m���8�8�:�H�a�
�G�G�Q��
�
�1�
�F�G�H�
	H�
	H�H���� 	"�	"��

	H�
	H�s+�I2�I?�"0J�AJ�2I<�?J	�J	c�n�|jjd�|jj�y)zQBackup the existing sources.list files and write the current
       configurationz.saveN)r"�backup�saverWs r6r�z#SoftwareProperties.save_sourceslist�s*��	�����G�$������r8c��t|�}tjj|j�r�tj
d|jz�D]�}t
|�5}|D]|}|j�jd�r�#|t|�k(s�2tjjtjj|��dccddd�cS	ddd���y#1swY��xYw)zs
    helper that checks if a given line is in the source list
    return the channel name or None if not found
    z	%s/*.list�#rN)rrPrQrR�CHANNEL_PATH�globrxrzr{�splitext�basename)r5�srcline�srcentry�filenamer�r�s      r6�_get_channel_from_linez)SoftwareProperties._get_channel_from_line�s���
�7�#�H�	�w�w�~�~�d�'�'�(��i�i��d�.?�.?� ?�@�E�(�
�(�^�	E�q��E�d��z�z�|�&�&�s�+���;�t�,�,��W�W�%�%�b�g�g�&6�&6�x�&@�A�!�D�D�	E�	E�E�	E�	E�E��
	E�	E�s�%4C3�AC3�&C3�3C<	c��|j�j}|j|�}|r$|j�d|�d�}|j	|�yy)z�
    helper that adds the gpg key of the channel to the apt
    keyring *if* the channel is in /usr/share/app-install/channels
    rz.keyTF)rr�rDr=�add_key)r5�shortcutrA�channel�keyps     r6�&check_and_add_key_for_channel_shortcutz9SoftwareProperties.check_and_add_key_for_channel_shortcut�sM��
�"�"�$�)�)�G��)�)�'�2�G�� �-�-�w�
7�d�
�l�l�4��
�r8c��y)z) abstract interface to keep the UI alive N�rWs r6�update_interfacez#SoftwareProperties.update_interface�s�r8c���|jd�s|S|j�d}	|jdd�d}d|�d|jj�d|��}|S#t$rd}Y�.wxYw)z�
    short cut - this:
      apt-add-repository http://packages.medibuntu.org free non-free
    same as
      apt-add-repository 'deb http://packages.medibuntu.org/ '$(lsb_release -cs)' free non-free'
    �httprr�r	�mainzdeb )r{r��
IndexErrorr$�codename)r5r��repo�areass    r6�expand_http_linez#SoftwareProperties.expand_http_line�sr���?�?�6�"�
�k��:�:�<��?�D���
�
�3�q�!�!�$���#�D�K�K�$8�$8�%�A�D��K�������s�A�A,�+A,c�x�	t|j��}|j||�S#t$rYywxYw)z*
    Add a source for the given line.
    F)rrzr�add_source_from_shortcut)r5r��enable_source_coderGs    r6�add_source_from_linez'SoftwareProperties.add_source_from_line�sA���#�D�J�J�L�1���(�(��3E�F�F��$��
��s�-�	9�9c	��|j�j}|j}|j|�}|rdnd}||ddz}t||�}t||�}|js|jry|j|�s|j
�|jj|j|j|j|j|j|j|j��|jj||j|j|j|j|j|j��|j!�|j"rF|j"j$r0ddl}	|	j)�}
|
j%|j��y	)
z�
    Add a source with the given shortcut and add the signing key if the
    site is a known channel or the shortcut implementer adds it.
    r�z	# deb-srcrNF)r�r��
architecturesr)�sources_listT)rr��sourceparts_filerUr�rJrFr"r�rnr�r�r�r�r�r[r�r r��apt�Cache)r5rGrX�deb_liner��debsrc_entry_type�debsrc_line�
new_deb_entry�new_debsrc_entryr^�caches           r6rWz+SoftwareProperties.add_source_from_shortcut�s����#�#�%�*�*�H��$�$�D��$�$�X�.�H�%7�	�[��#�h�q�r�l�2�K���$�/�M�"�;��5����� 0� 8� 8�
��6�6�x�@�����������+�+�&�*�*�&�+�+�&�,�,�!.�!6�!6�+�0�0�'4�'B�'B�
�D�	�����*�)�-�-�)�.�.�)�/�/�!1�!9�!9�.�3�3�'7�'E�'E�
�G�	�!�!�#��|�|����+�+���	�	���
���"2�"7�"7��8�r8c�l�|r�t|t�r$|j|�}|j|d�y|�`|j|d�t	j|�}d|_d|_|j|d�d|_|j|d�yt|t�r|j|�}|�y|jtjjd�k7r�|jjd�r;|jjjtd|j���n:|jjjt!d|j���	|jj#|�|j'�y#t$$rY�wxYw)	zRemove the given sourceTNFr�zDir::Etc::sourcelistz.sourcesr�)r�)r�rIr��
remove_sourcer�rnr�r�rr�	find_file�endswithr"r�r�r
rr�r�r�)r5r��remove_source_codes   r6rgz SoftwareProperties.remove_sourcesp���	�F�C�	 ��.�.�v�6�����6�4�(�
������6�5�)����6�"�����������6�5�)�������6�5�)���&�#���,�,�V�4�f�
�~��
�{�{�g�n�n�.�.�/E�F�F�	���	�	�j�	)������$�$�%6�r����%L�M������$�$�[��&�+�+�%F�G��
�����f�%�	�!�!�#��
��
��s�;F'�'	F3�2F3c��tjj|�sy	|jj	|�}|S#YyxYw)z7Add a gnupg key to the list of trusted software vendorsF)rPrQrRr/r�)r5rQr�s   r6rFzSoftwareProperties.add_key3s=��
�7�7�>�>�$�����l�l���t�$���
����s	�?�Ac��tj�}|j|jd��|j	�|j|j�S)z<Add a gnupg key from a utf-8 data string (e.g. copy-n-paste)zutf-8)�tempfilerry�encoder|rFr)r5�keydata�tmps   r6�add_key_from_dataz$SoftwareProperties.add_key_from_data=sA��
�
%�
%�
'�C��I�I�g�n�n�W�%�&��I�I�K��<�<����!�!r8c�J�	|jj|�y#YyxYw)z<Remove a gnupg key from the list of trusted software vendorsTF)r/�rm)r5�keyids  r6�
remove_keyzSoftwareProperties.remove_keyDs$��������������s��"c�H�	|jj�y#YyxYw)z Run apt-key update TF)r/r�rWs r6�update_keyszSoftwareProperties.update_keysLs$���
�l�l����
���
�s��!c�.�t|tj�sJ�|j}|r|j}|j
}n>tj|�}|j|�}|j}|j
}|j�d|�d|�d�S)z" Return the PackageKit package id �;)	r�r�Package�current_ver�ver_str�arch�DepCache�get_candidate_verr)r5�	apt_cache�pkg�cur_ver�verr}�depcache�	candidates        r6�get_package_idz!SoftwareProperties.get_package_idTsy���c�7�?�?�+�+�+��o�o�G���o�o���|�|���#�#�I�.���.�.�s�3�	������~�~���(�(�C��.�.r8c�0�tj|�}|j|�}g}	|jj	d�D]6}|D]/\}}}	|j|�dk7s�|j
||��1�8	|S#ttf$rgcYSwxYw)zF Get the package dependencies, which can be filtered out by a pattern �Depends���)	rr~r�depends_list_strrir
r��KeyErrorr�)
r��package�patternr�r��dependencies�dep_list�dep_name�dep_ver�dep_ops
          r6�get_dependenciesz#SoftwareProperties.get_dependenciesbs������	�*�H��*�*�7�3�I��L��!�2�2�6�6�y�A�	=�H�-5�
=�)��'�6��=�=��)�R�/� �'�'�	�(�(;�<�
=�	=����
�i� ���	��s�;B�&B�B�B)NNrF)F)Tr�)A�__name__�
__module__�__qualname__r=rer��rangerf�RELEASE_UPGRADES_LTS�RELEASE_UPGRADES_NEVERrkr7r4r*rKrXr\r_rarqr�r�r�r�r�r�r�r�r�r�r�r�r�r�r)r�r�r�r�r�r�rZrrrrrr r(rJr�rDrJrMrUrYrWrgrFrqrurwr��staticmethodr�rLr8r6rrDsg��2�,�A���5��8�n�	�����h��e��g�!��'+�R�-���.�(%�L�(�&�0� �2%�N� ��$�
$�
�
$�$�$�$�<
3��$������(�T.�*�%�<��*.�
/H�b�� �0��"	G�$�L)$�V�"���/����r8r�__main__)/rr��hashlibrr�rPr>r}r:r2rmr)�stringr�ImportErrorrIr,r,r-r�xml.sax.saxutilsr�configparserrrrr#�aptsources.distrorBr
�aptsources.sourceslistrrr
�"softwareproperties.shortcuthandlerr�softwareproperties.shortcutsr�
gi.repositoryr�objectrr��spr�rqr�rLr8r6�<module>r�s���4���	�	��
��
��������(�#�(�'�!�����P�P�G�9��m��m�`�z����"���&�&�(�)�� � ��#���[���m�m�)���������(�'�(�s4�C�C�C,�C�C�	C)�(C)�,C:�9C:

Zerion Mini Shell 1.0