
    ȇh                     J    S SK r SSKJrJr  SSKJr  SSKJr   " S S\5      rg)    N   )CodeGeneratorDraft04JSON_TYPE_TO_PYTHON_TYPE)JsonSchemaDefinitionException)enforce_listc                      ^  \ rS rSr\" \R                  40 SSSS.D6rS0 SSS4U 4S jjrS	 rS
 r	S r
S rS rS rS rS rSrU =r$ )CodeGeneratorDraft06   z^(/(([^/~])|(~[01]))*)*\Zz'^(\w+:(\/?\/?))?[^#\\\s]*(#[^\\\s]*)?\Zz^(?:(?:[^\x00-\x20\"\'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*\Z)zjson-pointerzuri-referencezuri-templateNTc                    > [         TU ]  XX4XV5        U R                  R                  SU R                  4SU R
                  4SU R                  4SU R                  4SU R                  445        g )NexclusiveMinimumexclusiveMaximumpropertyNamescontainsconst)	super__init___json_keywords_to_functionupdategenerate_exclusive_minimumgenerate_exclusive_maximumgenerate_property_namesgenerate_containsgenerate_const)self
definitionresolverformatsuse_defaultuse_formatsdetailed_exceptions	__class__s          nC:\Users\julio\OneDrive\Documentos\Trabajo\IdeasFrscas\Cabanna\env\Lib\site-packages\fastjsonschema/draft06.pyr   CodeGeneratorDraft06.__init__   ss    w[f''..!@!@A!@!@Ad::;//0d))*0
 	    c                     [        U[        5      (       a  U R                  5         g SU;   a  U R                  5         g U R	                  U5        g )Nz$ref)
isinstanceboolgenerate_boolean_schemagenerate_refrun_generate_functions)r   r   s     r"   _generate_func_code_block.CodeGeneratorDraft06._generate_func_code_block   s=    j$''((*z!''
3r$   c                     U R                   SL a  U R                  S5        U R                   SL a  U R                  S5        gg)zm
Means that schema can be specified by boolean.
True means everything is valid, False everything is invalid.
TpassF{name} must not be thereN)_definitionlexcr   s    r"   r(   ,CodeGeneratorDraft06.generate_boolean_schema&   s=    
 t#FF6Nu$HH/0 %r$   c                    [        U R                  S   5      n SR                  S U 5       5      nSnSU;   a  USR                  U R                  S	9-  nS
U;   d  SU;   a"  SU;  a  USR                  U R                  S	9-  nU R                  SX$5         U R                  SSR                  U5      SS9  SSS5        g! [         a  n[	        SR                  U5      5      eSnAff = f! , (       d  f       g= f)z
Validation of type. Can be one type or list of types.

Since draft 06 a float without fractional part is an integer.

.. code-block:: python

    {'type': 'string'}
    {'type': ['string', 'number']}
