Skip to content

Commit c2ea7c7

Browse files
committed
pep 8
1 parent 02354dc commit c2ea7c7

File tree

4 files changed

+42
-29
lines changed

4 files changed

+42
-29
lines changed

winpython/associate.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def _get_shortcut_data(target, current=True):
4545
for name in os.listdir(wpdir):
4646
bname, ext = osp.splitext(name)
4747
if ext == '.exe':
48-
data.append( (osp.join(wpdir, name),
49-
bname,
50-
osp.join(wpgroup, bname)) )
48+
data.append((osp.join(wpdir, name),
49+
bname,
50+
osp.join(wpgroup, bname)))
5151
return data
5252

5353

@@ -101,7 +101,7 @@ def register(target, current=True):
101101
for ftype in ("", "NoCon", "Compiled"):
102102
winreg.SetValueEx(winreg.CreateKey(root, KEY_DROP1 % ftype),
103103
"", 0, winreg.REG_SZ, handler)
104-
104+
105105
# Icons
106106
dlls = osp.join(target, 'DLLs')
107107
winreg.SetValueEx(winreg.CreateKey(root, KEY_I % ""),
@@ -110,7 +110,7 @@ def register(target, current=True):
110110
"", 0, winreg.REG_SZ, r'%s\py.ico' % dlls)
111111
winreg.SetValueEx(winreg.CreateKey(root, KEY_I % "Compiled"),
112112
"", 0, winreg.REG_SZ, r'%s\pyc.ico' % dlls)
113-
113+
114114
# Descriptions
115115
winreg.SetValueEx(winreg.CreateKey(root, KEY_D % ""),
116116
"", 0, winreg.REG_SZ, "Python File")
@@ -195,7 +195,7 @@ def unregister(target, current=True):
195195
except WindowsError:
196196
rootkey = 'HKEY_CURRENT_USER' if current else 'HKEY_LOCAL_MACHINE'
197197
print(r'Unable to remove %s\%s' % (rootkey, key), file=sys.stderr)
198-
198+
199199
# Start menu shortcuts
200200
for path, desc, fname in _get_shortcut_data(target, current=current):
201201
if osp.exists(fname):

winpython/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_module_path(modname):
2222
def get_module_data_path(modname, relpath=None, attr_name='DATAPATH'):
2323
"""Return module *modname* data path
2424
Note: relpath is ignored if module has an attribute named *attr_name*
25-
25+
2626
Handles py2exe/cx_Freeze distributions"""
2727
datapath = getattr(sys.modules[modname], attr_name, '')
2828
if datapath:

winpython/py3compat.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
winpython.py3compat (exact copy of spyderlib.py3compat)
99
-------------------------------------------------------
1010
11-
Transitional module providing compatibility functions intended to help
11+
Transitional module providing compatibility functions intended to help
1212
migrating from Python 2 to Python 3.
1313
1414
This module should be fully compatible with:
@@ -25,9 +25,9 @@
2525
PY3 = sys.version[0] == '3'
2626

2727

28-
#==============================================================================
28+
# =============================================================================
2929
# Data types
30-
#==============================================================================
30+
# =============================================================================
3131
if PY2:
3232
# Python 2
3333
TEXT_TYPES = (str, unicode)
@@ -39,9 +39,9 @@
3939
NUMERIC_TYPES = tuple(list(INT_TYPES) + [float, complex])
4040

4141

42-
#==============================================================================
42+
# =============================================================================
4343
# Renamed/Reorganized modules
44-
#==============================================================================
44+
# =============================================================================
4545
if PY2:
4646
# Python 2
4747
import __builtin__ as builtins
@@ -74,9 +74,9 @@
7474
from collections import MutableMapping
7575

7676

77-
#==============================================================================
77+
# =============================================================================
7878
# Strings
79-
#==============================================================================
79+
# =============================================================================
8080
def is_text_string(obj):
8181
"""Return True if `obj` is a text string, False if it is anything else,
8282
like binary data (Python 3) or QString (Python 2, PyQt API #1)"""
@@ -87,6 +87,7 @@ def is_text_string(obj):
8787
# Python 3
8888
return isinstance(obj, str)
8989

90+
9091
def is_binary_string(obj):
9192
"""Return True if `obj` is a binary string, False if it is anything else"""
9293
if PY2:
@@ -96,11 +97,13 @@ def is_binary_string(obj):
9697
# Python 3
9798
return isinstance(obj, bytes)
9899

100+
99101
def is_string(obj):
100102
"""Return True if `obj` is a text or binary Python string object,
101103
False if it is anything else, like a QString (Python 2, PyQt API #1)"""
102104
return is_text_string(obj) or is_binary_string(obj)
103105

106+
104107
def is_unicode(obj):
105108
"""Return True if `obj` is unicode"""
106109
if PY2:
@@ -110,6 +113,7 @@ def is_unicode(obj):
110113
# Python 3
111114
return isinstance(obj, str)
112115

116+
113117
def to_text_string(obj, encoding=None):
114118
"""Convert `obj` to (unicode) text string"""
115119
if PY2:
@@ -128,6 +132,7 @@ def to_text_string(obj, encoding=None):
128132
else:
129133
return str(obj, encoding)
130134

