Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/cpython/src/__pycache__/zython_importer.cpython-311.pyc
1068 views
�

.`6c���ddlZddlZddlZddlZGd�dejj��ZGd�dejj��Z	Gd�d��Z
Gd�d	��Zed
krke
��Z
e
�de����e
���ddlmcmZejd��Ze���dSdS)
�Nc�"�eZdZd�Zdd�Zd�ZdS)�DependencyInjectorFinderc��||_dS�N)�_loader)�self�loaders  ��/Users/wstein/build/cocalc/src/data/projects/2c9318d1-4f8b-4910-8da7-68a965514c95/zython/packages/cpython/src/zython_importer.py�__init__z!DependencyInjectorFinder.__init__
s
�������Nc�d�|j�|��r|�|��SdS)z�Attempt to locate the requested module
        fullname is the fully-qualified name of the module,
        path is set to __path__ for sub-modules/packages, or None otherwise.
        target can be a module object, but is unused in this example.
        N)r�provides�	_gen_spec)r�fullname�path�targets    r
�	find_specz"DependencyInjectorFinder.find_specs8���<� � ��*�*�	,��>�>�(�+�+�+�	,�	,rc�P�tj�||j��}|Sr)�	importlib�	machinery�
ModuleSpecr)rr�specs   r
rz"DependencyInjectorFinder._gen_specs!���"�-�-�h���E�E���rr)�__name__�
__module__�__qualname__rrr�rr
rr	sF���������,�,�,�,�����rrc�6�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�DependencyInjectorLoaderzmyapp.virtual.c�x�i|_tj|jdd���|_g|j_dS)N�����)�	_services�types�
ModuleType�_COMMON_PREFIX�
_dummy_module�__path__�rs r
rz!DependencyInjectorLoader.__init__s=�����#�-�d�.A�#�2�#�.F�G�G���')���#�#�#rc��||j|<dS)z�Register a service as provided via the given module
        A service is any Python object in this context - an imported module,
        a class, etc.N)r!�r�service_name�modules   r
�providez DependencyInjectorLoader.provide%s��(.���|�$�$�$rc�r�|�|��|jvrdS|j�|��S)NT)�_truncate_namer!r$�
startswith�rrs  r
rz!DependencyInjectorLoader.provides*s=�����x�(�(�D�N�:�	<��4�
�&�1�1�(�;�;�;rc�t�|�|j��}||jvr|jS|j|}|S)z�Create the given module from the supplied module spec
        Under the hood, this module returns a service or a dummy module,
        depending on whether Python is still importing one of the names listed
        in _COMMON_PREFIX.
        )r.�namer!r%)rrr*r+s    r
�
create_modulez&DependencyInjectorLoader.create_module2sD���*�*�4�9�5�5���t�~�-�	&��%�%����-���
rc��dS)z�Execute the given module in its own namespace
        This method is required to be present by importlib.abc.Loader,
        but since we know our module object is already fully-formed,
        this method merely no-ops.
        Nr)rr+s  r
�exec_modulez$DependencyInjectorLoader.exec_module@s	��	
�rc�:�|t|j��d�S)zStrip off _COMMON_PREFIX from the given module name
        Convenience method when checking if a service is provided.
        N)�lenr$r0s  r
r.z'DependencyInjectorLoader._truncate_nameGs ����D�/�0�0�1�1�2�2rN)
rrrr$rr,rr3r5r.rrr
rrss������%�N�	)�	)�	)�.�.�.�
<�<�<�
�
�
�
�
�
�3�3�3�3�3rrc�$�eZdZdZd�Zd�Zd�ZdS)�DependencyInjectorzX
    Convenience wrapper for DependencyInjectorLoader and DependencyInjectorFinder.
    c�^�t��|_t|j��|_dSr)rrr�_finderr's r
rzDependencyInjector.__init__Rs$��/�1�1���/���=�=����rc�N�tj�|j��dSr)�sys�	meta_path�appendr;r's r
�installzDependencyInjector.installUs ���
���T�\�*�*�*�*�*rc�<�|j�||��dSr)rr,r)s   r
r,zDependencyInjector.provideWs ������\�6�2�2�2�2�2rN)rrr�__doc__rr@r,rrr
r9r9NsK��������>�>�>�+�+�+�3�3�3�3�3rr9c�(�eZdZGd�d��ZdS)�FrontendModulec��eZdZd�Zd�ZdS)�FrontendModule.Popupc��||_dSr)�_message)r�messages  r
rzFrontendModule.Popup.__init__]s
��#�D�M�M�Mrc�0�td|j��dS)NzPopup:)�printrHr's r
�displayzFrontendModule.Popup.display_s���(�D�M�*�*�*�*�*rN)rrrrrLrrr
�PopuprF\s2������	$�	$�	$�	+�	+�	+�	+�	+rrMN)rrrrMrrr
rDrD[s<������+�+�+�+�+�+�+�+�+�+rrD�__main__�frontendzHello World!)�
importlib.abcr�importlib.machineryr=r"�abc�MetaPathFinderr�Loaderrr9rDr�injectorr,r@�myapp.virtual.frontend�virtualrOrM�popuprLrrr
�<module>rYsx����������
�
�
�
�����
�
�
�
�
�y�}�;�
�
�
� 23�23�23�23�23�y�}�3�23�23�23�j
3�
3�
3�
3�
3�
3�
3�
3�+�+�+�+�+�+�+�+��z��
�!�!�#�#�H�
���Z���!1�!1�2�2�2�������.�-�-�-�-�-�-�-�-��H�N�>�*�*�E�	�M�M�O�O�O�O�O�
�
r