
    x
h_                     L   d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZmZmZmZ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 dZerd dlZd dlZ ej@                   e!d	            Z"d
Z# ejH                  d      Z%dZ&e"jO                  dd      Z(e(jS                  ddde!d       e(jS                  ddde!d       e(jS                  ddde!d       e(jS                  ddde!d       e(jS                  d d!e!d"#       e(jS                  d$d%d&e!g d'(        G d) d*e      Z*y)+    )absolute_importdivisionprint_functionunicode_literalsN)CodeBackend)fmt_underscores)check_route_name_conflict	fmt_classfmt_funcfmt_namespacefmt_objfmt_typefmt_var)class_name_for_data_type)is_nullable_typeis_list_typeis_map_typeis_struct_type
is_tag_refis_union_typeis_user_defined_typeis_void_typeFargparsez# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# flake8: noqa
# pylint: skip-file

from abc import ABCMeta, abstractmethod
z:(?P<tag>[A-z]*):`(?P<val>.*?)`a+  If you do not consume the entire response body, then you must call close on the
response object, otherwise you will max out your available connections. We
recommend using the `contextlib.closing
<https://docs.python.org/2/library/contextlib.html#contextlib.closing>`_
context manager to ensure this.zpython-client-backendzGenerates a Python class with a method for each route. Extend the generated class and implement the abstract request() method. This class assumes that the python_types backend was used with the same output directory.)progdescriptionz-mz--module-nameTzQThe name of the Python module to generate. Please exclude the .py file extension.)requiredtypehelpz-cz--class-namezBThe name of the Python class that contains each route as a method.z-tz--types-packagez6The output Python package of the python_types backend.z-ez--error-class-pathz.exceptions.ApiErrorz}The path to the class that's raised when a route returns an error. The class name is inserted into the doc for route methods.)defaultr   r   z-wz--auth-typez(The auth type of the client to generate.)r   r   z-az--attribute-commentappendzRoute attributes that the backend will have access to and presumably expose in generated code. Use ":all" to select all attributes defined in stone_cfg.Route. Attributes will be exposed in the documentation, as the client doesn't use them.)actionr   r   r   c                   d    e Zd ZeZdZd Zd Zd Zd Z	ddZ
	 ddZd Z	 	 	 dd	Zd
 Zd Zd Zy)PythonClientBackendNc                    | j                  d| j                  j                  z        5  | j                  t               d}|j
                  j                         D ]8  }|j                  D ]#  }|j                  s| j                  d       d} n |s8 n | j                          | j                  |j
                  j                                | j                          | j                          | j                  d| j                  j                  z         | j                         5  | j                  d       | j                          | j                  d       | j                  d       | j                         5  | j                  d	       d
d
d
       | j                          | j                  |j
                  j                                d
d
d
       d
d
d
       y
# 1 sw Y   SxY w# 1 sw Y   xY w# 1 sw Y   y
xY w)zGenerates a module called "base".

        The module will contain a base class that will have a method for
        each route across all namespaces.
        z%s.pyFzimport warningsTzclass %s(object):z__metaclass__ = ABCMetaz@abstractmethodz:def request(self, route, namespace, arg, arg_binary=None):passN)output_to_relative_pathargsmodule_nameemit_rawbase
namespacesvaluesroutes
deprecatedemit_generate_imports
class_nameindent_generate_route_methods)selfapifound_deprecated	namespaceroutes        a/var/www/html/lionshead-backend/venv/lib/python3.12/site-packages/stone/backends/python_client.pygeneratezPythonClientBackend.generate~   sw    ))'DII4I4I*IJMM$$ ^^224	&--E''		"34+/(	 .
 $ 5 IIK""3>>#8#8#:;IIKIIKII)DII,@,@@A		34				+,		PR[[]IIf% #		,,S^^-B-B-DE # KJ. #] # KJsK   AG7:G7BG7'AG+;GAG+G7G($G++G4	0G77H c           	          |D ]W  }|j                   s| j                  dj                  | j                  j                  t        |j                                     Y y )Nzfrom {} import {})
