
    Mh--                        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 d	d
lmZ d	dl mZ d	dlmZmZ  ej0                  d      Z e j4                  e      Z	 d dlZ	 d dlmZ  ejC                  e        de"ddfdZ#ejI                         d ejJ                  dd      fdeee"df    ejJ                  dde#      f   de"ddfd       Z$dee   defdZ&	 d:ddd dd!ddd"d#eedf   d$e'd%e(d&e"d'ee(df   d(e'd)e'd*ee'df   d+e"ddfd,Z)ejU                         	 d:ddd d!dd d-d#eeedf    ejV                  d.      f   d$ee' ejJ                  d/      f   d%ee( ejJ                  d0      f   d&ee" ejJ                  d1      f   d(ee' ejJ                  d2      f   d*eee'df    ejJ                  d3      f   d+ee" ejJ                  d4      f   defd5       Z,ejU                         	 d:d6dddd!dd d"d#eeedf    ejV                  d.      f   d$ee' ejJ                  d/      f   d%ee( ejJ                  d0      f   d&ee" ejJ                  d1      f   d'eee(df    ejJ                  d7      f   d(ee' ejJ                  d2      f   d*eee'df    ejJ                  d3      f   d+ee" ejJ                  d4      f   defd8       Z-d;d9Z.y# e$ r dZY w xY w# e$ r Y ww xY w)<    N)Path)AnyListUnion)print)Tree)	Annotated)get_import_data)FastAPICLIException   )__version__)setup_logging)get_rich_toolkitget_uvicorn_log_configrich)rich_markup_mode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    g/var/www/pru.catia.catastroantioquia-mas.com/valormasv2/lib/python3.12/site-packages/fastapi_cli/cli.pyversion_callbackr   &   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   ,   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_treer2   C   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workers	root_pathr   proxy_headerspathr4   r5   r6   r7   r8   commandr   r9   c                   t               5 }	|dk(  rdnd}
|	j                  d|
 dd       |	j                          |	j                  d       	 t	        | |	      }t        j                  d|j                  j                          t        j                  d|j                  j                          |j                  }|j                  }|	j                  d|j                          |	j                          t        |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        t"        st        d!      d |	j                          |	j                  d"       |	j                          t#        j$                  |||||||t'               #       d d d        y # t
        $ r@}|	j                          |	j                  d
|        t        j                  d      d d }~ww xY 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] files)r:   app_namez[error]r   )codezImporting from zImporting module modulezIImporting the FastAPI app object from the module with the following code:rC   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   r4   r5   r6   r7   r8   r9   
log_config)r   print_title
print_liner   r
   r   r   r   loggerdebugmodule_dataextra_sys_pathmodule_import_strimport_stringr2   r'   rB   uvicornrunr   )r:   r4   r5   r6   r7   r8   r;   r   r9   toolkitserver_typeimport_dataerN   rQ   r.   urlurl_docss                     r   _runrZ   X   s    
	 Q
w'.%'7m\i}LAyQg	
	/)tcBK 	{'>'>'M'M&NOP()@)@)R)R(STU!--#11(B(B'CDE$[%=%=>	iX.W 	 	
 	$[%B%B$CCXYdYmYmXnnuv	
 	)-< 	 	

 vQtf%U%=&se1SE5%hZq
#> 	 	
 e MMW  
 %M 	g'-/		
QQ
 Q
 # 	/ MMGA3-(**!$$.	/Q
 Q
s1   AKI?HK?	K;KKKK)r4   r5   r6   r8   r   r9   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.zEnable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.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.zdEnable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.c          
      *    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.
    r=   )r:   r4   r5   r6   r8   r   r;   r9   NrZ   )r:   r4   r5   r6   r8   r   r9   s          r   r=   r=      s%    N 	#	r   z0.0.0.0zIUse multiple worker processes. Mutually exclusive with the --reload flag.c                ,    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.
    rS   )	r:   r4   r5   r6   r7   r8   r   r;   r9   Nr\   )r:   r4   r5   r6   r7   r8   r   r9   s           r   rS   rS     s(    Z 	#
r   c                      t                y Nr    r   r   mainra   e  s    Er   r_   )r   N)/r#   pathlibr   typingr   r   r   r   r   r   	rich.treer   typing_extensionsr	   fastapi_cli.discoverr
   fastapi_cli.exceptionsr   r3   r   r   	utils.clir   r   Typerr   	getLogger__name__rL   rR   ImportErrorfastapi_cloud_cli.clifastapi_cloud_cli	add_typerboolr   r   Optionr2   strintrZ   r;   Argumentr=   rS   ra   r`   r   r   <module>ru      s\     # #    ' 0 6  " ?ekk6*			8	$
	 MM#$
D T   	 ELL-DE#dDj:EU	
	# # 
# #,4: $ , #]
  $ ]

d

]
 ]
 	]

 ]
 39]
 ]
 ]
 
sDy	]
 ]
 
]
@  	O 	 	 	 	 	 	WO
dDj D	
	O  T	
	O  d	
	O(  W	
	)O4  w	
	5O@ 
c4i i	
	
AOL w	
	MOX 	YO Od  	V 	 	 	 	 	 	 	cV
dDj D	
	V  T	
	V  d	
	V(  W	
	)V4 c4i\	
	5V@  w	
	AVL 
c4i i	
	
MVX w	
	YVd 	eV Vr
[
  G  		s$   1K. 6K< .K98K9<LL