Skip to content

Commit e9ef27a

Browse files
committed
pep8 fixes
1 parent 0543807 commit e9ef27a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

larray_editor/utils.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import sys
55
import numpy as np
66

7-
PY2 = sys.version[0] == '2'
8-
97
from qtpy import PYQT5
108
from qtpy.QtCore import QVariant
119
from qtpy.QtGui import QIcon, QColor, QFont, QKeySequence
@@ -19,6 +17,8 @@
1917
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
2018

2119

20+
PY2 = sys.version[0] == '2'
21+
2222
# Note: string and unicode data types will be formatted with '%s' (see below)
2323
SUPPORTED_FORMATS = {
2424
'object': '%s',
@@ -62,37 +62,45 @@
6262
'bool': '%r',
6363
}
6464

65+
6566
def _get_font(family, size, bold=False, italic=False):
6667
weight = QFont.Bold if bold else QFont.Normal
6768
font = QFont(family, size, weight)
6869
if italic:
6970
font.setItalic(True)
7071
return to_qvariant(font)
7172

73+
7274
def is_float(dtype):
7375
"""Return True if datatype dtype is a float kind"""
7476
return ('float' in dtype.name) or dtype.name in ['single', 'double']
7577

78+
7679
def is_number(dtype):
7780
"""Return True is datatype dtype is a number kind"""
7881
return is_float(dtype) or ('int' in dtype.name) or ('long' in dtype.name) or ('short' in dtype.name)
7982

83+
8084
def get_font(section):
8185
return _get_font('Calibri', 11)
8286

87+
8388
def to_qvariant(obj=None):
8489
return obj
8590

91+
8692
def from_qvariant(qobj=None, pytype=None):
8793
# FIXME: force API level 2 instead of handling this
8894
if isinstance(qobj, QVariant):
8995
assert pytype is str
9096
return pytype(qobj.toString())
9197
return qobj
9298

99+
93100
def _(text):
94101
return text
95102

103+
96104
def to_text_string(obj, encoding=None):
97105
"""Convert `obj` to (unicode) text string"""
98106
if PY2:
@@ -111,11 +119,13 @@ def to_text_string(obj, encoding=None):
111119
else:
112120
return str(obj, encoding)
113121

122+
114123
def keybinding(attr):
115124
"""Return keybinding"""
116125
ks = getattr(QKeySequence, attr)
117126
return QKeySequence.keyBindings(ks)[0]
118127

128+
119129
def create_action(parent, text, icon=None, triggered=None, shortcut=None, statustip=None):
120130
"""Create a QAction"""
121131
action = QAction(text, parent)
@@ -130,6 +140,7 @@ def create_action(parent, text, icon=None, triggered=None, shortcut=None, status
130140
# action.setShortcutContext(Qt.WidgetShortcut)
131141
return action
132142

143+
133144
def clear_layout(layout):
134145
for i in reversed(range(layout.count())):
135146
item = layout.itemAt(i)
@@ -139,6 +150,7 @@ def clear_layout(layout):
139150
widget.deleteLater()
140151
layout.removeItem(item)
141152

153+
142154
def get_idx_rect(index_list):
143155
"""Extract the boundaries from a list of indexes"""
144156
rows = [i.row() for i in index_list]
@@ -147,7 +159,6 @@ def get_idx_rect(index_list):
147159

148160

149161
class IconManager(object):
150-
151162
_icons = {'larray': 'larray.ico'}
152163
_icon_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'images')
153164

@@ -162,6 +173,7 @@ def icon(self, ref):
162173
# appropriate PySide.QtGui.QIcon.themeName() .
163174
return QIcon.fromTheme(ref)
164175

176+
165177
ima = IconManager()
166178

167179

@@ -170,11 +182,11 @@ class LinearGradient(object):
170182
I cannot believe I had to roll my own class for this when PyQt already
171183
contains QLinearGradient... but you cannot get intermediate values out of
172184
QLinearGradient!
173-
185+
174186
Parameters
175187
----------
176188
stop_points: list/tuple, optional
177-
List containing pairs (stop_position, colors_HsvF).
189+
List containing pairs (stop_position, colors_HsvF).
178190
`colors` is a 4 elements list containing `hue`, `saturation`, `value` and `alpha-channel`
179191
"""
180192
def __init__(self, stop_points=None):
@@ -224,6 +236,7 @@ def __init__(self, canvas, parent=None):
224236
self.setLayout(layout)
225237
canvas.draw()
226238

239+
227240
def show_figure(parent, figure):
228241
canvas = FigureCanvas(figure)
229242
main = PlotDialog(canvas, parent)

0 commit comments

Comments
 (0)