B wÏ1`nã@s ddlmZGdd„deƒZdS)é)ÚCodeGeneratorDraft06c sXeZdZeejfdddddddœŽZdid f‡fd d „ Zd d „Zdd„Zdd„Z ‡Z S)ÚCodeGeneratorDraft07z6^(?P\d{4})-(?P\d{1,2})-(?P\d{1,2})\Zz^\w+:(\/?\/?)[^\s]+\Zz'^(\w+:(\/?\/?))?[^#\\\s]*(#[^\\\s]*)?\Zz^[^@]+@[^@]+\.[^@]+\Zz1^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)\Zzu^(?P\d{1,2}):(?P\d{1,2})(?::(?P\d{1,2})(?:\.(?P\d{1,6}))?([zZ]|[+-]\d\d:\d\d)?)?\Z)ÚdateZiriz iri-referencez idn-emailzrelative-json-pointerÚtimeNTcs:tƒ ||||¡|j d|jfd|jfd|jff¡dS)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__©ú:/tmp/pip-unpacked-wheel-vlg95h98/fastjsonschema/draft07.pyr s zCodeGeneratorDraft07.__init__c Csº| d¡"|j|jd|j|jddWdQRX| d¡8d|jkrf|j|jd|j|jddn | d¡WdQRXd |jkr¶| d ¡"|j|jd |j|jddWdQRXdS) 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. ztry:rT)Zclear_variablesNz except JsonSchemaValueException:ÚelseÚpassZthenzelse:)ÚlZgenerate_func_code_blockÚ _definitionZ _variableZ_variable_name)rrrrr s*      z*CodeGeneratorDraft07.generate_if_then_elsec Cs’|jddkrŽ| d¡p| d¡| d¡| d¡WdQRX| d¡| d ¡WdQRX| d ¡| d ¡WdQRXWdQRXdS) z­ Means decoding value when it's encoded by base64. .. code-block:: python { 'contentEncoding': 'base64', } rÚbase64zif isinstance({variable}, str):ztry:z import base64z){variable} = base64.b64decode({variable})Nzexcept Exception:z {name} must be encoded by base64zif {variable} == "":zcontentEncoding must be base64)rrÚexc)rrrrr Ks      z.CodeGeneratorDraft07.generate_content_encodingc CsÈ|jddkrÄ| d¡F| d¡| d¡WdQRX| d¡| d¡WdQRXWdQRX| d ¡P| d¡| d ¡| d ¡WdQRX| d¡| d ¡WdQRXWdQRXdS) z· Means loading value when it's specified as JSON. .. code-block:: python { 'contentMediaType': 'application/json', } rzapplication/jsonz!if isinstance({variable}, bytes):ztry:z'{variable} = {variable}.decode("utf-8")Nzexcept Exception:z{name} must encoded by utf8zif isinstance({variable}, str):z import jsonz#{variable} = json.loads({variable})z{name} must be valid JSON)rrr)rrrrr_s        z0CodeGeneratorDraft07.generate_content_media_type) Ú__name__Ú __module__Ú __qualname__ÚdictrZ FORMAT_REGEXSr r r rÚ __classcell__rr)rrrs  .rN)Zdraft06rrrrrrÚs