o
    ѷ6ic&                     @   s  d dl mZ er3d 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)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   q/var/www/hoanhtaovolam_webdjango/env/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dB 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__returnNc                 C      |j | jd S r(   )_pagegetr*   r,   objclsr   r   r   __get__:      z_PageSettingsDescriptor.__get__c                 C   s.   t |d| j| ||j| j< |j|jd< d S )N_validate_num_propertyr   )getattrr*   r1   _print_optionsr,   r4   valuer   r   r   __set__=   s   z_PageSettingsDescriptor.__set__r/   Nr   r   r   __doc__r-   r   r6   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__r/   Nc                 C   r0   r(   )_marginr2   r*   r3   r   r   r   r6   O   r7   z!_MarginSettingsDescriptor.__get__c                 C   s4   t |dd| j | ||j| j< |j|jd< d S )Nr8   zMargin r   )r9   r*   rC   r:   r;   r   r   r   r=   R   s   z!_MarginSettingsDescriptor.__set__r>   r?   r   r   r   r   rB   C   s
    rB   c                   @   r%   )_ScaleDescriptorz'Scale descriptor which validates scale.c                 C   r'   r(   r)   r+   r   r   r   r-   [   r.   z_ScaleDescriptor.__init__r/   Nc                 C   s   |j | jS r(   r:   r2   r*   r3   r   r   r   r6   ^   s   z_ScaleDescriptor.__get__c                 C   s:   t |d| j| |dk s|dkrtd||j| j< d S )Nr8   g?   z*Value of scale should be between 0.1 and 2)r9   r*   
ValueErrorr:   r;   r   r   r   r=   a   s   z_ScaleDescriptor.__set__r>   r?   r   r   r   r   rD   X   rA   rD   c                   @   s<   e Zd ZdZddgZdd ZdedB 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__r/   Nc                 C   r0   r(   rE   r3   r   r   r   r6   p   r7   z"_PageOrientationDescriptor.__get__c                 C   s*   || j vrtd| j  ||j| j< d S )Nz!Orientation value must be one of )ORIENTATION_VALUESrG   r:   r*   r;   r   r   r   r=   s   s   
z"_PageOrientationDescriptor.__set__r>   )	r   r   r   r@   rI   r-   r!   r6   r=   r   r   r   r   rH   h   s    rH   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*   rK   )r,   r*   rK   r   r   r   r-   |   s   
z _ValidateTypeDescriptor.__init__c                 C   r0   r(   rE   r3   r   r   r   r6      r7   z_ValidateTypeDescriptor.__get__r/   Nc                 C   s4   t || jst| j d| jj ||j| j< d S )Nz should be of type )
isinstancerK   rG   r*   r   r:   r;   r   r   r   r=      s   z_ValidateTypeDescriptor.__set__r>   )r   r   r   r@   typer-   r6   r=   r   r   r   r   rJ   y   s
    rJ   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   r@   r-   __classcell__r   r   rS   r   rO          rO   c                       rN   )_ValidateShrinkToFitz)Expected type of shrink to fit attribute.c                    rP   r(   rQ   r+   rS   r   r   r-      rU   z_ValidateShrinkToFit.__init__rV   r   r   rS   r   rY      rX   rY   c                       rN   )_ValidatePageRangesz'Expected type of page ranges attribute.c                    rP   r(   )rR   r-   r"   r+   rS   r   r   r-      rU   z_ValidatePageRanges.__init__rV   r   r   rS   r   rZ      rX   rZ   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@r/   Nc                 C   s(   i | _ tjd tjd d| _i | _d S )Nr   r   r\   )r:   r[   A4r1   rC   r,   r   r   r   r-   I  s
   
zPrintOptions.__init__c                 C   s   | j S )z+Returns a hash of print options configured.)r:   r^   r   r   r   to_dictQ  s   zPrintOptions.to_dict	page_sizec                 C   sL   |  d|d  |  d|d  |d | jd< |d | jd< | j| jd< dS )ah  Sets the page size to predefined or custom dimensions.

        Args:
            page_size: A dictionary containing 'height' and 'width' keys with
                respective values in cm.

        Example:
            self.set_page_size(PageSize.A4)  # A4 predefined size
            self.set_page_size({"height": 15.0, "width": 20.0})  # Custom size
        r   r   r   N)r8   r1   r:   )r,   r`   r   r   r   set_page_sizeU  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)rL   intr   rG   )r,   rb   r<   r   r   r   r8   f  s
   z#PrintOptions._validate_num_propertyr>   )!r   r   r   r&   page_height
page_widthrB   
margin_topmargin_bottommargin_leftmargin_rightrD   r   rH   r   rO   r   rY   shrink_to_fitrZ   page_rangesr]   LEGALLETTERTABLOIDr-   r   r_   dictra   r#   r   r8   r   r   r   r   r[      s>    




r[   N)typingr   r   r   r!   r   r   r   r$   r#   ro   r&   rB   rD   rH   rJ   rO   rY   rZ   r[   r   r   r   r   <module>   s&   
