3
=Ad]
  ã               @   s6   d Z ddlZddlmZ ejeƒZG dd„ deƒZdS )z' A trait type used to access services. é    N)Ú	TraitTypec                   s:   e Zd ZdZd‡ fdd„	Zdd„ Zdd	„ Zd
d„ Z‡  ZS )ÚServicez­ A trait type used to access services.

    Note that this is a trait *type* and hence does *NOT* have traits itself
    (i.e. it does *not* inherit from 'HasTraits').

    NÚ c                s.   t t| ƒjf |Ž || _|| _|| _|| _dS )z Constructor. N)Úsuperr   Ú__init__Ú	_protocolÚ_queryÚ	_minimizeÚ	_maximize)ÚselfÚprotocolÚqueryZminimizeZmaximizeÚmetadata)Ú	__class__© úl/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/envisage-4.7.2-py3.6.egg/envisage/service.pyr      s    zService.__init__c             C   s&   | j |ƒ}|j| j| j| j| jƒ}|S )z Trait type getter. )Ú_get_service_registryZget_servicer   r   r	   r
   )r   ÚobjZ
trait_nameÚservice_registryr   r   r   Úget4   s    
zService.getc             C   s   t dƒ‚dS )z Trait type setter. zService traits cannot be setN)ÚSystemError)r   r   ÚnameÚvaluer   r   r   Úset@   s    zService.setc             C   s*   t |ddƒ}|dkr&td|| jf ƒ‚|S )z6 Return the service registry in effect for an object. r   Nz§The "Service" trait type can only be used within objects that have a reference to a service registry via their "service_registry" trait. 
Object %s
Service protocol %s)ÚgetattrÚ
ValueErrorr   )r   r   r   r   r   r   r   I   s    zService._get_service_registry)Nr   r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ú__classcell__r   r   )r   r   r      s
   	r   )r   ÚloggingZ
traits.apir   Ú	getLoggerr   Úloggerr   r   r   r   r   Ú<module>   s   
