From 1c0387a192ce2d0926cb1340ebd5342ba43df410 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Wed, 19 Mar 2014 14:53:47 +0100 Subject: [PATCH] pep8 --- sloth/annotations/model.py | 25 ++++++++++++++++++------- sloth/gui/buttonarea.py | 6 ++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sloth/annotations/model.py b/sloth/annotations/model.py index 291e3e3..083ce60 100644 --- a/sloth/annotations/model.py +++ b/sloth/annotations/model.py @@ -11,7 +11,7 @@ from PyQt4.QtCore import QModelIndex, QAbstractItemModel, Qt, pyqtSignal, QVaria LOG = logging.getLogger(__name__) -ItemRole, DataRole, ImageRole = [Qt.UserRole + i + 1 for i in range(3)] +ItemRole, DataRole, ImageRole = [Qt.UserRole + ur + 1 for ur in range(3)] class ModelItem: @@ -172,7 +172,7 @@ class ModelItem: for i, item in enumerate(items): item._parent = self - item._row = next_row + i + item._row = next_row + i self._children.append(item) if self._model is not None: @@ -221,11 +221,12 @@ class ModelItem: def getColor(self): return None + class RootModelItem(ModelItem): def __init__(self, model, files): ModelItem.__init__(self) self._model = model - self._toload = [] + self._toload = [] for f in files: self._toload.append(f) self._children.append(f) @@ -251,9 +252,9 @@ class RootModelItem(ModelItem): else: return Qt.ItemIsEnabled | Qt.ItemIsSelectable - def appendChild(self, item): + def appendChild(self, item, signalModel=True): if isinstance(item, FileModelItem): - ModelItem.appendChild(self, item) + ModelItem.appendChild(self, item, signalModel=signalModel) else: raise TypeError("Only FileModelItems can be attached to RootModelItem") @@ -285,6 +286,7 @@ class RootModelItem(ModelItem): return [child.getAnnotations() for child in self.children() if hasattr(child, 'getAnnotations')] + class KeyValueModelItem(ModelItem, MutableMapping): def __init__(self, hidden=None, properties=None): ModelItem.__init__(self) @@ -397,6 +399,7 @@ class KeyValueModelItem(ModelItem, MutableMapping): del self['unconfirmed'] self._emitDataChanged('unconfirmed') + class FileModelItem(KeyValueModelItem): def __init__(self, fileinfo, hidden=None): if not hidden: hidden = ['filename'] @@ -422,6 +425,7 @@ class FileModelItem(KeyValueModelItem): elif fileinfo['class'] == 'video': return VideoFileModelItem(fileinfo) + class ImageModelItem(ModelItem): def __init__(self, annotations): ModelItem.__init__(self) @@ -440,6 +444,7 @@ class ImageModelItem(ModelItem): for ann in self.annotations(): ann.setUnconfirmed(False) + class ImageFileModelItem(FileModelItem, ImageModelItem): def __init__(self, fileinfo): self._annotation_data = fileinfo.get("annotations", []) @@ -472,6 +477,7 @@ class ImageFileModelItem(FileModelItem, ImageModelItem): if hasattr(child, 'getAnnotations')] return fi + class VideoFileModelItem(FileModelItem): def __init__(self, fileinfo): frameinfos = fileinfo.get("frames", []) @@ -488,6 +494,7 @@ class VideoFileModelItem(FileModelItem): fi['frames'] = [child.getAnnotations() for child in self.children()] return fi + class FrameModelItem(ImageModelItem, KeyValueModelItem): def __init__(self, frameinfo): annotations = frameinfo.get("annotations", []) @@ -521,6 +528,7 @@ class FrameModelItem(ImageModelItem, KeyValueModelItem): if hasattr(child, 'getAnnotations')] return fi + class AnnotationModelItem(KeyValueModelItem): def __init__(self, annotation): KeyValueModelItem.__init__(self, properties=annotation) @@ -547,6 +555,7 @@ class AnnotationModelItem(KeyValueModelItem): return Qt.red return None + class KeyValueRowModelItem(ModelItem): def __init__(self, key, read_only=True): ModelItem.__init__(self) @@ -668,8 +677,10 @@ class AnnotationModel(QAbstractItemModel): def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: - if section == 0: return "File/Type/Key" - elif section == 1: return "Value" + if section == 0: + return "File/Type/Key" + elif section == 1: + return "Value" return None # Own methods diff --git a/sloth/gui/buttonarea.py b/sloth/gui/buttonarea.py index 029869a..7e8e832 100644 --- a/sloth/gui/buttonarea.py +++ b/sloth/gui/buttonarea.py @@ -3,8 +3,10 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * from sloth.gui.floatinglayout import FloatingLayout import logging + LOG = logging.getLogger(__name__) + def unique_list(seq): seen = {} result = [] @@ -14,6 +16,7 @@ def unique_list(seq): result.append(item) return result + class ButtonListWidget(QGroupBox): selectionChanged = pyqtSignal(object) @@ -196,8 +199,10 @@ class ButtonArea(QWidget): if button is not None: self.label_button_list.toggleChecked(button) + def main(): from conf import config + config.update("example_config") app = QApplication(sys.argv) @@ -206,6 +211,7 @@ def main(): return app.exec_() + if __name__ == '__main__': sys.exit(main())