[pytango] 109/122: Remove metaclasses in examples

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


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

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

commit 1890f6c34d71cbbdcc23bb94eee59315152c8d8f
Author: Vincent Michel <vincent.michel at maxlab.lu.se>
Date:   Mon Jan 16 18:11:42 2017 +0100

    Remove metaclasses in examples
---
 examples/Clock/Clock.py                 |  8 ++------
 examples/Clock/ClockDS.py               | 18 ++----------------
 examples/TuringMachine/TuringMachine.py | 19 ++++++++++---------
 3 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/examples/Clock/Clock.py b/examples/Clock/Clock.py
index faa24a6..fea1bdc 100644
--- a/examples/Clock/Clock.py
+++ b/examples/Clock/Clock.py
@@ -1,15 +1,11 @@
 import time
-from PyTango.server import run
-from PyTango.server import Device, DeviceMeta
-from PyTango.server import attribute, command   
+from PyTango.server import Device, attribute, command
 
 
 class Clock(Device):
-    __metaclass__ = DeviceMeta
 
     @attribute
     def time(self):
-	"""The time attribute"""
         return time.time()
 
     @command(dtype_in=str, dtype_out=str)
@@ -18,4 +14,4 @@ class Clock(Device):
 
 
 if __name__ == "__main__":
-    run([Clock])
+    Clock.run_server()
diff --git a/examples/Clock/ClockDS.py b/examples/Clock/ClockDS.py
index 24ad822..5e1ecde 100644
--- a/examples/Clock/ClockDS.py
+++ b/examples/Clock/ClockDS.py
@@ -1,14 +1,4 @@
 #!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------------
-# This file is part of PyTango (http://pytango.rtfd.io)
-#
-# Copyright 2013-2015 European Synchrotron Radiation Facility, Grenoble, France
-#
-# Distributed under the terms of the GNU Lesser General Public License,
-# either version 3 of the License, or (at your option) any later version.
-# See LICENSE.txt for more info.
-# ------------------------------------------------------------------------------
 
 """
 Clock Device server showing how to write a TANGO server with a Clock device
@@ -24,14 +14,10 @@ commands:
 """
 
 import time
-
-from PyTango.server import Device, DeviceMeta
-from PyTango.server import attribute, command
-from PyTango.server import run
+from PyTango.server import Device, attribute, command
 
 
 class Clock(Device):
-    __metaclass__ = DeviceMeta
 
     @attribute(dtype=float)
     def time(self):
@@ -57,4 +43,4 @@ class Clock(Device):
 
 
 if __name__ == "__main__":
-    run([Clock,])
+    Clock.run_server()
diff --git a/examples/TuringMachine/TuringMachine.py b/examples/TuringMachine/TuringMachine.py
index 994c72b..958291d 100644
--- a/examples/TuringMachine/TuringMachine.py
+++ b/examples/TuringMachine/TuringMachine.py
@@ -1,14 +1,14 @@
 import json
 from PyTango import DevState
-from PyTango.server import Device, DeviceMeta, run
+from PyTango.server import Device
 from PyTango.server import attribute, command, device_property
 
+
 class TuringMachine(Device):
-    __metaclass__ = DeviceMeta
 
     blank_symbol = device_property(dtype=str, default_value=" ")
     initial_state = device_property(dtype=str, default_value="init")
-    
+
     def init_device(self):
         Device.init_device(self)
         self.__tape = {}
@@ -35,8 +35,8 @@ class TuringMachine(Device):
         self.__transition_function = tf = {}
         for k, v in json.loads(func_str).items():
             tf[tuple(str(k).split(","))] = map(str, v)
-        print tf
-        
+        print(tf)
+
     @attribute(dtype=str)
     def tape(self):
         s, keys = "", self.__tape.keys()
@@ -57,13 +57,14 @@ class TuringMachine(Device):
             elif y[2] == "L":
                 self.__head -= 1
             self.__state = y[0]
-        print self.__state
+        print(self.__state)
 
     def dev_state(self):
         if self.__state in self.__final_states:
             return DevState.ON
         else:
             return DevState.RUNNING
-            
-    
-run([TuringMachine])
+
+
+if __name__ == "__main__":
+    TuringMachine.run_server()

-- 
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