U
    g#                     @   sJ  d dl mZ d dl mZ d dl mZ d dl mZ erd 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
n0d 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)Type)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   P/tmp/pip-unpacked-wheel-3ysq0mf8/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                   @   s8   e Zd ZdZdd Zee dddZdddd	ZdS )
_PageSettingsDescriptorz8Descriptor which validates `height` and 'width' of page.c                 C   s
   || _ d S Nnameselfr+   r   r   r   __init__<   s    z _PageSettingsDescriptor.__init__returnc                 C   s   |j | jd S r)   )_pagegetr+   r-   objclsr   r   r   __get__?   s    z_PageSettingsDescriptor.__get__Nc                 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__B   s    z_PageSettingsDescriptor.__set__	r   r   r   __doc__r.   r   r   r6   r<   r   r   r   r   r(   9   s   r(   c                   @   s8   e Zd ZdZdd Zee dddZdddd	ZdS )
_MarginSettingsDescriptorz`Descriptor which validates below attributes.

    - top
    - bottom
    - left
    - right
    c                 C   s
   || _ d S r)   r*   r,   r   r   r   r.   Q   s    z"_MarginSettingsDescriptor.__init__r/   c                 C   s   |j | jd S r)   )_marginr2   r+   r3   r   r   r   r6   T   s    z!_MarginSettingsDescriptor.__get__Nc                 C   s4   t |dd| j | ||j| j< |j|jd< d S )Nr7   zMargin r   )r8   r+   r@   r9   r:   r   r   r   r<   W   s    z!_MarginSettingsDescriptor.__set__r=   r   r   r   r   r?   H   s   r?   c                   @   s8   e Zd ZdZdd Zee dddZdddd	ZdS )
_ScaleDescriptorz'Scale descriptor which validates scale.c                 C   s
   || _ d S r)   r*   r,   r   r   r   r.   `   s    z_ScaleDescriptor.__init__r/   c                 C   s   |j | jS r)   r9   r2   r+   r3   r   r   r   r6   c   s    z_ScaleDescriptor.__get__Nc                 C   s:   t |d| j| |dk s"|dkr*td||j| j< d S )Nr7   g?   z*Value of scale should be between 0.1 and 2)r8   r+   
ValueErrorr9   r:   r   r   r   r<   f   s    z_ScaleDescriptor.__set__r=   r   r   r   r   rA   ]   s   rA   c                   @   s@   e Zd ZdZddgZdd Zee dddZd	dd
dZ	d	S )_PageOrientationDescriptorz?PageOrientation descriptor which validates orientation of page.r   r	   c                 C   s
   || _ d S r)   r*   r,   r   r   r   r.   r   s    z#_PageOrientationDescriptor.__init__r/   c                 C   s   |j | jd S r)   rB   r3   r   r   r   r6   u   s    z"_PageOrientationDescriptor.__get__Nc                 C   s*   || j krtd| j  ||j| j< d S )Nz!Orientation value must be one of )ORIENTATION_VALUESrD   r9   r+   r:   r   r   r   r<   x   s    
z"_PageOrientationDescriptor.__set__)
r   r   r   r>   rF   r.   r   r$   r6   r<   r   r   r   r   rE   m   s
   rE   c                   @   s4   e Zd ZdZedddZdd Zddd	d
ZdS )_ValidateTypeDescriptorzEBase Class Descriptor which validates type of any subclass attribute.)expected_typec                 C   s   || _ || _d S r)   )r+   rH   )r-   r+   rH   r   r   r   r.      s    z _ValidateTypeDescriptor.__init__c                 C   s   |j | jd S r)   rB   r3   r   r   r   r6      s    z_ValidateTypeDescriptor.__get__Nr/   c                 C   s4   t || js$t| j d| jj ||j| j< d S )Nz should be of type )
isinstancerH   rD   r+   r   r9   r:   r   r   r   r<      s    z_ValidateTypeDescriptor.__set__)r   r   r   r>   r   r.   r6   r<   r   r   r   r   rG   ~   s   rG   c                       s    e Zd ZdZ fddZ  ZS )_ValidateBackGroundz&Expected type of background attribute.c                    s   t  |t d S r)   superr.   r#   r,   	__class__r   r   r.      s    z_ValidateBackGround.__init__r   r   r   r>   r.   __classcell__r   r   rM   r   rJ      s   rJ   c                       s    e Zd ZdZ fddZ  ZS )_ValidateShrinkToFitz)Expected type of shrink to fit attribute.c                    s   t  |t d S r)   rK   r,   rM   r   r   r.      s    z_ValidateShrinkToFit.__init__rO   r   r   rM   r   rQ      s   rQ   c                       s    e Zd ZdZ fddZ  ZS )_ValidatePageRangesz'Expected type of page ranges attribute.c                    s   t  |t d S r)   )rL   r.   listr,   rM   r   r   r.      s    z_ValidatePageRanges.__init__rO   r   r   rM   r   rR      s   rR   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dZedddZeeddddZdS )PrintOptionsr   r   r   r   r   r   r    r   r   r!   r"   Nr/   c                 C   s   i | _ i | _i | _d S r)   )r9   r1   r@   r-   r   r   r   r.     s    zPrintOptions.__init__c                 C   s   | j S )z-:Returns: A hash of print options configured.)r9   rU   r   r   r   to_dict  s    zPrintOptions.to_dict)property_namer;   r0   c                 C   s6   t |ttfst| d|dk r2t| 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)rI   intr   rD   )r-   rW   r;   r   r   r   r7     s    z#PrintOptions._validate_num_property)r   r   r   r(   Zpage_heightZ
page_widthr?   Z
margin_topZmargin_bottomZmargin_leftZmargin_rightrA   r    rE   r   rJ   r   rQ   Zshrink_to_fitrR   Zpage_rangesr.   r   rV   r%   r   r7   r   r   r   r   rT      s   rT   N)typingr   r   r   r   r   r   r$   r
   r   r   r&   r'   r%   r(   r?   rA   rE   rG   rJ   rQ   rR   rT   r   r   r   r   <module>   s.   
