Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/logilab/common/__pycache__/corbautils.cpython-37.pyc

B

�d{TM�@s`dZdZddlmZmZddlZdadd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)z<A set of utility function to ease the use of OmniORBpy.




zrestructuredtext en�)�CORBA�PortableServerNcCs$tdkr ddl}t�|jtj�atS)z�
    returns a reference to the ORB.
    The first call to the method initialized the ORB
    This method is mainly used internally in the module.
    Nr)�orb�sysrZORB_init�argvZORB_ID)r�r�J/opt/alt/python37/lib/python3.7/site-packages/logilab/common/corbautils.py�get_orbsr	cCs0t�}|�d�}|�tj�}|dk	s,td��|S)zq
    returns a reference to the NameService object.
    This method is mainly used internally in the module.
    ZNameServiceNz$Failed to narrow root naming context)r	�resolve_initial_references�_narrow�	CosNaming�
NamingContext�AssertionError)rZnssZrootContextrrr�get_root_context,s

rcCs�t�}x~|dd�D]n\}}t�||�g}y|�|�}Wqtjjk
r�}z&|�|��tj�}|dk	sptd��Wdd}~XYqXqW|d\}}t�||�g}y|�	||�
��Wn6tjjk
r�}z|�||�
��Wdd}~XYnXdS)a
    Registers a object in the NamingService.
    The name path is a list of 2-uples (id,kind) giving the path.

    For instance if the path of an object is [('foo',''),('bar','')],
    it is possible to get a reference to the object using the URL
    'corbaname::hostname#foo/bar'.
    [('logilab','rootmodule'),('chatbot','application'),('chatter','server')]
    is mapped to
    'corbaname::hostname#logilab.rootmodule/chatbot.application/chatter.server'

    The get_object_reference() function can be used to resolve such a URL.
    N���z.test context exists but is not a NamingContext)rrZ
NameComponentZbind_new_contextr
ZAlreadyBound�resolverr�bindZ_thisZrebind)�object�namepath�context�id�kind�name�exrrr�register_object_name8s
rcCs$t�}|�d�}|��}|��dS)z�
    This methods activates the Portable Object Adapter.
    You need to call it to enable the reception of messages in your code,
    on both the client and the server.
    ZRootPOAN)r	r
Z_get_the_POAManager�activate)rZpoaZ
poaManagerrrr�activate_POAWs
rcCst���dS)zc
    Enters the ORB mainloop on the server.
    You should not call this method on the client.
    N)r	�runrrrr�run_orbbsrcCst��|�S)zg
    Resolves a corbaname URL to an object proxy.
    See register_object_name() for examples URLs
    )r	Zstring_to_object)�urlrrr�get_object_referenceisr cCs d�dd�|D��}d||fS)zrgiven an host name and a name path as described in register_object_name,
    return a corba string identifier
    �/cSsg|]}d�|��qS)�.)�join)�.0Zpath_eltrrr�
<listcomp>tsz%get_object_string.<locals>.<listcomp>zcorbaname::%s#%s)r#)�hostrZstrnamerrr�get_object_stringpsr')�__doc__�
__docformat__ZomniORBrrrrr	rrrrr r'rrrr�<module>s