o
    ҷh,                     @  s   d dl mZ ddlmZmZ d dlmZ d dlZd dlZeG dd dZ	eG dd	 d	Z
eG d
d dZeG dd dZG dd dejZG dd dejZeG dd dZeG dd dZeG dd dZd$ddZd%dd Zd&d"d#ZdS )'    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  sn   e Zd ZU dZded< ded< ded< ded< ded< ded	< d
Zded< d
Zded< dd Zedd Z	d
S )	GPUDevicez6
    Describes a single graphics processor (GPU).
    float	vendor_id	device_idstrvendor_stringdevice_stringdriver_vendordriver_versionNztyping.Optional[float]
sub_sys_idrevisionc                 C  sn   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | jd ur+| j|d< | jd ur5| j|d< |S )	NvendorIddeviceIdvendorStringdeviceStringdriverVendordriverVersionsubSysIdr   )	dictr	   r
   r   r   r   r   r   r   selfjson r   f/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v117/system_info.pyto_json*   s   









zGPUDevice.to_jsonc                 C  st   | t |d t |d t|d t|d t|d t|d d|v r)t |d nd d|v r6t |d d	S d d	S )
Nr   r   r   r   r   r   r   r   )r	   r
   r   r   r   r   r   r   )r   r   clsr   r   r   r   	from_json8   s   





zGPUDevice.from_json)
__name__
__module____qualname____doc____annotations__r   r   r   classmethodr"   r   r   r   r   r      s   
 r   c                   @  s6   e Zd ZU dZded< ded< dd Zedd Zd	S )
SizezA
    Describes the width and height dimensions of an entity.
    intwidthheightc                 C  s   t  }| j|d< | j|d< |S )Nr+   r,   )r   r+   r,   r   r   r   r   r   Q   s   

zSize.to_jsonc                 C  s   | t |d t |d dS )Nr+   r,   )r+   r,   )r*   r    r   r   r   r"   W   s   

zSize.from_jsonNr#   r$   r%   r&   r'   r   r(   r"   r   r   r   r   r)   F   s   
 r)   c                   @  s>   e Zd ZU dZded< ded< ded< dd Zed	d
 ZdS ) VideoDecodeAcceleratorCapabilityzo
    Describes a supported video decoding profile with its associated minimum and
    maximum resolutions.
    r   profiler)   max_resolutionmin_resolutionc                 C  s0   t  }| j|d< | j |d< | j |d< |S )Nr/   maxResolutionminResolution)r   r/   r0   r   r1   r   r   r   r   r   n   s
   
z(VideoDecodeAcceleratorCapability.to_jsonc                 C  s*   | t |d t|d t|d dS )Nr/   r2   r3   )r/   r0   r1   )r   r)   r"   r    r   r   r   r"   u   s
   
z*VideoDecodeAcceleratorCapability.from_jsonNr-   r   r   r   r   r.   _   s   
 r.   c                   @  sF   e Zd ZU dZded< ded< ded< ded< d	d
 Zedd ZdS ) VideoEncodeAcceleratorCapabilityzx
    Describes a supported video encoding profile with its associated maximum
    resolution and maximum framerate.
    r   r/   r)   r0   r*   max_framerate_numeratormax_framerate_denominatorc                 C  s6   t  }| j|d< | j |d< | j|d< | j|d< |S )Nr/   r2   maxFramerateNumeratormaxFramerateDenominator)r   r/   r0   r   r5   r6   r   r   r   r   r      s   


z(VideoEncodeAcceleratorCapability.to_jsonc                 C  s2   | t |d t|d t|d t|d dS )Nr/   r2   r7   r8   )r/   r0   r5   r6   )r   r)   r"   r*   r    r   r   r   r"      s   


z*VideoEncodeAcceleratorCapability.from_jsonNr-   r   r   r   r   r4   ~   s   
 r4   c                   @  0   e Zd ZdZdZdZdZdd Zedd Z	d	S )
SubsamplingFormatz>
    YUV subsampling type of the pixels of a given image.
    yuv420yuv422yuv444c                 C     | j S Nvaluer   r   r   r   r         zSubsamplingFormat.to_jsonc                 C     | |S r?   r   r    r   r   r   r"         zSubsamplingFormat.from_jsonN)
r#   r$   r%   r&   YUV420YUV422YUV444r   r(   r"   r   r   r   r   r:          r:   c                   @  r9   )
	ImageTypez(
    Image format of a given image.
    jpegwebpunknownc                 C  r>   r?   r@   rB   r   r   r   r      rC   zImageType.to_jsonc                 C  rD   r?   r   r    r   r   r   r"      rE   zImageType.from_jsonN)
r#   r$   r%   r&   JPEGWEBPUNKNOWNr   r(   r"   r   r   r   r   rJ      rI   rJ   c                   @  sF   e Zd ZU dZded< ded< ded< ded< d	d
 Zedd ZdS ) ImageDecodeAcceleratorCapabilityz
    Describes a supported image decoding profile with its associated minimum and
    maximum resolutions and subsampling.
    rJ   
