Python3: plugin code still has references to removed itertools.izip
itertools.izip
was removed in Python3. References to it remain in the code:
blissadm@lid02eiger2lima:~/Git/Lima/applications/tango/python$ git grep izip
plugins/Bpm.py: return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
plugins/Memcached.py:# return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
plugins/PeakFinder.py: return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
plugins/Roi2Spectrum.py: return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
The suggested solution is to apply the patch in d9a29084:
diff --git a/plugins/RoiCounter.py b/plugins/RoiCounter.py
index 4c0eb12..ad06573 100644
--- a/plugins/RoiCounter.py
+++ b/plugins/RoiCounter.py
@@ -30,7 +30,7 @@ from Lima import Core
from Lima.Server.plugins.Utils import getDataFromFile,BasePostProcess
def grouper(n, iterable, padvalue=None):
- return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
+ return zip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
RoiCounterTask = Core.Processlib.Tasks.RoiCounterTask
Another alternative, which allows still using itertools.izip
in Python2 (probably not worth), was applied in Lima-camera-simulator@c6fa7a57:
diff --git a/tango/Simulator.py b/tango/Simulator.py
index 0a08528..8220d57 100644
--- a/tango/Simulator.py
+++ b/tango/Simulator.py
@@ -26,13 +26,19 @@
import itertools
import PyTango
+# python3 compat
+try:
+ from itertools import izip as zip
+except ImportError:
+ pass
+
from Lima.Server import AttrHelper
from Lima import Core
from Lima import Simulator as SimuMod
def grouper(n, iterable, padvalue=None):
- return itertools.izip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
+ return zip(*[itertools.chain(iterable, itertools.repeat(padvalue, n-1))]*n)
class Simulator(PyTango.Device_4Impl):
In any case, the solution should be uniform inside the repository, that is, for the following files:
blissadm@lid02eiger2lima:~/Git/Lima/applications/tango/python$ git grep 'def grouper'
plugins/Bpm.py:def grouper(n, iterable, padvalue=None):
plugins/Memcached.py:# def grouper(n, iterable, padvalue=None):
plugins/PeakFinder.py:def grouper(n, iterable, padvalue=None):
plugins/Roi2Spectrum.py:def grouper(n, iterable, padvalue=None):
plugins/RoiCounter.py:def grouper(n, iterable, padvalue=None):