
    x
h                        d dl mZmZmZmZ d dlmZ d dlZd dlm	Z	m
Z
 d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dZerd dlZed	ed
ededededededededediZ h dZ!ed        Z"d Z#d$dZ$d%dZ%d Z&d Z'd$dZ(d Z)d Z*d Z+dZ,	 d$dZ-d Z.dZ/e/ja                  d       Z1e/ja                  e,       Z2d! Z3d&d"Z4d&d#Z5y)'    )absolute_importdivisionprint_functionunicode_literals)contextmanagerN)BackendCodeBackend)
fmt_pascalfmt_underscores)ApiNamespace)AnnotationTypeBooleanBytesFloat32Float64Int32Int64ListString	TimestampUInt32UInt64is_user_defined_typeis_aliasFboolbytesfloatintliststrdatetime>   forpassasyncbreakclasswhilecontinuec              #      K   | j                   }d  | j                   }||k(  r"| j                  d       | j                          y y w)Nr#   )linenoemit)codegenstarting_linenoending_linenos      b/var/www/html/lionshead-backend/venv/lib/python3.12/site-packages/stone/backends/python_helpers.pyemit_pass_if_nothing_emittedr0   :   s?      nnO	NNM-'V (s   AAc                      | t         v r| dz   S | S )N_)_reserved_keywords)ss    r/   _rename_if_reservedr5   D   s    3w    c                 6    t        |       }|rt        |      S |S N)r
   r5   namecheck_reservedr4   s      r/   	fmt_classr<   J   s    4A%3q!::r6   c                 d    t        |       } |rt        |       } |dkD  rdj                  | |      } | S )N   z{}_v{})r   r5   format)r:   r;   versions      r/   fmt_funcrA   N   s5    4 D"4({tW-Kr6   c                 0    t        j                  | d      S )Nr>   )width)pprintpformat)os    r/   fmt_objrG   V   s    >>!1%%r6   c                 h    t         j                  | j                  t        | j                              S r8   )_type_tableget	__class__r<   r:   )	data_types    r/   fmt_typerM   Y   s"    ??9..	)..0IJJr6   c                 6    t        |       }|rt        |      S |S r8   )r   r5   r9   s      r/   fmt_varrO   \   s    A%3q!::r6   c                 <    dj                  | |t        |      g      S )N.)joinrO   )ns_namedata_type_name
field_names      r/   fmt_namespaced_varrV   `   s    88Wngj.ABCCr6   c                     t        |       S r8   )r5   )r:   s    r/   fmt_namespacerX   c   s    t$$r6   c                     i }| j                   D ]L  }t        |j                  |j                        }||v r ||   }t	        dj                  ||            |||<   N y)z
    Check name conflicts among generated route definitions. Raise a runtime exception when a
    conflict is encountered.
    )r@   z.There is a name conflict between {!r} and {!r}N)routesrA   r:   r@   RuntimeErrorr?   )	namespaceroute_by_nameroute
route_nameother_routes        r/   check_route_name_conflictra   f   si     M!!ejj%--@
&'
3K@GGUZ[] ]$)j! "r6   z  # type: ignorec           	          |j                  d      }|sy|rt        nd}|D ]8  }| j                  dj                  |t	        |j
                        |             : | j                          y)z
    Both the true Python backend and the Python PEP 484 Type Stub backend have
    to perform the same imports.

    :param insert_type_ignore: add a MyPy type-ignore comment to the imports in
        the except: clause.
    T)consider_annotation_typesN z;from {package} import {namespace_name}{type_ignore_comment})packagenamespace_nametype_ignore_comment)get_imported_namespacesTYPE_IGNORE_COMMENTr+   r?   rX   r:   )backendr\   re   insert_type_ignoreimported_namespacesrg   nss          r/   *generate_imports_for_referenced_namespacesrn   w   sq     $;;VZ;[1C-!RYY(1 3 Z 
 	 " LLNr6   c                     | j                  d       | j                  d       | j                  dj                  d             | j                  d       | j                  d       y )Nz# -*- coding: utf-8 -*-z)# Auto-generated by Stone, do not modify.z# @{}	generatedz# flake8: noqaz# pylint: skip-file)r+   r?   )rj   s    r/   generate_module_headerrq      sM    LL*+LL<= LL,-LL!"LL&'r6   zfrom stone.backends.python_rsrc import stone_base as bb{type_ignore_comment}
from stone.backends.python_rsrc import stone_validators as bv{type_ignore_comment}

rd   )rg   c                 Z    ||k(  r| S dj                  t        |j                        |       S )z
    Returns a name that can be used to reference `name` in namespace `name_ns`
    from `source_ns`.

    If `source_ns` and `name_ns` are the same, that's just `name`. Otherwise
    it's `name_ns`.`name`.
    z{}.{})r?   rX   r:   )r:   name_ns	source_nss      r/   prefix_with_ns_if_necessaryru      s+     G>>-5t<<r6   c                     t        |       st        |       sJ dt        |       z         t        | j                        }|rt        || j                  |      S |S )a>  
    Returns the name of the Python class that maps to a user-defined type.
    The name is identical to the name in the spec.

    If ``ns`` is set to a Namespace and the namespace of `data_type` does
    not match, then a namespace prefix is added to the returned name.
    For example, ``foreign_ns.TypeName``.
    zExpected composite type, got %r)r   r   typer<   r:   ru   r\   )rL   rm   r:   s      r/   class_name_for_data_typerx      sW      	*hy.A <)DO;<AY^^$D	*41D1DbIIKr6   c                     t        | t              sJ t        | j                        }|rt	        || j
                  |      S |S )zL
    Same as class_name_for_data_type, but works with annotation types.
    )
isinstancer   r<   r:   ru   r\   )annotation_typerm   r:   s      r/   class_name_for_annotation_typer|      sA     o~666_))*D	*41J1JBOOKr6   )F)Fr>   r8   )6
__future__r   r   r   r   
contextlibr   rD   stone.backendr   r	   stone.backends.helpersr
   r   stone.irr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _MYPYtypingrI   r3   r0   r5   r<   rA   rG   rM   rO   rV   rX   ra   ri   rn   rq   _validators_import_templater?   validators_import"validators_import_with_type_ignoreru   rx   r|    r6   r/   <module>r      s(   R R %  . "   " 	 V	7WW	5	5&
Ez
E
E   ;&K;D%* )  9>2( 
 06626N %@%G%G+ &H & "= r6   