135+
131136
def to_binary_string(obj, encoding=None):
132137
"""Convert `obj` to binary string (bytes in Python 3, str in Python 2)"""
133138
if PY2:
@@ -141,9 +146,9 @@ def to_binary_string(obj, encoding=None):
141146
return bytes(obj, 'utf-8' if encoding is None else encoding)
142147

143148

144-
#==============================================================================
149+
# =============================================================================
145150
# Function attributes
146-
#==============================================================================
151+
# =============================================================================
147152
def get_func_code(func):
148153
"""Return function code object"""
149154
if PY2:
@@ -153,6 +158,7 @@ def get_func_code(func):
153158
# Python 3
154159
return func.__code__
155160

161+
156162
def get_func_name(func):
157163
"""Return function name"""
158164
if PY2:
@@ -162,6 +168,7 @@ def get_func_name(func):
162168
# Python 3
163169
return func.__name__
164170

171+
165172
def get_func_defaults(func):
166173
"""Return function default argument values"""
167174
if PY2:
@@ -172,9 +179,9 @@ def get_func_defaults(func):
172179
return func.__defaults__
173180

174181

175-
#==============================================================================
182+
# =============================================================================
176183
# Special method attributes
177-
#==============================================================================
184+
# =============================================================================
178185
def get_meth_func(obj):
179186
"""Return method function object"""
180187
if PY2:
@@ -184,6 +191,7 @@ def get_meth_func(obj):
184191
# Python 3
185192
return obj.__func__
186193

194+
187195
def get_meth_class_inst(obj):
188196
"""Return method class instance"""
189197
if PY2:
@@ -193,6 +201,7 @@ def get_meth_class_inst(obj):
193201
# Python 3
194202
return obj.__self__
195203

204+
196205
def get_meth_class(obj):
197206
"""Return method class"""
198207
if PY2:
@@ -203,9 +212,9 @@ def get_meth_class(obj):
203212
return obj.__self__.__class__
204213

205214

206-
#==============================================================================
215+
# =============================================================================
207216
# Misc.
208-
#==============================================================================
217+
# =============================================================================
209218
if PY2:
210219
# Python 2
211220
input = raw_input
@@ -217,10 +226,12 @@ def get_meth_class(obj):
217226
# Python 3
218227
input = input
219228
getcwd = os.getcwd
229+
220230
def cmp(a, b):
221231
return (a > b) - (a < b)
222232
str_lower = str.lower
223233

234+
224235
def qbytearray_to_str(qba):
225236
"""Convert QByteArray object to str in a way compatible with Python 2/3"""
226237
return str(bytes(qba.toHex()).decode())

winpython/qthelpers.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def qapplication(translate=True):
4646
SpyderApplication = MacApplication
4747
else:
4848
SpyderApplication = QApplication
49-
49+
5050
app = SpyderApplication.instance()
5151
if not app:
5252
# Set Application name for Gnome 3
@@ -71,14 +71,16 @@ def file_uri(fname):
7171

7272

7373
QT_TRANSLATOR = None
74+
75+
7476
def install_translator(qapp):
7577
"""Install Qt translator to the QApplication instance"""
7678
global QT_TRANSLATOR
7779
if QT_TRANSLATOR is None:
7880
qt_translator = QTranslator()
7981
if qt_translator.load("qt_"+QLocale.system().name(),
8082
QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
81-
QT_TRANSLATOR = qt_translator # Keep reference alive
83+
QT_TRANSLATOR = qt_translator # Keep reference alive
8284
if QT_TRANSLATOR is not None:
8385
qapp.installTranslator(QT_TRANSLATOR)
8486

@@ -94,9 +96,9 @@ def _process_mime_path(path, extlist):
9496
if os.name == 'nt':
9597
# On Windows platforms, a local path reads: file:///c:/...
9698
# and a UNC based path reads like: file://server/share
97-
if path.startswith(r"file:///"): # this is a local path
98-
path=path[8:]
99-
else: # this is a unc path
99+
if path.startswith(r"file:///"): # this is a local path
100+
path = path[8:]
101+
else: # this is a unc path
100102
path = path[5:]
101103
else:
102104
path = path[7:]
@@ -168,7 +170,7 @@ def create_action(parent, text, shortcut=None, icon=None, tip=None,
168170
action.setData(to_qvariant(data))
169171
if menurole is not None:
170172
action.setMenuRole(menurole)
171-
#TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
173+
# TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
172174
# (this will avoid calling shortcuts from another dockwidget
173175
# since the context thing doesn't work quite well with these widgets)
174176
action.setShortcutContext(context)
@@ -201,14 +203,14 @@ def add_actions(target, actions, insert_before=None):
201203
target.insertAction(insert_before, action)
202204
previous_action = action
203205

204-
206+
205207
def get_std_icon(name, size=None):
206208
"""Get standard platform icon
207209
Call 'show_std_icons()' for details"""
208210
if not name.startswith('SP_'):
209211
name = 'SP_'+name
210-
icon = QWidget().style().standardIcon( getattr(QStyle, name) )
212+
icon = QWidget().style().standardIcon(getattr(QStyle, name))
211213
if size is None:
212214
return icon
213215
else:
214-
return QIcon( icon.pixmap(size, size) )
216+
return QIcon(icon.pixmap(size, size))

0 commit comments

Comments
 (0)