a
    �Ï?e~  ã                   @   s    d dl mZ G dd„ deƒZdS )é   )ÚCodeGeneratorDraft06c                
       s\   e Zd Zeejfi dddddddœ¤ŽZdi d	f‡ fd
d„	Zdd„ Zdd„ Zdd„ Z	‡  Z
S )ÚCodeGeneratorDraft07z6^(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})\Zz^\w+:(\/?\/?)[^\s]+\Zz'^(\w+:(\/?\/?))?[^#\\\s]*(#[^\\\s]*)?\Zz^[^@]+@[^@]+\.[^@]+\Zz1^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)\Zzu^(?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6}))?([zZ]|[+-]\d\d:\d\d)?)?\Z)ÚdateZiriziri-referencez	idn-emailzrelative-json-pointerÚtimeNTc                    s:   t ƒ  ||||¡ | j d| jfd| jfd| jff¡ d S )NÚifÚcontentEncodingÚcontentMediaType)ÚsuperÚ__init__Z_json_keywords_to_functionÚupdateÚgenerate_if_then_elseÚgenerate_content_encodingÚgenerate_content_media_type)ÚselfZ
definitionÚresolverÚformatsZuse_default©Ú	__class__© úY/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/fastjsonschema/draft07.pyr
      s    ýzCodeGeneratorDraft07.__init__c                 C   sú   | j ddd��, | j| jd | j| jdd� W d  ƒ n1 s@0    Y  |   d¡�B d	| jv r~| j| jd	 | j| jdd� n
|   d
¡ W d  ƒ n1 sœ0    Y  d| jv rö|   d¡�, | j| jd | j| jdd� W d  ƒ n1 sì0    Y  dS )aµ  
        Implementation of if-then-else.

        .. code-block:: python

            {
                'if': {
                    'exclusiveMaximum': 0,
                },
                'then': {
                    'minimum': -10,
                },
                'else': {
                    'multipleOf': 2,
                },
            }

        Valid values are any between -10 and 0 or any multiplication of two.
        útry:F)Úoptimizer   T)Zclear_variablesNz except JsonSchemaValueException:ÚelseÚpassZthenzelse:)ÚlZgenerate_func_code_blockÚ_definitionZ	_variableZ_variable_name©r   r   r   r   r      s0    ü$
ü(
üz*CodeGeneratorDraft07.generate_if_then_elsec              	   C   sâ   | j d dkrÞ|  d¡�¶ |  d¡�$ |  d¡ |  d¡ W d  ƒ n1 sN0    Y  |  d¡� |  d	¡ W d  ƒ n1 s‚0    Y  |  d
¡� |  d¡ W d  ƒ n1 s¶0    Y  W d  ƒ n1 sÔ0    Y  dS )z­
        Means decoding value when it's encoded by base64.

        .. code-block:: python

            {
                'contentEncoding': 'base64',
            }
        r   Úbase64úif isinstance({variable}, str):r   zimport base64z){variable} = base64.b64decode({variable})Núexcept Exception:z {name} must be encoded by base64zif {variable} == "":zcontentEncoding must be base64©r   r   Úexcr   r   r   r   r   K   s    

((z.CodeGeneratorDraft07.generate_content_encodingc              	   C   sF  | j d dk�rB|  d¡�x |  d¡� |  d¡ W d  ƒ n1 sF0    Y  |  d¡� |  d¡ W d  ƒ n1 sz0    Y  W d  ƒ n1 s˜0    Y  |  d	¡�„ |  d¡�$ |  d
¡ |  d¡ W d  ƒ n1 sâ0    Y  |  d¡� |  d¡ W d  ƒ n1 �s0    Y  W d  ƒ n1 �s80    Y  dS )z·
        Means loading value when it's specified as JSON.

        .. code-block:: python

            {
                'contentMediaType': 'application/json',
            }
        r   zapplication/jsonz!if isinstance({variable}, bytes):r   z'{variable} = {variable}.decode("utf-8")Nr   z{name} must encoded by utf8r   zimport jsonz#{variable} = json.loads({variable})z{name} must be valid JSONr    r   r   r   r   r   _   s    
(F
(z0CodeGeneratorDraft07.generate_content_media_type)Ú__name__Ú
__module__Ú__qualname__Údictr   ZFORMAT_REGEXSr
   r   r   r   Ú__classcell__r   r   r   r   r      s   
÷
	.r   N)Zdraft06r   r   r   r   r   r   Ú<module>   s   