o
    ҷhb#                     @   s>  d dl mZ d dl mZ d dl mZ erCd dl mZ d dl mZ ed ZG dd ded	d
ZG dd ded	d
ZG dd ded	d
Z	nd dl m
Z
 d dl mZ eZeee
f  Z ZZ	G dd dZG dd dZG dd dZG dd dZG dd dZG dd deZG dd deZG dd  d eZG d!d" d"Zd#S )$    )TYPE_CHECKING)List)Optional)Literal)	TypedDict)portrait	landscapec                   @   s.   e Zd ZU eed< eed< eed< eed< dS )_MarginOptsleftrighttopbottomN__name__
__module____qualname__float__annotations__ r   r   _/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/print_page_options.pyr	      s
   
 r	   F)totalc                   @   s   e Zd ZU eed< eed< dS )	_PageOptswidthheightNr   r   r   r   r   r   #   s   
 r   c                   @   sJ   e Zd ZU eed< eed< eed< eed< eed< eed< e	e
 ed< dS )	
_PrintOptsmarginpage
backgroundorientationscaleshrinkToFit
pageRangesN)r   r   r   r	   r   r   boolOrientationr   r   strr   r   r   r   r   '   s   
 r   )Any)Dictc                   @   4   e Zd ZdZdd Zdee fddZd
dd	ZdS )_PageSettingsDescriptorz8Descriptor which validates `height` and 'width' of page.c                 C   
   || _ d S Nnameselfr,   r   r   r   __init__;      
z _PageSettingsDescriptor.__init__returnc                 C      |j | jd S r*   )_pagegetr,   r.   objclsr   r   r   __get__>      z_PageSettingsDescriptor.__get__Nc                 C   s.   t |d| j| ||j| j< |j|jd< d S )N_validate_num_propertyr   )getattrr,   r3   _print_optionsr.   r6   valuer   r   r   __set__A   s   z_PageSettingsDescriptor.__set__r1   N	r   r   r   __doc__r/   r   r   r8   r?   r   r   r   r   r(   8   
    r(   c                   @   r'   )_MarginSettingsDescriptorz`Descriptor which validates below attributes.

    - top
    - bottom
    - left
    - right
    c                 C   r)   r*   r+   r-   r   r   r   r/   P   r0   z"_MarginSettingsDescriptor.__init__r1   c                 C   r2   r*   )_marginr4   r,   r5   r   r   r   r8   S   r9   z!_MarginSettingsDescriptor.__get__Nc                 C   s4   t |dd| j | ||j| j< |j|jd< d S )Nr:   zMargin r   )r;   r,   rE   r<   r=   r   r   r   r?   V   s   z!_MarginSettingsDescriptor.__set__r@   rA   r   r   r   r   rD   G   s
    rD   c                   @   r'   )_ScaleDescriptorz'Scale descriptor which validates scale.c                 C   r)   r*   r+   r-   r   r   r   r/   _   r0   z_ScaleDescriptor.__init__r1   c                 C   s   |j | jS r*   r<   r4   r,   r5   r   r   r   r8   b   s   z_ScaleDescriptor.__get__Nc                 C   s:   t |d| j| |dk s|dkrtd||j| j< d S )Nr:   g?   z*Value of scale should be between 0.1 and 2)r;   r,   
ValueErrorr<   r=   r   r   r   r?   e   s   z_ScaleDescriptor.__set__r@   rA   r   r   r   r   rF   \   rC   rF   c                   @   s<   e Zd ZdZddgZdd Zdee fddZdd
dZ	d	S )_PageOrientationDescriptorz?PageOrientation descriptor which validates orientation of page.r   r   c                 C   r)   r*   r+   r-   r   r   r   r/   q   r0   z#_PageOrientationDescriptor.__init__r1   c                 C   r2   r*   rG   r5   r   r   r   r8   t   r9   z"_PageOrientationDescriptor.__get__Nc                 C   s*   || j vrtd| j  ||j| j< d S )Nz!Orientation value must be one of )ORIENTATION_VALUESrI   r<   r,   r=   r   r   r   r?   w   s   
z"_PageOrientationDescriptor.__set__r@   )
r   r   r   rB   rK   r/   r   r#   r8   r?   r   r   r   r   rJ   l   s    rJ   c                   @   s.   e Zd ZdZdZdd Zdd Zd
dd	ZdS )_ValidateTypeDescriptorzEBase Class Descriptor which validates type of any subclass attribute.Nc                 C   r)   r*   r+   )r.   r,   expected_typer   r   r   r/      r0   z _ValidateTypeDescriptor.__init__c                 C   r2   r*   rG   r5   r   r   r   r8      r9   z_ValidateTypeDescriptor.__get__r1   c                 C   s4   t || jst| j d| jj ||j| j< d S )Nz should be of type )
isinstancerM   rI   r,   r   r<   r=   r   r   r   r?      s   z_ValidateTypeDescriptor.__set__r@   )r   r   r   rB   rM   r/   r8   r?   r   r   r   r   rL   }   s    rL   c                   @      e Zd ZdZeZdS )_ValidateBackGroundz&Expected type of background attribute.Nr   r   r   rB   r"   rM   r   r   r   r   rP          rP   c                   @   rO   )_ValidateShrinkToFitz)Expected type of shirnk to fit attribute.NrQ   r   r   r   r   rS      rR   rS   c                   @   rO   )_ValidatePageRangesz'Excepted type of page ranges attribute.N)r   r   r   rB   listrM   r   r   r   r   rT      rR   rT   c                   @   s   e Zd ZedZ	 edZ	 edZ	 edZ	 edZ		 edZ
	 edZ	 edZ	 ed	eZ	 ed
eZ	 edeZ	 dddZdefddZdededdfddZdS )PrintOptionsr   r   r   r   r
   r   r   r   r   r    r!   r1   Nc                 C   s   i | _ i | _i | _d S r*   )r<   r3   rE   r.   r   r   r   r/     s   
zPrintOptions.__init__c                 C   s   | j S )z-:Returns: A hash of print options configured.)r<   rW   r   r   r   to_dict  s   zPrintOptions.to_dictproperty_namer>   c                 C   s6   t |ttfst| d|dk rt| ddS )z3Helper function to validate some of the properties.z  should be an integer or a floatr   z cannot be less then 0N)rN   intr   rI   )r.   rY   r>   r   r   r   r:     s
   z#PrintOptions._validate_num_propertyr@   )r   r   r   r(   page_height
page_widthrD   
margin_topmargin_bottommargin_leftmargin_rightrF   r   rJ   r   rP   r"   r   rS   shrink_to_fitrT   rU   page_rangesr/   r   rX   r$   r   r:   r   r   r   r   rV      s4    



rV   N)typingr   r   r   r   r   r#   r	   r   r   r%   r&   r$   r(   rD   rF   rJ   rL   rP   rS   rT   rV   r   r   r   r   <module>   s.   
