Your IP : 216.73.216.213
B
�d{T�� � @ s> d Z ddlmZ dZddlZddlZddlZddlZddl m
Z
mZ ddlm
Z
mZmZ ddlmZ ddlmZ dd lmZmZ dd
lmZ ddlmZ ddlmZ G d
d� de�ZG dd� de�ZG dd� de�Z G dd� de�Z!dDdd�Z"dEdd�Z#G dd� de$�Z%G dd� de%�Z&G dd� de'�Z(dFdd �Z)G d!d"� d"e'�Z*ee*ed#�� ee(ed$�� da+d%d&� Z,d'd(� Z-G d)d*� d*e$�Z.d+d,� Z/i Z0d-d.� Z1G d/d0� d0e2�Z3ee3�G d1d2� d2e$��Z4G d3d4� d4e4�Z5G d5d6� d6e5�Z6G d7d8� d8e5�Z7G d9d:� d:e4�Z8G d;d<� d<e4�Z9dd=l:m;Z; e;d>�d?d@� �Z<e;dA�dBdC� �Z=dS )Ga: This module provides bases for predicates dispatching (the pattern in use
here is similar to what's refered as multi-dispatch or predicate-dispatch in the
literature, though a bit different since the idea is to select across different
implementation 'e.g. classes), not to dispatch a message to a function or
method. It contains the following classes:
* :class:`RegistryStore`, the top level object which loads implementation
objects and stores them into registries. You'll usually use it to access
registries and their contained objects;
* :class:`Registry`, the base class which contains objects semantically grouped
(for instance, sharing a same API, hence the 'implementation' name). You'll
use it to select the proper implementation according to a context. Notice you
may use registries on their own without using the store.
.. Note::
implementation objects are usually designed to be accessed through the
registry and not by direct instantiation, besides to use it as base classe.
The selection procedure is delegated to a selector, which is responsible for
scoring the object according to some context. At the end of the selection, if an
implementation has been found, an instance of this class is returned. A selector
is built from one or more predicates combined together using AND, OR, NOT
operators (actually `&`, `|` and `~`). You'll thus find some base classes to
build predicates:
* :class:`Predicate`, the abstract base predicate class
* :class:`AndPredicate`, :class:`OrPredicate`, :class:`NotPredicate`, which you
shouldn't have to use directly. You'll use `&`, `|` and '~' operators between
predicates directly
* :func:`objectify_predicate`
You'll eventually find one concrete predicate: :class:`yes`
.. autoclass:: RegistryStore
.. autoclass:: Registry
Predicates
----------
.. autoclass:: Predicate
.. autofunc:: objectify_predicate
.. autoclass:: yes
Debugging
---------
.. autoclass:: traced_selection
Exceptions
----------
.. autoclass:: RegistryException
.. autoclass:: RegistryNotFound
.. autoclass:: ObjectNotFound
.. autoclass:: NoSelectableObject
� )�print_functionzrestructuredtext enN)�listdir�stat)�join�isdir�exists)� getLogger)�warn)�string_types�
add_metaclass)�modpath_from_file)�set_log_methods)�
classpropertyc @ s e Zd ZdZdS )�RegistryExceptionz"Base class for registry exception.N)�__name__�
__module__�__qualname__�__doc__� r r �H/opt/alt/python37/lib/python3.7/site-packages/logilab/common/registry.pyr ` s r c @ s e Zd ZdZdS )�RegistryNotFoundzaRaised when an unknown registry is requested.
This is usually a programming/typo error.
N)r r r r r r r r r c s r c @ s e Zd ZdZdS )�ObjectNotFoundzvRaised when an unregistered object is requested.
This may be a programming/typo or a misconfiguration error.
N)r r r r r r r r r i s r c @ s e Zd ZdZdd� Zdd� ZdS )�NoSelectableObjectz8Raised when no object is selectable for a given context.c C s || _ || _|| _d S )N)�args�kwargs�objects)�selfr r r r r r �__init__q s zNoSelectableObject.__init__c C s d| j | j�� | jf S )Nz#args: %s, kwargs: %s
candidates: %s)r r �keysr )r r r r �__str__v s zNoSelectableObject.__str__N)r r r r r r r r r r r o s r c C s( t | |�}|d dkr|�� d�|�S )N���r �.)r �popr )�path� extrapathZmodpathr r r �_modname_from_path{ s
r% c s� |dkrt | t�st�i g f}x~| D ]v� t� �rbtt� d��rb� fdd�t� �D �}t|||� q$� dd� dkr$t� |�}� |d |<