File: //usr/lib/python3.9/site-packages/dasbus/server/__pycache__/container.cpython-39.pyc
a
װ_ � @ sT d dl mZ d dlmZ d dlmZmZ ddgZG dd� de�Z G dd� de
�ZdS ) � )�
get_dbus_path)�Publishable)�ObjPath�List�DBusContainerError�
DBusContainerc @ s e Zd ZdZdS )r z,General exception for DBus container errors.N)�__name__�
__module__�__qualname__�__doc__� r r �;/usr/lib/python3.9/site-packages/dasbus/server/container.pyr s c @ s� e Zd ZdZddd�Zdd� Zed�dd �Zed
�dd�Ze e d
�dd�Z
e e d
�dd�Zdd� Ze
d�dd�Zdd� Zdd� Zdd� ZdS )r a� The container of DBus objects.
A DBus container should be used to dynamically publish Publishable
objects within the same namespace. It generates a unique DBus path
for each object. It is able to resolve a DBus path into an object
and an object into a DBus path.
Example:
.. code-block:: python
# Create a container of tasks.
container = DBusContainer(
namespace=("my", "project"),
basename="Task",
message_bus=DBus
)
# Publish a task.
path = container.to_object_path(MyTask())
# Resolve an object path into a task.
task = container.from_object_path(path)
Nc C sH || _ |rg |�|�R }|dd� | _|d | _i | _t� | _d| _dS )z�Create a new container.
:param message_bus: a message bus
:param namespace: a sequence of names
:param basename: a string with the base name
N���r )�_message_bus�
_namespace� _basename�
_container�set�
_published�_counter)�selfZmessage_bus� namespace�basenamer r r
�__init__? s
zDBusContainer.__init__c C s
|| _ dS )z�Set the namespace.
All DBus objects from the container should use the same
namespace, so the namespace should be set up before any
of the DBus objects are published.
:param namespace: a sequence of names
N)r )r r r r r
�
set_namespaceR s zDBusContainer.set_namespace)�object_pathc C s
| � |�S )z�Convert a DBus path to a published object.
If no published object is found for the given DBus path,
raise DBusContainerError.
:param object_path: a DBus path
:return: a published object
)�_find_object�r r r r r
�from_object_path] s zDBusContainer.from_object_path)�returnc C s<