a
    xd                     @  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ddl	m
Z
 ddl	mZ eG dd	 d	ZeG d
d dZddddZddddZddddZdddddZddddZedeG dd dZdS )    )annotations   )event_classT_JSON_DICT)	dataclassN)network)runtimec                   @  s   e Zd ZU dZded< ded< ded< ded< dZd	ed
< dZd	ed< dZded< dZded< dZ	ded< dZ
d	ed< dZded< dd Zedd ZdS )LogEntryz
    Log entry.
    strsourceleveltextzruntime.Timestamp	timestampNztyping.Optional[str]categoryurlztyping.Optional[int]line_numberz#typing.Optional[runtime.StackTrace]stack_tracez"typing.Optional[network.RequestId]network_request_id	worker_idz2typing.Optional[typing.List[runtime.RemoteObject]]argsc                 C  s   t  }| j|d< | j|d< | j|d< | j |d< | jd urF| j|d< | jd urZ| j|d< | jd urn| j|d< | j	d ur| j	 |d< | j
d ur| j
 |d	< | jd ur| j|d
< | jd urdd | jD |d< |S )Nr   r   r   r   r   r   
lineNumber
stackTracenetworkRequestIdworkerIdc                 S  s   g | ]}|  qS  to_json.0ir   r   c/var/www/html/Ranjet/env/lib/python3.9/site-packages/selenium/webdriver/common/devtools/v112/log.py
<listcomp>H       z$LogEntry.to_json.<locals>.<listcomp>r   )dictr   r   r   r   r   r   r   r   r   r   r   r   selfjsonr   r   r    r   5   s(    













zLogEntry.to_jsonc                 C  s   | t |d t |d t |d tj|d d|v rBt |d nd d|v rXt |d nd d|v rnt|d nd d|v rtj|d nd d	|v rtj|d	 nd d
|v rt |d
 nd d|v rdd |d D nd dS )Nr   r   r   r   r   r   r   r   r   r   r   c                 S  s   g | ]}t j|qS r   )r   ZRemoteObject	from_jsonr   r   r   r    r!   X   r"   z&LogEntry.from_json.<locals>.<listcomp>)r   r   r   r   r   r   r   r   r   r   r   )r
   r   	Timestampr'   intZ
StackTracer   Z	RequestIdclsr&   r   r   r    r'   K   s    


zLogEntry.from_json)__name__
__module____qualname____doc____annotations__r   r   r   r   r   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 )ViolationSettingz*
    Violation configuration setting.
    r
   namefloat	thresholdc                 C  s   t  }| j|d< | j|d< |S )Nr3   r5   )r#   r3   r5   r$   r   r   r    r   g   s    

zViolationSetting.to_jsonc                 C  s   | t |d t|d dS )Nr3   r5   )r3   r5   )r
   r4   r*   r   r   r    r'   m   s    

zViolationSetting.from_jsonN)r,   r-   r.   r/   r0   r   r1   r'   r   r   r   r    r2   \   s   
r2   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])returnc                  c  s   ddi} | V }dS )z
    Clears the log.
    methodz	Log.clearNr   cmd_dictr&   r   r   r    clearu   s    r:   c                  c  s   ddi} | V }dS )z^
    Disables log domain, prevents further log entries from being reported to the client.
    r7   zLog.disableNr   r8   r   r   r    disable   s    r;   c                  c  s   ddi} | V }dS )z
    Enables log domain, sends the entries collected so far to the client by means of the
    ``entryAdded`` notification.
    r7   z
Log.enableNr   r8   r   r   r    enable   s    r<   ztyping.List[ViolationSetting])configr6   c                 c  s,   t  }dd | D |d< d|d}|V }dS )zV
    start violation reporting.

    :param config: Configuration for violations.
    c                 S  s   g | ]}|  qS r   r   r   r   r   r    r!      r"   z+start_violations_report.<locals>.<listcomp>r=   zLog.startViolationsReport)r7   paramsN)r#   )r=   r>   r9   r&   r   r   r    start_violations_report   s    r?   c                  c  s   ddi} | V }dS )z#
    Stop violation reporting.
    r7   zLog.stopViolationsReportNr   r8   r   r   r    stop_violations_report   s    r@   zLog.entryAddedc                   @  s.   e Zd ZU dZded< edd dddZdS )	
EntryAddedz-
    Issued when new message was logged.
    r	   entryr   )r&   r6   c                 C  s   | t |d dS )NrB   )rB   )r	   r'   r*   r   r   r    r'      s    zEntryAdded.from_jsonN)r,   r-   r.   r/   r0   r1   r'   r   r   r   r    rA      s   
rA   )
__future__r   utilr   r   Zdataclassesr   enumtyping r   r   r	   r2   r:   r;   r<   r?   r@   rA   r   r   r   r    <module>   s$   K