data_typesr/   formatr'   types_packager   namer4   r+   r7   s      r9   r0   z%PythonClientBackend._generate_imports   sE    #I##		-44TYY5L5Lm\e\j\jNklm $    c                     d| _         |D ]k  }|j                  s| j                  d       | j                  dj                  |j                               | j                          | j                  |       m y)zvCreates methods for the routes in each namespace. All data types
        and routes are represented as Python classes.Nz,# ------------------------------------------z# Routes in {} namespace)cur_namespacer-   r/   r=   r?   _generate_routesr@   s      r9   r3   z+PythonClientBackend._generate_route_methods   s_     "#I		HI		4;;INNKL		%%i0 $rA   c                 Z   || _         | j                  j                  T| j                  j                  j                  d      D cg c]   }|j	                         j                         " c}| _        t        |       |j                  D ]  }| j                  E| j                  ||       |j                  j                  d      dk(  sA| j                  ||d       Ud}|j                  |j                  j                  d      }||j                  d      D cg c]   }|j	                         j                         " }}| j                  D ]L  }||v s| j                  ||       |j                  j                  d      dk(  r| j                  ||d          yc c}w c c}w )zV
        Generates Python methods that correspond to routes in the namespace.
        N,styledownloadTauth)rC   r'   	auth_typesplitstriplowersupported_auth_typesr	   r-   _generate_route_helperattrsget)r4   r7   rJ   r8   route_auth_attrmoderoute_auth_modesbase_auth_types           r9   rD   z$PythonClientBackend._generate_routes   sx    ' 99*TXT]T]TgTgTmTmnqTr(sTry):)@)@)BTr(sD%!),%%E ((0++Iu=;;??7+z9//	5$G"&;;*&+kkoof&=O"*ETEZEZ[^E_#`E_TDJJL$6$6$8E_ #`&*&?&?N%)9933IuE ;;??73zA 77	5$O '@ &	 )t" $as   %F#%F(c                 2   |j                   }|j                  }|j                  j                  d      dk(  }|j                  j                  d      dk(  }|r"|sJ d       | j	                  ||||ddg       n| j	                  ||||       | j                         5  d}d}	d}
|rd	g}n|rd
g}|r
|sd}	t        }
|j                  r'| j                  |j                  | j                        }nd}| j                  ||||j                  |||	|
|j                  	       | j                  |       t        |      r| j                  d       nt        |      rv| j!                  |j"                  D cg c]  }|j$                   c}dj'                  t)        |j*                  j$                        t-        |j$                                     nt/        |      st1        d|z        dj'                  t)        |j$                        t3        |j$                  |j4                              dj'                  |j$                        dg}|r|j7                  d       n|j7                  d       | j!                  |dd       |r@| j                  d       t        |      r| j                  d       n@| j                  d       n.t        |      r| j                  d       n| j                  d       ddd       | j                          yc c}w # 1 sw Y   xY w)a  Generate a Python method that corresponds to a route.

        :param namespace: Namespace that the route belongs to.
        :param stone.ir.ApiRoute route: IR node for the route.
        :param bool download_to_file: Whether a special version of the route
            that downloads the response body to a file should be generated.
            This can only be used for download-style routes.
        rG   uploadrH   z;download_to_file can only be set for download-style routes._to_filedownload_path)method_name_suffix