typez, c              3   4   #    U  H  n[         U   v   M     g 7f)N)r   ).0ts     r"   	<genexpr>5CodeGeneratorDraft06.generate_type.<locals>.<genexpr>=   s     $P%Q%=a%@%s   zUnknown type: {}N integerzD and not (isinstance({variable}, float) and {variable}.is_integer()))variablenumberbooleanz  or isinstance({variable}, bool)z&if not isinstance({variable}, ({})){}:z{name} must be {}z or rule)	r   r0   joinKeyErrorr   format	_variabler1   r2   )r   typespython_typesr2   extras        r"   generate_type"CodeGeneratorDraft06.generate_type0   s    T--f56	P99$P%$PPL [bb c  E e!3%9O7>>>WWEVV<lRHH(&++e*<6HJ SR  	P/0B0I0I#0NOO	P SRs#   C  !C, 
C)
C$$C),
C:c                 T   U R                  S5         [        U R                  S   [        [        [
        R                  45      (       d  [        S5      eU R                  S5         U R                  SSS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)N1if isinstance({variable}, (int, float, Decimal)):r   z9exclusiveMinimum must be an integer, a float or a decimalz$if {variable} <= {exclusiveMinimum}:z-{name} must be bigger than {exclusiveMinimum}rA   	r1   r&   r0   intfloatdecimalDecimalr   r2   r3   s    r"   r   /CodeGeneratorDraft06.generate_exclusive_minimumN   s    VVGHd../ABS%QXQ`Q`Dabb34opp>?HOab @ IH @? IH$   AB&B7B
B	B
B'c                 T   U R                  S5         [        U R                  S   [        [        [
        R                  45      (       d  [        S5      eU R                  S5         U R                  SSS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NrM   r   z9exclusiveMaximum must be an integer, a float or a decimalz$if {variable} >= {exclusiveMaximum}:z.{name} must be smaller than {exclusiveMaximum}rA   rN   r3   s    r"   r   /CodeGeneratorDraft06.generate_exclusive_maximumU   s    VVGHd../ABS%QXQ`Q`Dabb34opp>?IPbc @ IH @? IHrT   c                    U R                   R                  S0 5      nUSL a  gUSL a;  U R                  5         U R                  S5         U R	                  SSS9  SSS5        gU R                  5         U R                  S5         U R                  5         U R                  S	5         U R                  S
5        U R                  S5         U R                  S5         U R                  USR                  U R                  5      U R                  SS9  SSS5        U R                  S5         U R                  S5        SSS5        SSS5        U R                  S5         U R	                  SSS9  SSS5        SSS5        SSS5        g! , (       d  f       g= f! , (       d  f       N= f! , (       d  f       Ns= f! , (       d  f       N|= f! , (       d  f       Nc= f! , (       d  f       Nl= f! , (       d  f       g= f)z
Means that keys of object must to follow this definition.

.. code-block:: python

    {
        'propertyNames': {
            'maxLength': 3,
        },
    }

Valid keys of object for this definition are foo, bar, ... but not foobar for example.
r   TFzif {variable}_keys:r/   rA   Nzif {variable}_is_dict:zif {variable}_len != 0:z {variable}_property_names = True!for {variable}_key in {variable}:try:{}_keyclear_variablesz except JsonSchemaValueException:z!{variable}_property_names = Falsez!if not {variable}_property_names:z/{name} must be named by propertyName definition)r0   getcreate_variable_keysr1   r2   create_variable_is_dictcreate_variable_with_lengthgenerate_func_code_blockrE   rF   _variable_name)r   property_names_definitions     r"   r   ,CodeGeneratorDraft06.generate_property_names\   s    %)$4$4$8$8"$M!$,&%/%%'-.3/J /. ((*01002VV56FF=> CD!VVF^ 99 9 ( ? $ 3 304	 :  , "VV$FG FF#FG H E  CD!RYhi E 7 21	 /. ,^ HG ED ED 76 21s   	F"G-&#G	F:6F	F:*F)	<F:GG.G6G-
F
F&"F:)
F73F::
GG
GG
G*	&G--
G;c           
      \   U R                  5         U R                  S5         U R                  S   nUSL a  U R                  SSS9  GOUSL a+  U R                  S5         U R                  SSS9  S	S	S	5        OU R                  S
5        U R                  S5         U R                  S5         U R	                  USR                  U R                  5      U R                  SS9  U R                  S5        U R                  S5        S	S	S	5        U R                  S5        S	S	S	5        U R                  S5         U R                  SSS9  S	S	S	5        S	S	S	5        g	! , (       d  f       N= f! , (       d  f       Nk= f! , (       d  f       Nc= f! , (       d  f       NJ= f! , (       d  f       g	= f)z
Means that array must contain at least one defined item.

.. code-block:: python

    {
        'contains': {
            'type': 'number',
        },
    }

Valid array is any with at least one number.
zif {variable}_is_list:r   Fz{name} is always invalidrA   Tzif not {variable}:z{name} must not be emptyNz{variable}_contains = FalserX   rY   rZ   r[   z{variable}_contains = Truebreakz%except JsonSchemaValueException: passzif not {variable}_contains:z.{name} must contain one of contains definition)create_variable_is_listr1   r0   r2   ra   rE   rF   rb   )r   contains_definitions     r"   r   &CodeGeneratorDraft06.generate_contains   s]    	$$&VV,-"&"2"2:">"e+3*E$,VV01HH7jHI 21 45VV?@55/$OODNN; //,0	 6  ;<w ( FFBC A VV9:HHMT^H_ ;- .- 21
 ( A@ ;:- .-sl   =FE0+FE;-AE*E;F7FF
E'	#F*
E84E;;
F		F
F	F
F+c                    U R                   S   n[        U[        5      (       a   SR                  U R	                  U5      5      nU R                  SU5         U R                  SSS9  SSS5        g! , (       d  f       g= f)z
Means that value is valid when is equeal to const definition.

.. code-block:: python

    {
        'const': 42,
    }

Only valid value is 42 in this example.
r   z"{}"zif {variable} != {}:z:{name} must be same as const definition: {definition_rule}rA   N)r0   r&   strrE   er1   r2   )r   r   s     r"   r   #CodeGeneratorDraft06.generate_const   sd       )eS!!MM$&&-0EVV*E2HHQX_H` 322s   A11
A? )__name__
__module____qualname____firstlineno__dictr   FORMAT_REGEXSr   r+   r(   rJ   r   r   r   r   r   __static_attributes____classcell__)r!   s   @r"   r	   r	      sv    -;; 	4C0		@ 	M -1"$\`vz 41K<cd&jP&`Pa ar$   r	   )	rQ   draft04r   r   
exceptionsr   	generatorr   r	   rn   r$   r"   <module>rz      s"     C 5 #ua/ uar$   