
    bi:                        d dl Z d dlmZ d dl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 d dlmZ d dlmZmZ d d	lmZ d
dlmZ d
dl mZ d
dlmZmZ  ej6                  ddddgi      Z e j:                  e      Z	 d dl Z 	 d dl"mZ# ejI                  e#       	 d dl%mZ& ejI                  e&       de'ddfdZ(ejS                         d ejT                  dd      fdeee'df    ejT                  dde(      f   de'ddfd       Z)d e+e   defd!Z,	 dJd"d#d$ddd%ddddd&
d'eedf   d(e-d)e.d*e'd+ee+e   df   d,ee.df   d-e-d.e-d/ee-df   d0ee-df   d1e'd2ee-df   ddfd3Z/eja                         	 dJd"d#d$dd%ddd$dd4	d'eeedf    ejb                  d5      f   d(ee- ejT                  d6      f   d)ee. ejT                  d7d89      f   d*ee' ejT                  d:      f   d;eee+e   df    ejT                  d<      f   d-ee- ejT                  d=      f   d/eee-df    ejT                  d>      f   d0eee-df    ejT                  d?d@dA      f   d1ee' ejT                  dB      f   d2eee-df    ejT                  dC      f   defdD       Z2eja                         	 dJdEd#ddd%ddd$ddF	d'eeedf    ejb                  d5      f   d(ee- ejT                  d6      f   d)ee. ejT                  d7d89      f   d*ee' ejT                  d:      f   d,eee.df    ejT                  dG      f   d-ee- ejT                  d=      f   d/eee-df    ejT                  d>      f   d0eee-df    ejT                  d?d@dA      f   d1ee' ejT                  dB      f   d2eee-df    ejT                  dC      f   defdH       Z3dKdIZ4y# e!$ r dZ Y Uw xY w# e!$ r Y Iw xY w# e!$ r Y =w xY w)L    N)Path)	AnnotatedAnyUnion)ValidationError)print)Tree)FastAPIConfig)get_import_data"get_import_data_from_import_string)FastAPICLIException   )__version__)setup_logging)get_rich_toolkitget_uvicorn_log_configrichhelp_option_namesz-hz--help)rich_markup_modecontext_settingsappvaluereturnc                 V    | r't        dt         d       t        j                         y )NzFastAPI CLI version: [green]z[/green])r   r   typerExit)r   s    M/opt/aeropuerto/back/api/venv/lib/python3.12/site-packages/fastapi_cli/cli.pyversion_callbackr   3   s(    ,[MBCjjl     FzEnable verbose output)helpversionz	--versionzShow the version and exit.)r!   callbackverbosec                 `    |rt         j                  nt         j                  }t        |       y)u  
    FastAPI CLI - The [bold]fastapi[/bold] command line app. 😎

    Manage your [bold]FastAPI[/bold] projects, run your FastAPI apps, and more.

    Read more in the docs: [link=https://fastapi.tiangolo.com/fastapi-cli/]https://fastapi.tiangolo.com/fastapi-cli/[/link].
    )levelN)loggingDEBUGINFOr   )r"   r$   	log_levels      r   r#   r#   9   s    $ ")gllI	"r    module_pathsc                    | d   }|j                         rd|j                   nd|j                   }t        |      }|j                         r|j	                  d       |}| dd  D ]c  }|j                         rd|j                   nd|j                   }|j	                  |      }|j                         sS|j	                  d       e |S )Nr   u   🐍 u   📁 u   [dim]🐍 __init__.py[/dim]r   )is_filenamer	   is_diradd)r+   rootr.   	root_treetreesub_pathsub_names          r   _get_module_treer6   P   s    ?D"&,,.U499+dii[6IDT
I{{}34D $ 4'/'7'7'9eHMM?#x}}o?V 	 xx!??HH234 r    z	127.0.0.1i@  T )
hostportreloadreload_dirsworkers	root_pathr   
entrypointproxy_headersforwarded_allow_ipspathr8   r9   r:   r;   r<   r=   commandr   r>   r?   r@   c                   t               5 }|dk(  rdnd}|j                  d| dd       |j                          |j                  d       |	rK| s|rG|j                          |j                  d	       |j                          t	        j
                  d
      	 t        j                  |	      }	 | s|rt        | |      }n,|j                  rt        |j                        }n
t               }t        j!                  d|j"                  j$                          t        j!                  d|j"                  j&                          |j"                  }|j(                  }|j                  d|j$                          |j                          |j*                  r8t-        |j*                        }|j                  |d       |j                          |j                  dd       |j                          |j                  d|j&                   d|j.                   d       |j                          |j                  d| dd        d!| d"| }| d#}|j                          |j                  d$| d%| dd&| d%| dd'       |dk(  r#|j                          |j                  d(d)       t0        st        d*      d |j                          |j                  d+       |j                          t1        j2                  |||||r'|D cg c]  }t5        |j                                c}nd |||
|t7               ,
       d d d        y # t        $ r}|j                          |j                  d       |j                          |j                         D ]7  }dj                  d |d   D              }|j                  d| d|d           9 |j                          t	        j
                  d
      d d }~ww xY w# t        $ r@}|j                          |j                  d|        t	        j
                  d
      d d }~ww xY wc c}w # 1 sw Y   y xY w)-Ndevdevelopment
productionz	Starting u    server 🚀FastAPI)tagzYSearching for package file structure from directories with [blue]__init__.py[/blue] fileszD[error]Cannot use --entrypoint together with path or --app argumentsr   )code)r>   z/[error]Invalid configuration in pyproject.toml:.c              3   2   K   | ]  }t        |        y wN)str).0locs     r   	<genexpr>z_run.<locals>.<genexpr>   s      BcS Bs   rO   u     [red]•[/red] z: msg)rA   app_namez[error]zImporting from zImporting module modulezIImporting the FastAPI app object from the module with the following code:rI   z[underline]from [bold]z[/bold] import [bold]z[/bold]zUsing import string: [blue]z[/]r   zhttp://:z/docszServer started at [link=]zDocumentation at [link=serverzERunning in development mode, for production use: [bold]fastapi run[/]tipz;Could not import Uvicorn, try running 'pip install uvicorn'zLogs:)
r   r8   r9   r:   r;   r<   r=   r?   r@   
log_config)r   print_title
print_liner   r   r   r
   resolver   errorsjoinr   r>   r   r   loggerdebugmodule_dataextra_sys_pathmodule_import_strimport_stringr+   r6   rR   uvicornrunrM   r   )rA   r8   r9   r:   r;   r<   r=   rB   r   r>   r?   r@   toolkitserver_typeconfigeerrorfieldimport_datar`   rc   r2   urlurl_docs	directorys                            r   _runrp   e   s=    
	 u
w'.%'7m\i}LAyQg	
 43 MMV  **!$$	/"**jAF	/s-4#F""@ARARS-/ 	{'>'>'M'M&NOP()@)@)R)R(STU!--#11(B(B'CDE##()A)ABIMM)M2 W 	 	
 	$[%B%B$CCXYdYmYmXnnuv	
 	)-< 	 	

 vQtf%U%=&se1SE5%hZq
#> 	 	
 e MMW  
 %M 	g  <GGiY&&()G' 3-/	
Mu
 u
(  	/ MMKL  K BU5\ BB 1%5<.IJK  **!$$.	/* # 	/ MMGA3-(**!$$.	/F HYu
 u
s\   BQM2>O>0HQ Q
+Q	O;B"O66O;;Q>	Q;QQQQ)	r8   r9   r:   
reload_dirr=   r   r>   r?   r@   zA path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried.zThe host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue].zThe port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port [blue]443[/blue] and HTTP on port [blue]80[/blue], transferring the communication to your app.PORT)r!   envvarzEnable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.rq   zRSet reload directories explicitly, instead of using the current working directory.zThe root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar.zThe name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically.z--entrypointz-ezNThe FastAPI app import string in the format 'some.importable_module:app_name'.zdEnable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.ziComma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything.c       	         0    t        | |||||||d||	       y)u  
    Run a [bold]FastAPI[/bold] app in [yellow]development[/yellow] mode. 🧪

    This is equivalent to [bold]fastapi run[/bold] but with [bold]reload[/bold] enabled and listening on the [blue]127.0.0.1[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    rD   )rA   r8   r9   r:   r;   r=   r   r>   rB   r?   r@   Nrp   )
rA   r8   r9   r:   rq   r=   r   r>   r?   r@   s
             r   rD   rD      s.    x 	#/r    z0.0.0.0)	r8   r9   r:   r<   r=   r   r>   r?   r@   zIUse multiple worker processes. Mutually exclusive with the --reload flag.c       	         0    t        | |||||||d||	       y)u  
    Run a [bold]FastAPI[/bold] app in [green]production[/green] mode. 🚀

    This is equivalent to [bold]fastapi dev[/bold] but with [bold]reload[/bold] disabled and listening on the [blue]0.0.0.0[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    re   )rA   r8   r9   r:   r<   r=   r   r>   rB   r?   r@   Nru   )
rA   r8   r9   r:   r<   r=   r   r>   r?   r@   s
             r   re   re   W  s.    x 	#/r    c                      t                y rL   r    r    r   mainry     s    Er    rL   )r   N)5r'   pathlibr   typingr   r   r   r   pydanticr   r   r   	rich.treer	   fastapi_cli.configr
   fastapi_cli.discoverr   r   fastapi_cli.exceptionsr   r7   r   r   	utils.clir   r   Typerr   	getLogger__name__r^   rd   ImportErrorfastapi_cloud_cli.clifastapi_cloud_cli	add_typerfastapi_new.clifastapi_new_cliboolr   r#   Optionlistr6   rM   intrp   rB   ArgumentrD   re   ry   rx   r    r   <module>r      s     ( (  $   , T 6  " ?ekk/BT8DT.U 
		8	$
	 MM#$
	 MM/"
D T   	 ELL-DE#dDj:EU	
	# # 
# #,4: $ , #D
 +/ $ #',0D

d

D
 D
 	D

 D
 tDz4'(D
 39D
 D
 D
 
sDy	D
 c4i D
 D
 sDy)D
 
D
N  	g 	 	 	 	 	 	 	 	 	Ag
dDj D	
	g  T	
	g  d	
	g*  W	
	+g6 d4j$e	
	7gB  w	
	CgN 
c4i i	
	
OgZ c4ia	
	[gj w	
	kgv #c4i|	
	wgB 	Cg gT  	g 	 	 	 	 	 	 	 	 	Ag
dDj D	
	g  T	
	g  d	
	g*  W	
	+g6 c4i\	
	7gB  w	
	CgN 
c4i i	
	
OgZ c4ia	
	[gj w	
	kgv #c4i|	
	wgB 	Cg gT
O  G  		  		s6   >O O O' OOO$#O$'O0/O0