Commit deffcbe6 authored by Damien Naudet's avatar Damien Naudet

Fixes for python3.

parent 15d74183
......@@ -256,19 +256,18 @@ class XsocsGui(Qt.QMainWindow):
sender = self.sender()
if not isinstance(sender, FitView):
return
views = self.__fitViews.values()
views = list(self.__fitViews.values())
try:
viewIdx = views.index(sender)
except ValueError:
# TODO
return
fitNode = self.__fitViews.keys()[viewIdx]
fitNode = list(self.__fitViews.keys())[viewIdx]
qspaceNode = fitNode.parent().parent()
qspaceView = self.__showQSpace(qspaceNode, bringToFront=False)
qspaceView.selectPoint(point.x, point.y)
def model(self):
return self.tree.model()
......
......@@ -190,7 +190,7 @@ class FitWidget(Qt.QWidget):
fitLayout = Qt.QHBoxLayout()
self.__fitTypeCb = fitTypeCb = Qt.QComboBox()
fitTypeCb.addItems(FitWidget.FitTypes.keys())
fitTypeCb.addItems(list(FitWidget.FitTypes.keys()))
fitTypeCb.setCurrentIndex(0)
fitLayout.addWidget(Qt.QLabel('Fit :'))
fitLayout.addWidget(fitTypeCb)
......
......@@ -52,7 +52,7 @@ def getNodeClass(nodeType, attrs=None):
for key, value in attrs.items():
info = _registeredAttributes.get(key)
if info:
klass = info.get(value)
klass = info.get(value.decode())
if klass:
break
if not klass:
......@@ -160,7 +160,6 @@ class H5Base(Node):
super(H5Base, self).__init__(subject=self, **kwargs)
self.setData(h5File, Qt.Qt.ToolTipRole)
self.setData(ModelColumns.NameColumn, os.path.basename(self.h5Path))
@staticmethod
......
......@@ -62,7 +62,7 @@ def projectItemFactory(h5File, h5Path, mode=None):
# For some reason attrs.get sometimes fails,
# using "in" seems a bit more robust.
if 'XsocsClass' in attrs:
xsocsClass = attrs['XsocsClass']
xsocsClass = attrs['XsocsClass'].decode()
klass = getItemClass(xsocsClass)
del attrs
......
......@@ -477,7 +477,7 @@ class ImageRoiManager(qt.QObject):
return optionActions
def _selectAll(self, checked):
print self._plot.getGraphXLimits(), self._plot.getGraphYLimits()
pass
def _clearRois(self, checked):
self.clear()
......@@ -507,7 +507,7 @@ class ImageRoiManager(qt.QObject):
# TODO : to raise or not to raise?
pass
rois = property(lambda self: self._rois.keys())
rois = property(lambda self: list(self._rois.keys()))
def showRois(self, show):
# TODO : name param to tell that we only want to toggle
......@@ -522,7 +522,8 @@ class ImageRoiManager(qt.QObject):
if self.sender() != action:
action.setChecked(show)
{roi.setVisible(show) for roi in self._rois.values()}
for roi in self._rois.values():
roi.setVisible(show)
def allowMultipleSelections(self, allow):
......
......@@ -64,7 +64,9 @@ class FitView(Qt.QMainWindow):
item = h5NodeToProjectItem(node)
fitH5 = self.__fitH5 = item.fitH5
qspaceItem = h5NodeToProjectItem(qspaceNode)
self.__qspaceH5 = qspaceItem.qspaceH5
self.__node = node
with fitH5:
# only one entry per file supposed right now
......@@ -165,6 +167,9 @@ class FitView(Qt.QMainWindow):
self.__sigInitPlots.connect(self.__firstInit, Qt.Qt.QueuedConnection)
def getFitNode(self):
return self.__node
def showEvent(self, event):
"""
Overloard method from Qt.QWidget.showEvent to set up the widget the
......
......@@ -59,15 +59,15 @@ class DropPlotWidget(XsocsPlot2D):
return super(DropPlotWidget, self).dropEvent(event)
qByteArray = mimeData.data('application/FitModel')
stream = Qt.QDataStream(qByteArray, Qt.QIODevice.ReadOnly)
h5File = stream.readString()
entry = stream.readString()
h5File = stream.readQString()
entry = stream.readQString()
q_axis = stream.readInt()
type = stream.readString()
type = stream.readQString()
if type == 'result':
process = stream.readString()
result = stream.readString()
process = stream.readQString()
result = stream.readQString()
self.plotFitResult(h5File, entry, process, result, q_axis)
elif type == 'status':
self.plotFitStatus(h5File, entry, q_axis)
......
......@@ -123,8 +123,8 @@ class FitEntryNode(H5Base):
h5file = self.h5File
entry = self.entry
stream.writeString(h5file)
stream.writeString(entry)
stream.writeQString(h5file)
stream.writeQString(entry)
stream.writeInt(q_axis)
return True
......@@ -234,7 +234,7 @@ class FitStatusNode(FitEntryNode):
if not FitEntryNode.mimeData(self, column, stream):
return False
stream.writeString('status')
stream.writeQString('status')
return True
......@@ -294,9 +294,9 @@ class FitResultNode(FitProcessNode):
process = self.process
result = self.result
stream.writeString('result')
stream.writeString(process)
stream.writeString(result)
stream.writeQString('result')
stream.writeQString(process)
stream.writeQString(result)
return True
......
......@@ -491,7 +491,8 @@ class XsocsPlot2D(PlotWindow):
pointDock = self.__pointWidget = DoublePointDock()
features = Qt.QDockWidget.DockWidgetVerticalTitleBar | Qt.QDockWidget.DockWidgetClosable
features = (Qt.QDockWidget.DockWidgetVerticalTitleBar |
Qt.QDockWidget.DockWidgetClosable)
pointDock.setFeatures(features)
pointDock.sizeHint = lambda: Qt.QSize()
self.addDockWidget(Qt.Qt.BottomDockWidgetArea, pointDock)
......
......@@ -94,7 +94,7 @@ class FitH5(XsocsH5Base):
return sorted([key for key in h5_file
if ('NX_class' in h5_file[key].attrs and
h5_file[key].attrs[
'NX_class'] == 'NXentry')])
'NX_class'].decode() == 'NXentry')])
def processes(self, entry):
"""
......@@ -107,7 +107,7 @@ class FitH5(XsocsH5Base):
processes = sorted([key for key in entry_grp
if ('NX_class' in entry_grp[key].attrs and
entry_grp[key].attrs[
'NX_class'] == 'NXprocess')])
'NX_class'].decode() == 'NXprocess')])
return processes
def get_result_names(self, entry, process):
......
......@@ -76,8 +76,9 @@ class XsocsH5(XsocsH5Base):
# when there is no attribute NX_class (should return the default
# None)
self.__entries = sorted([key for key in h5_file
if ('NX_class' in h5_file[key].attrs and
h5_file[key].attrs['NX_class'] == 'NXentry')]) # noqa
if ('NX_class' in h5_file[key].attrs and
h5_file[key].attrs[
'NX_class'].decode() == 'NXentry')])
def entries(self):
if self.__entries is None:
......@@ -158,8 +159,8 @@ class XsocsH5(XsocsH5Base):
def scan_positions(self, entry):
path = self.measurement_tpl.format(entry)
params = self.scan_params(entry)
m0 = '/adc{0}'.format(params['motor_0'][-1].upper())
m1 = '/adc{0}'.format(params['motor_1'][-1].upper())
m0 = '/adc{0}'.format(params['motor_0'].decode()[-1].upper())
m1 = '/adc{0}'.format(params['motor_1'].decode()[-1].upper())
n_0 = params['motor_0_steps']
n_1 = params['motor_1_steps']
......
......@@ -96,7 +96,7 @@ class PeakFitter(Thread):
n_proc)
if roi_indices is not None:
self.__roi_indices = roi_indices[:]
self.__roi_indices = np.array(roi_indices[:])
else:
self.__roi_indices = None
......@@ -119,7 +119,7 @@ class PeakFitter(Thread):
self.__set_status(self.ERROR)
raise
self.__indices = indices
self.__indices = np.array(indices)
def __set_status(self, status):
assert status in self.__STATUSES
......@@ -170,7 +170,7 @@ class PeakFitter(Thread):
try:
with QSpaceH5.QSpaceH5(qspace_f) as qspace_h5:
with qspace_h5.qspace_dset_ctx() as dset:
with qspace_h5:
x_pos = qspace_h5.sample_x[indices]
y_pos = qspace_h5.sample_y[indices]
except IOError:
......
......@@ -332,9 +332,9 @@ class Id01DataMerger(object):
self.__check_parsed()
if scan_ids is None:
scan_ids = self.__matched_scans.keys()
scan_ids = list(self.__matched_scans.keys())
if not isinstance(scan_ids, (list, tuple, xrange)):
if not isinstance(scan_ids, (list, tuple)):
scan_ids = [scan_ids]
scan_ids = set(scan_ids)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment