[pytango] 39/98: Implement attribute access as map in tango object

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:17:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to tag v9.2.0
in repository pytango.

commit 657e5bdcc90341f26741fd20d99d9402e1088ae0
Author: Jose Tiago Coutinho Macara <tiago.coutinho at esrf.fr>
Date:   Wed May 25 12:39:50 2016 +0200

    Implement attribute access as map in tango object
---
 src/boost/python/client.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/boost/python/client.py b/src/boost/python/client.py
index b47379c..5ea0fa1 100644
--- a/src/boost/python/client.py
+++ b/src/boost/python/client.py
@@ -169,6 +169,16 @@ class _DeviceHelper(object):
         except PyTango.DevFailed:
             return None
 
+    def __getitem__(self, name):
+        if self.get_attr_info(name) is None:
+            raise KeyError("Unknown attribute %s" % name)
+        return self.device[name]
+
+    def __setitem__(self, name, value):
+        if self.get_attr_info(name) is None:
+            raise KeyError("Unknown attribute %s" % name)
+        self.device[name] = value
+
     def __str__(self):
         return self.dstr()
 
@@ -206,6 +216,12 @@ class Object(object):
         except KeyError as ke:
             six.raise_from(AttributeError('Unknown {0}'.format(name)), ke)
 
+    def __getitem__(self, name):
+        return self._helper[name]
+
+    def __setitem__(self, name, value):
+        self._helper[name] = value
+
     def __str__(self):
         return str(self._helper)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list