extra_argsN)fbyteszContents to upload.)rY   strz#Path on local machine to save file.z!:class:`requests.models.Response`)overviewextra_request_argsextra_return_argfooterrP   z
arg = Nonezarg = {}.{})beforezUnhandled request type %rz{}.{}version'{}'argr\   Nonezr = self.requestF)compactz,self._save_body_to_file(download_path, r[1])zreturn Nonezreturn r[0]zreturn r)arg_data_typeresult_data_typerP   rQ   _generate_route_method_declr2   DOCSTRING_CLOSE_RESPONSEdocprocess_doc_docf_generate_docstring_for_funcerror_data_type#_maybe_generate_deprecation_warningr   r/   r   generate_multiline_list
all_fieldsr?   r=   r   r7   r
   r   AssertionErrorr   re   r    )r4   r7   r8   download_to_filerj   rk   request_binary_bodyresponse_binary_bodyr`   ra   rb   func_docstringr\   r'   s                 r9   rO   z*PythonClientBackend._generate_route_helper   s    ++ 11#kkoog6(B${{w7:E' - *- -',,Y-2-:-@@J9H8I - K ,,Y-2-:-@B
 [[]!%#F"'> &?" "'N &O" $,<#F 1yy!%!1!1%))TZZ!H!%-- %%'#5!1kk . 
 44U; M*		,'.,,%2%=%=>%=QVV%=>(//%m&=&=&B&BC!-"4"457 -  #=1$%@%2&3 4 4
 }Y^^<'

EMMJLinn-	D
 #C F#((/A5(Q		HI 01IIm,IIm, 01IIm,IIj)O P 			A ?Q ]s    CL0L
E,LLLc                 V   dg}|r||z  }|r|j                  d       t        |      r|j                  D ]  }t        |j                        r+|j                  dj                  |j                               C|j                  rvt        |j                        r|j                  j                  }	nd}	dj                  |j                  | j                  |	|j                              }
|j                  |
       |j                  |j                          n6t        |      r|j                  d       nt        |      st        d|z        t        |j                  |z   |j                         }t#        |j                        }| j%                  |d	j                  ||      d
       y)z+Generates the method prototype for a route.r4   r\   z{}=NoneNz{}={}rg   zUnhandled request type: %rrd   z	def {}_{}:)r    r   ru   r   	data_typer=   r?   has_defaultr   r7   _generate_python_valuer   r   r   rv   r   re   r   rt   )r4   r7   r8   rj   rx   rZ   r[   r'   fieldnsrg   method_namenamespace_names                r9   rl   z/PythonClientBackend._generate_route_method_decl=  sY    xJDKK-(&11#EOO4KK	 0 0 <=&&
 ,EOO<"__66!!..

33BFHC KK$KK

+# 2$ =)KKm, !=!."/ 0 0 uzz,>>V(8$$T;+=+=nk+Z\_`rA   c                 4   |j                   rdj                  |j                        }|j                   j                  r2|dj                  |j                   j                  j                        z  }dj                  |      dg}| j	                  |ddd       y y )	Nz{} is deprecated.z Use {}.rf   DeprecationWarningzwarnings.warn)()F)rc   delimri   )r.   r=   r?   byrt   )r4   r8   msgr'   s       r9   rs   z7PythonClientBackend._maybe_generate_deprecation_warningc  s    %,,UZZ8C""z(()9)9)<)<)A)ABBMM#&(<=D((& 	 )  rA   c
           
      
   t        |      rg n|j                  }
