a
    <g@  ã                   @   sv   d dl Z d dlZd dlmZ d dlZejdkr<d dlmZ nd dlZe	e	e	dœdd„Z
dd	d
„ZG dd„ dejƒZdS )é    N)Úprotoc©é   é	   r   )Ú	resources)Úpackage_or_requirementÚresource_nameÚreturnc                 C   s6   d}t jdkr"t | ¡|  ¡ }nt | |¡}t|ƒS )z6Obtain the filename for a resource on the file system.Nr   )ÚsysÚversion_infor   ÚfilesÚresolveÚpkg_resourcesÚresource_filenameÚstr)r   r   Ú	file_name© r   úa/var/www/html/micrositios/openai-assistant/venv/lib/python3.9/site-packages/grpc_tools/command.pyÚ_get_resource_file_name   s    
ÿÿr   Fc              
   C   sÖ   g }t j | ¡}t  |¡D ]:\}}}|D ]*}| d¡r(| t j t j ||¡¡¡ q(qtddƒ}|D ]l}	dd |¡d |¡d |¡d |¡d |¡g|	g }
t	 
|
¡d	krd|r¾td
 |
¡ƒ‚qdtj d |
¡¡ qdd S )Nz.protoÚ
grpc_toolsZ_protozgrpc_tools.protocz--proto_path={}z--python_out={}z--pyi_out={}z--grpc_python_out={}r   zerror: {} failedzwarning: {} failed)ÚosÚpathÚabspathÚwalkÚendswithÚappendÚjoinr   Úformatr   ÚmainÚ	Exceptionr
   ÚstderrÚwrite)Zpackage_rootÚstrict_modeZproto_filesZinclusion_rootÚrootÚ_r   ÚfilenameZwell_known_protos_includeZ
proto_fileÚcommandr   r   r   Úbuild_package_protos+   s.    
ÿ
úùr'   c                   @   s2   e Zd ZdZdZdgZdd„ Zdd„ Zdd	„ Zd
S )ÚBuildPackageProtosz>Command to generate project *_pb2.py modules from proto files.zbuild grpc protobuf modules)zstrict-modeÚsz6exit with non-zero value if the proto compiling fails.c                 C   s
   d| _ d S )NF)r"   ©Úselfr   r   r   Úinitialize_optionsS   s    z%BuildPackageProtos.initialize_optionsc                 C   s   d S )Nr   r*   r   r   r   Úfinalize_optionsV   s    z#BuildPackageProtos.finalize_optionsc                 C   s   t | jjd | jƒ d S )NÚ )r'   ÚdistributionÚpackage_dirr"   r*   r   r   r   ÚrunY   s    ÿzBuildPackageProtos.runN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdescriptionÚuser_optionsr,   r-   r1   r   r   r   r   r(   G   s   ÿr(   )F)r   r
   r   r   Ú
setuptoolsr   Ú	importlibr   r   r   r   r'   ÚCommandr(   r   r   r   r   Ú<module>   s   
þ