image_typer)   max_dimensionsmin_dimensionsztyping.List[SubsamplingFormat]subsamplingsc                 C  sH   t  }| j |d< | j |d< | j |d< dd | jD |d< |S )N	imageTypemaxDimensionsminDimensionsc                 S     g | ]}|  qS r   r   .0ir   r   r   
<listcomp>       z<ImageDecodeAcceleratorCapability.to_json.<locals>.<listcomp>rU   )r   rR   r   rS   rT   rU   r   r   r   r   r      s   z(ImageDecodeAcceleratorCapability.to_jsonc                 C  s<   | t |d t|d t|d dd |d D dS )NrV   rW   rX   c                 S     g | ]}t |qS r   )r:   r"   r[   r   r   r   r^          z>ImageDecodeAcceleratorCapability.from_json.<locals>.<listcomp>rU   )rR   rS   rT   rU   )rJ   r"   r)   r    r   r   r   r"      s   z*ImageDecodeAcceleratorCapability.from_jsonNr-   r   r   r   r   rQ      s   
 rQ   c                   @  sf   e Zd ZU dZded< ded< ded< ded	< d
ed< dZded< dZded< dd Zedd Z	dS )GPUInfoz>
    Provides information about the GPU(s) on the system.
    ztyping.List[GPUDevice]devicesztyping.List[str]driver_bug_workaroundsz-typing.List[VideoDecodeAcceleratorCapability]video_decodingz-typing.List[VideoEncodeAcceleratorCapability]video_encodingz-typing.List[ImageDecodeAcceleratorCapability]image_decodingNztyping.Optional[dict]aux_attributesfeature_statusc                 C  s   t  }dd | jD |d< dd | jD |d< dd | jD |d< dd | jD |d	< d
d | jD |d< | jd ur?| j|d< | jd urI| j|d< |S )Nc                 S  rY   r   rZ   r[   r   r   r   r^     r_   z#GPUInfo.to_json.<locals>.<listcomp>rc   c                 S  s   g | ]}|qS r   r   r[   r   r   r   r^     s    driverBugWorkaroundsc                 S  rY   r   rZ   r[   r   r   r   r^     r_   videoDecodingc                 S  rY   r   rZ   r[   r   r   r   r^     r_   videoEncodingc                 S  rY   r   rZ   r[   r   r   r   r^     r_   imageDecodingauxAttributesfeatureStatus)r   rc   rd   re   rf   rg   rh   ri   r   r   r   r   r     s   



zGPUInfo.to_jsonc              
   C  s   | dd |d D dd |d D dd |d D dd |d	 D d
d |d D d|v r3t |d nd d|v r@t |d dS d dS )Nc                 S  r`   r   )r   r"   r[   r   r   r   r^     ra   z%GPUInfo.from_json.<locals>.<listcomp>rc   c                 S  s   g | ]}t |qS r   )r   r[   r   r   r   r^     r_   rj   c                 S  r`   r   )r.   r"   r[   r   r   r   r^     ra   rk   c                 S  r`   r   )r4   r"   r[   r   r   r   r^     ra   rl   c                 S  r`   r   )rQ   r"   r[   r   r   r   r^     ra   rm   rn   ro   )rc   rd   re   rf   rg   rh   ri   )r   r    r   r   r   r"     s   zGPUInfo.from_json)
r#   r$   r%   r&   r'   rh   ri   r   r(   r"   r   r   r   r   rb      s   
 rb   c                   @  s>   e Zd ZU dZded< ded< ded< dd	 Zed
d ZdS )ProcessInfoz"
    Represents process info.
    r   type_r*   id_r   cpu_timec                 C  s(   t  }| j|d< | j|d< | j|d< |S )NtypeidcpuTime)r   rq   rr   rs   r   r   r   r   r   *  s
   


zProcessInfo.to_jsonc                 C  s&   | t |d t|d t|d dS )Nrt   ru   rv   )rq   rr   rs   )r   r*   r   r    r   r   r   r"   1  s
   


zProcessInfo.from_jsonNr-   r   r   r   r   rp     s   
 rp   returnPtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[GPUInfo, str, str, str]]c                  c  s>    ddi} | V }t |d t|d t|d t|d fS )a  
    Returns information about the system.

    :returns: A tuple with the following items:

        0. **gpu** - Information about the GPUs on the system.
        1. **modelName** - A platform-dependent description of the model of the machine. On Mac OS, this is, for example, 'MacBookPro'. Will be the empty string if not supported.
        2. **modelVersion** - A platform-dependent description of the version of the machine. On Mac OS, this is, for example, '10.1'. Will be the empty string if not supported.
        3. **commandLine** - The command line string used to launch the browser. Will be the empty string if not supported.
    methodzSystemInfo.getInfogpu	modelNamemodelVersioncommandLine)rb   r"   r   cmd_dictr   r   r   r   get_info:  s   


r   feature_stater   0typing.Generator[T_JSON_DICT, T_JSON_DICT, bool]c                 c  s,    t  }| |d< d|d}|V }t|d S )z`
    Returns information about the feature state.

    :param feature_state:
    :returns: 
    featureStatezSystemInfo.getFeatureState)ry   paramsfeatureEnabled)r   bool)r   r   r   r   r   r   r   get_feature_stateQ  s   	r   Dtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[ProcessInfo]]c                  c  s"    ddi} | V }dd |d D S )zj
    Returns information about all running processes.

    :returns: An array of process info blocks.
    ry   zSystemInfo.getProcessInfoc                 S  r`   r   )rp   r"   r[   r   r   r   r^   n  ra   z$get_process_info.<locals>.<listcomp>processInfor   r~   r   r   r   get_process_infod  s
   r   )rw   rx   )r   r   rw   r   )rw   r   )
__future__r   utilr   r   dataclassesr   enumtypingr   r)   r.   r4   Enumr:   rJ   rQ   rb   rp   r   r   r   r   r   r   r   <module>   s0   8$#3

