o
    M,h(                     @   s  d dl mZmZ er5d dl mZ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	 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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   x/var/www/www-root/data/www/bot.pdev.uz/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   liststrr   r   r   r   r   $   s   
 r   )Anyc                   @   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__7      
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+   r2   _print_optionsr-   r5   valuer   r   r   __set__=   s   z_PageSettingsDescriptor.__set__r0   N	r   r   r   __doc__r.   r   r   r7   r>   r   r   r   r   r'   4   
    r'   c                   @   r&   )_MarginSettingsDescriptorz`Descriptor which validates below attributes.

    - top
    - bottom
    - left
    - right
    c                 C   r(   r)   r*   r,   r   r   r   r.   L   r/   z"_MarginSettingsDescriptor.__init__r0   c                 C   r1   r)   )_marginr3   r+   r4   r   r   r   r7   O   r8   z!_MarginSettingsDescriptor.__get__Nc                 C   s4   t |dd| j | ||j| j< |j|jd< d S )Nr9   zMargin r   )r:   r+   rD   r;   r<   r   r   r   r>   R   s   z!_MarginSettingsDescriptor.__set__r?   r@   r   r   r   r   rC   C   s
    rC   c                   @   r&   )_ScaleDescriptorz'Scale descriptor which validates scale.c                 C   r(   r)   r*   r,   r   r   r   r.   [   r/   z_ScaleDescriptor.__init__r0   c                 C   s   |j | jS r)   r;   r3   r+   r4   r   r   r   r7   ^   s   z_ScaleDescriptor.__get__Nc                 C   s:   t |d| j| |dk s|dkrtd||j| j< d S )Nr9   g?   z*Value of scale should be between 0.1 and 2)r:   r+   
ValueErrorr;   r<   r   r   r   r>   a   s   z_ScaleDescriptor.__set__r?   r@   r   r   r   r   rE   X   rB   rE   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.   m   r/   z#_PageOrientationDescriptor.__init__r0   c                 C   r1   r)   rF   r4   r   r   r   r7   p   r8   z"_PageOrientationDescriptor.__get__Nc                 C   s*   || j vrtd| j  ||j| j< d S )Nz!Orientation value must be one of )ORIENTATION_VALUESrH   r;   r+   r<   r   r   r   r>   s   s   
z"_PageOrientationDescriptor.__set__r?   )
r   r   r   rA   rJ   r.   r   r"   r7   r>   r   r   r   r   rI   h   s    rI   c                   @   s0   e Zd ZdZdefddZdd Zdd	d
ZdS )_ValidateTypeDescriptorzEBase Class Descriptor which validates type of any subclass attribute.expected_typec                 C   s   || _ || _d S r)   )r+   rL   )r-   r+   rL   r   r   r   r.   |   s   
z _ValidateTypeDescriptor.__init__c                 C   r1   r)   rF   r4   r   r   r   r7      r8   z_ValidateTypeDescriptor.__get__r0   Nc                 C   s4   t || jst| j d| jj ||j| j< d S )Nz should be of type )
isinstancerL   rH   r+   r   r;   r<   r   r   r   r>      s   z_ValidateTypeDescriptor.__set__r?   )r   r   r   rA   typer.   r7   r>   r   r   r   r   rK   y   s
    rK   c                           e Zd ZdZ fddZ  ZS )_ValidateBackGroundz&Expected type of background attribute.c                       t  |t d S r)   superr.   r!   r,   	__class__r   r   r.         z_ValidateBackGround.__init__r   r   r   rA   r.   __classcell__r   r   rT   r   rP          rP   c                       rO   )_ValidateShrinkToFitz)Expected type of shrink to fit attribute.c                    rQ   r)   rR   r,   rT   r   r   r.      rV   z_ValidateShrinkToFit.__init__rW   r   r   rT   r   rZ      rY   rZ   c                       rO   )_ValidatePageRangesz'Expected type of page ranges attribute.c                    rQ   r)   )rS   r.   r#   r,   rT   r   r   r.      rV   z_ValidatePageRanges.__init__rW   r   r   rT   r   r[      rY   r[   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	Z	 ed
Z	 edZ	 dddZdddZdddZdddZd ddZdefddZdedd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    g33333=@g      5@r   r   gHzA@gףp=
5@gq=
ף;@gףp=
E@r0   Nc                 C   s(   i | _ tjd tjd d| _i | _d S )Nr   r   r]   )r;   r\   A4r2   rD   r-   r   r   r   r.     s
   
zPrintOptions.__init__c                 C   s   | j S )z-:Returns: A hash of print options configured.)r;   r_   r   r   r   to_dict  s   zPrintOptions.to_dict	page_sizec                 C   sL   |  d|d  |  d|d  |d | jd< |d | jd< | j| jd< dS )a  Sets the page size to predefined or custom dimensions.

        Parameters:
        -----------
        page_size: dict
        A dictionary containing `height` and `width` as keys with respective values.

        Example:
        --------
        self.set_page_size(PageSize.A4)  # A4 predefined size
        self.set_page_size({"height": 15.0, "width": 20.0})  # Custom size in cm
        r   r   r   N)r9   r2   r;   )r-   ra   r   r   r   set_page_size  s
   zPrintOptions.set_page_size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 than 0N)rM   intr   rH   )r-   rc   r=   r   r   r   r9     s
   z#PrintOptions._validate_num_propertyr?   )!r   r   r   r'   page_height
page_widthrC   
margin_topmargin_bottommargin_leftmargin_rightrE   r   rI   r   rP   r   rZ   shrink_to_fitr[   page_rangesr^   LEGALLETTERTABLOIDr.   r   r`   dictrb   r$   r   r9   r   r   r   r   r\      s>    




r\   N)typingr   r   r   r   r"   r   r   r   r%   r$   rp   r'   rC   rE   rI   rK   rP   rZ   r[   r\   r   r   r   r   <module>   s&   