g }| j                  j                  rL|	rJ| j                  j                  D ]1  }||	v s|	|   |j	                  dj                  ||	|                3 |
s|s|sy| j                  d       |r| j                  |       |r<|r| j                          | j                  d       |D ]  }| j                  |d        |s|
r|s|r| j                          |rW|D ]R  \  }}}|r'dj                  |||      }| j                  |d       0| j                  dj                  ||      d       T t        |      r|
D ]x  }|j                  r!t        |j                        rAdj                  |j                  | j                  |j                  | j                              }n[dj                  | j                  ||j                        |j                  | j                  |j                  | j                              }| j                  |d       t        |j                        s| j                  d	j                  |j                  | j                  ||j                                     2d	j                  |j                  | j                  ||j                              }| j                  |       { nt!        |      r|j                  rF| j                  d
j                  | j                  |j                  | j                              d       | j                  dj                  | j                  ||                   |s|r|s|
s| j                          |rfg }t        |      r|j	                  d       n#| j                  ||      }|j	                  |       |j	                  |       | j#                  |d       nOt        |      r| j                  d       n2| j                  ||      }| j                  dj                  |             t        |      s|j                  r| j                  dj                  | j                  j$                               | j                          | j                  j$                  j'                  dd      d   }| j                  dj                  |             | j)                         5  | j                  | j                  ||             ddd       |r!| j                          | j                  |       | j                  d       y# 1 sw Y   >xY w)a  
        Generates a docstring for a function or method.

        This function is versatile. It will create a docstring using all the
        data that is provided.

        :param arg_data_type: The data type describing the argument to the
            route. The data type should be a struct, and each field will be
            treated as an input parameter of the method.
        :param result_data_type: The data type of the route result.
        :param error_data_type: The data type of the route result in the case
            of an error.
        :param str overview: A description of the route that will be located
            at the top of the docstring.
        :param extra_request_args: [(field name, field type, field doc), ...]
            Describes any additional parameters for the method that aren't a
            field in arg_data_type.
        :param str extra_return_arg: Name of an additional return type that. If
            this is specified, it is assumed that the return of the function
            will be a tuple of return_data_type and extra_return-arg.
        :param str footer: Additional notes at the end of the docstring.
        Nz{}: {}z"""zRoute attributes:z    z:param {} {}: {})subsequent_prefixz:param {}: {}z:type {}: {}z:param arg: {}z:type arg: {}rh   z:rtype: z:rtype: Nonez
:rtype: {}z:raises: :class:`{}`.   z If this raises, {} will contain:)r   fieldsr'   attribute_commentr    r=   r/   emit_wrapped_textr   rn   r   r}   r?   ro   rp   _format_type_in_docr   rt   error_class_pathrsplitr2   )r4   r7   rj   rk   rr   r_   r`   ra   rb   rP   r   attrs_lines	attributear?   data_type_namern   	field_docr   r'   rtypeerror_class_names                         r9   rq   z0PythonClientBackend._generate_docstring_for_funcp  s   4 $M28L8L99&&5!YY88	%%	*:*F&&xy%	BR'ST 9 h{ 		%""8,		II)* &&q&1 ! ;		!1C-D.#%$6$=$=n>BC%I	..yAG / I ..+224=.4 / 6 2D m,#Eyy/@(7(>(> %

D,<,<UYY

,S)UI );(A(A $ 8 8EOO T %

 $ 0 0DJJ G)I
 ..% / A/@ !IIn&;&; %

 $ 8 8EOO T'  %3$9$9!JJ 44YP%	 ..y99 $< }- $$**+;+B+B(():):DJJG,I*0 + 2 		/00,,YFH I .@F IIK D,-F#001ACE"KK()((z:,-		.)00<LM		,--e45O,1G1GII,33DII4N4NOPIIK
  $yy99@@aHLII8??@PQR		$229oNO  IIK""6*		% s   4"UUc                    |dk(  rH|}d|vr| j                   j                  dz   |z   }dj                  | j                  j                  |      S |dk(  rxd|v r!|j                  dd      \  }}t        |      }nd}d|v rdj                  t        ||            S d	j                  | j                   j                  t        ||            S |d
k(  r'|j                  dd      \  }}dj                  ||      S |dk(  r1|dk(  ry|dk(  s|dk(  rdj                  |j                               S |S |dk(  rdj                  |      S t        d|z        )z
        Callback used as the handler argument to process_docs(). This converts
        Babel doc references to Sphinx-friendly annotations.
        r   r   z:class:`{}.{}`r8   r|   r   z
:meth:`{}`rd   z:meth:`{}_{}`link z
`{} <{}>`_valnullrh   truefalsez``{}``r   zUnknown doc ref tag %r)rC   r?   r=   r'   r>   rK   intr   r   
capitalizeRuntimeError)r4   tagr   fq_valre   anchorr   s          r9   rp   zPythonClientBackend._docf  sY   
 &=F#~++0036?#**499+B+BFKKG^cz"yya0Wg,cz#**8C+IJJ&--&&++Xc7-KM MF]::c1-LFD&&vt44E\f}#.s~~'788
G^??3''7#=>>rA   c                 4   t        |      ryt        |      r:dj                  | j                  j                  |j
                  t        |            S t        |      r+dj                  | j                  ||j                              S t        |      r+dj                  | j                  ||j                              S t        |      rFdj                  | j                  ||j                        | j                  ||j                              S t        |      S )zo
        Returns a string that can be recognized by Sphinx as a type reference
        in a docstring.
        rh   z:class:`{}.{}.{}`zNullable[{}]zList[{}]zMap[{}, {}])r   r   r=   r'   r>   r?   r   r   r   r}   r   r   key_data_typevalue_data_type)r4   r7   r}   s      r9   r   z'PythonClientBackend._format_type_in_doc)  s    
 	"!),&--		'')9LN Ni(!((((I4G4GH  )$$$((I4G4GH  # ''((I4K4KL((I4M4MN 
 I&&rA   c                     t        |      rLdj                  t        |j                        t	        |j
                        t        |j                              S t        |      S )Nz{}.{}.{})	r   r=   r   r?   r   union_data_typer   tag_namer   )r4   r7   values      r9   r   z*PythonClientBackend._generate_python_valueC  sO    e$$inn-()>)>?') )
 5>!rA   )F) N)NNNNNNN)__name__
__module____qualname___cmdline_parsercmdline_parserrN   r:   r0   r3   rD   rO   rl   rs   rq   rp   r   r    rA   r9   r#   r#   y   sa    $N!FFn	1!FfT /3$aL MQGKOSSj"?H'4"rA   r#   )+
__future__r   r   r   r   restone.backendr   stone.backends.helpersr   stone.backends.python_helpersr	   r
   r   r   r   r   r   stone.backends.python_typesr   stone.irr   r   r   r   r   r   r   r   _MYPYtyping	importlibimport_moduler^   r   r*   compiledoc_sub_tag_rerm   ArgumentParserr   add_argumentr#   r   rA   r9   <module>r      s   R R 	 % 2  	 	 	 	 "9""3z?3 =>#  ))	 	 *    	     		M     		A     "		E     		3	     	J  
Q"+ Q"rA   