← Back
Editing: container.cpython-312.pyc
� �ic � �` � d dl mZ d dlmZ d dlmZmZ ddgZ G d� de� Z G d� de � Zy) � )� get_dbus_path)�Publishable)�ObjPath�List�DBusContainerError� DBusContainerc � � e Zd ZdZy)r z,General exception for DBus container errors.N)�__name__� __module__�__qualname__�__doc__� � �</usr/lib/python3.12/site-packages/dasbus/server/container.pyr r s � �6�r c �~ � e Zd ZdZdd�Zd� Zdefd�Zdefd�Zd e e fd �Z de e fd�Zd� Zd e fd�Zd� Zd� Zd� Zy)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 � � || _ |rg |�|��}|dd | _ |d | _ i | _ t � | _ d| _ y)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)�self�message_bus� namespace�basenames r �__init__zDBusContainer.__init__? sM � � (����.�)�.�X�.�I�#�C�R�.���"�2��������%����� r c � � || _ y)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 s r � set_namespacezDBusContainer.set_namespaceR s � � $��r �object_pathc �$ � | j |� 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"