a F `'@sddlmZmZddlmZddlmZddlmZddl m Z gdZ ddZ d d Z d d ZGd ddedZGdddeZGdddeZdS))ABCMetaabstractmethod)Lock)ClientObjectHandler) PropertyProxy)DBusSpecificationError)AbstractObjectProxy ObjectProxyInterfaceProxyget_object_pathdisconnect_proxycCs(t|tstdt|jt|dS)zoGet an object handler of the DBus proxy. :param proxy: a DBus proxy :return: a DBus proxy handler zInvalid type '{}'._handler) isinstancer TypeErrorformattype__name__getattr)proxyr7/usr/lib/python3.9/site-packages/dasbus/client/proxy.pyget_object_handler%s rcCst|}|jS)zkGet an object path of the remote DBus object. :param proxy: a DBus proxy :return: a DBus path )r object_pathrZhandlerrrrr 1sr cCst|}|dS)zVDisconnect the DBus proxy from the remote object. :param proxy: a DBus proxy N)rZdisconnect_membersrrrrr ;sr cs`eZdZdZgdZheZefddZeddZ ddZ d d Z d d Z fd dZ ZS)rz'Abstract proxy of a remote DBus object.)r _members_lock __weakref__cKs*||||fi||_t|_t|_dS)aKCreate a new proxy. :param message_bus: a message bus :param service_name: a DBus name of the service :param object_path: a DBus path the object :param handler_factory: a factory of a DBus client object handler :param handler_arguments: additional arguments for the handler factory N)r dictrrr)self message_bus service_namerZhandler_factoryZhandler_argumentsrrr__init__Qs zAbstractObjectProxy.__init__cCsdS)z|Get the DBus interface of the member. :param member_name: a member name :return: an interface name Nrr member_namerrr_get_interfacedsz"AbstractObjectProxy._get_interfacecGs*z |j|WStyYn0|j|S)aFind a member of the DBus object. If the member doesn't exist, we will acquire a lock and ask a handler to create it. This method is thread-safe. :param key: a member key :return: a member :raise: AttributeError if invalid )rKeyError_create_member)rkeyrrr _get_memberms   zAbstractObjectProxy._get_memberc Gs|jz|j|WWdSty4Yn0z|jj|}Wn2tyx}ztt|dWYd}~n d}~00||j|<|WdS1s0YdS)a Create a member of the DBus object. If the member doesn't exist, ask a handler to create it. This method is thread-safe. :param key: a member key :return: a member :raise: DBusSpecificationError if invalid N)rrr%r Z create_memberrAttributeErrorstr)rr'membererrrr&s  $ z"AbstractObjectProxy._create_membercCs(||||}t|tr$|S|S)zGet the attribute. Called when an attribute lookup has not found the attribute in the usual places. Always call the DBus handler in this case. )r(r$rrget)rnamer+rrr __getattr__s zAbstractObjectProxy.__getattr__csP||jvrt||S||||}t|tr>||Std |dS)zSet the attribute. Called when an attribute assignment is attempted. Call the DBus handler if the name is not a name of an instance attribute defined in _locals. zCan't set DBus attribute '{}'.N) _localssuper __setattr__r(r$rrsetr)r)rr.valuer+ __class__rrr2s   zAbstractObjectProxy.__setattr__)r __module__ __qualname____doc__ __slots__r0rr!rr$r(r&r/r2 __classcell__rrr5rrDs  r) metaclasscs<eZdZdZdgZhejeZfddZddZZ S)r zProxy of a remote DBus object._interface_namescstj|i|d|_dS)zRCreate a new proxy. :param handler: a DBus client object handler N)r1r!r=)rargskwargsr5rrr!szObjectProxy.__init__cCsZ|jdur(t|jjj}dd|D|_z |j|WStyFYn0td|dS)zkGet the DBus interface of the member. The members of standard interfaces have a priority. NcSsi|]}|j|jqSr)r.interface_name).0mrrr sz.ObjectProxy._get_interface..z"DBus object has no attribute '{}'.)r=reversedr Z specificationmembersr%r)r)rr#rErrrr$s   zObjectProxy._get_interface rr7r8r9r:rr0r!r$r;rrr5rr s  r cs<eZdZdZdgZhejeZfddZddZZ S)r z!Proxy of a remote DBus interface._interface_namecs(tj|||g|Ri|||_dS)zCreate a new proxy. :param message_bus: a message bus :param service_name: a DBus name of the service :param object_path: a DBus path the object :param handler: a DBus client object handler N)r1r!rG)rrr rr@r>r?r5rrr!s zInterfaceProxy.__init__cCs|jS)z%Get the DBus interface of the member.)rGr"rrrr$szInterfaceProxy._get_interfacerFrrr5rr s  r N)abcrr threadingrZdasbus.client.handlerrZdasbus.client.propertyrZdasbus.specificationr__all__rr r rr r rrrrs        x(