HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/Quirks/__pycache__/quirkapplier.cpython-310.pyc
o

��f��@sfddlmZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z	Gdd�d�Zdd�ZdS)�)�globNc@sheZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�QuirkChecker�/usr/share/jockey/quirkscCs.||_||_g|_|��|��|_d|_dS)Nz/usr/share/X11/xorg.conf.d)�_handler�quirks_path�_quirks�get_quirks_from_path�get_system_info�_system_info�_xorg_conf_d_path)�self�handler�path�r�5/usr/lib/python3/dist-packages/Quirks/quirkapplier.py�__init__!s

zQuirkChecker.__init__cCs|g|_tj�|j�r3ttj�|jd��D]}tj�|�r/t�	d|�|�
|�}|j|7_q|jSt�	d|j�|jS)�5check all the files in a directory looking for quirks�*z
Parsing %sz%s does not exist)r�osr�isdirrr�join�isfile�logging�debug�get_quirks_from_file)r�f�quirksrrrr)s
��z!QuirkChecker.get_quirks_from_pathcCstj�|�}|��S)r)�Quirks�quirkreader�	ReadQuirk�
get_quirks)r�
quirk_filerrrr7sz!QuirkChecker.get_quirks_from_filecCstj��}|��S)zGet system info for the quirk)r�	quirkinfo�	QuirkInfo�get_dmi_info)r�
quirk_inforrrr	=s
zQuirkChecker.get_system_infocCs�d}|j��D]2}|j|D]*}|j�|�r8|j�|�|kr8t|j|�dkr8t�d|j�|�|f�dSqqt�d�|S)zSee if tags match system infoT�zFailure to match %s with %sF�Success)�
match_tags�keysr
�get�lenrr)r�quirk�result�tag�valrrr�matches_tagsBs���
zQuirkChecker.matches_tagsTcCs�|jD]?}|j��dd�|jD�vrBt�d|j�|�|�r=|r/t�d|j�|�	|�qt�d|j�|�
|�qt�d�qdS)z)Process quirks and do something with themcSsg|]}|�����qSr)�lower�strip)�.0�xrrr�
<listcomp>Rsz.QuirkChecker._check_quirks.<locals>.<listcomp>zProcessing quirk %szApplying quirk %szUnapplying quirk %szQuirk doesn't matchN)rrr1r
rr�idr0�info�_apply_quirk�_unapply_quirk)r�enabler,rrr�
_check_quirksOs


��zQuirkChecker._check_quirkscC�|�d�dS)zEnable all quirks for a handlerTN�r;�rrrr�
enable_quirks_�zQuirkChecker.enable_quirkscCr<)z Disable all quirks for a handlerFNr=r>rrr�disable_quirkscr@zQuirkChecker.disable_quirkscCs d|j|j|j���dd�fS)z$Return the path to the X config filez%s/10-%s-%s.conf� �-)rrr6r1�replace)rr,rrr�_get_destination_pathgs�z"QuirkChecker._get_destination_pathcCs�|�|�}tjddd�}|�|j�|��tj�|j	�}t
�|j�t
�|j	�zt
�d|�|�|�WdStyGt
�d�YdSw)z!Get the xorg snippet and apply it�wF)�mode�deletezCreating %szError during write()T)rE�tempfile�NamedTemporaryFile�write�	x_snippet�close�xkit�
xorgparser�Parser�namerr�
globaldictr�unlink�IOError�	exception)rr,�destination�tmp_file�tmp_xkitrrrr8ls
�
�zQuirkChecker._apply_quirkc	CsL|�|�}t�d|�zt�|�WdSttfy%t�d�YdSw)z%Remove the file with the xorg snippetzRemoving %s ...zCannot unlink destinationFT)rErrrrS�OSErrorrTrU)rr,rVrrrr9�s
�
�zQuirkChecker._unapply_quirkN)r)T)�__name__�
__module__�__qualname__rrrr	r0r;r?rArEr8r9rrrrr s


rcCs0tddd�}|��|��ttj�t��dS)N�nvidiaz/home/alberto/oem/jockey/quirks)rr)rr?rA�printrr�abspath�__file__)�arrr�main�s
rb)
rr�sysrIr�xkit.xutilsrN�xkit.xorgparser�Quirks.quirkreaderr�Quirks.quirkinforrbrrrr�<module>sn