Skip to content

Commit 2504a35

Browse files
committed
Style Guide Fixes:Pep8
1 parent 94cb2ad commit 2504a35

36 files changed

+181
-128
lines changed

kivy/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ def kivy_usage():
183183
kivy_options = {
184184
'window': ('egl_rpi', 'pygame', 'sdl', 'x11', 'sdl2'),
185185
'text': ('pil', 'pygame', 'sdlttf', 'sdl2'),
186-
'video': ('gstplayer', 'ffmpeg', 'ffpyplayer', 'gi', 'pygst', 'pyglet',
187-
'null'),
186+
'video': (
187+
'gstplayer', 'ffmpeg', 'ffpyplayer', 'gi', 'pygst', 'pyglet',
188+
'null'),
188189
'audio': ('gstplayer', 'pygame', 'gi', 'pygst', 'ffpyplayer', 'sdl'),
189190
'image': ('tex', 'imageio', 'dds', 'gif', 'pil', 'pygame', 'ffpy', 'sdl2'),
190191
'camera': ('opencv', 'gi', 'pygst', 'videocapture', 'avfoundation'),
191192
'spelling': ('enchant', 'osxappkit', ),
192-
'clipboard': ('android', 'winctypes', 'dbusklipper', 'nspaste', 'pygame', 'sdl2', 'dummy'), }
193+
'clipboard': (
194+
'android', 'winctypes', 'dbusklipper', 'nspaste', 'pygame',
195+
'sdl2', 'dummy'), }
193196

194197
# Read environment
195198
for option in kivy_options:

kivy/adapters/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
An adapter is a mediating controller-type class that processes and presents
88
data for use in views. It does this by generating models, generally lists of
99
:class:`~kivy.uix.listview.SelectableView` items, that are consumed and
10-
presented by views. Views are top-level widgets, such as a
10+
presented by views. Views are top-level widgets, such as a
1111
:class:`~kivy.uix.listview.ListView`, that allow users to scroll through
1212
and (optionally) interact with your data.
1313
@@ -35,7 +35,7 @@
3535
and your data. It manages the creation of the view elements for the model
3636
using the args_converter to prepare the contructor arguments for your
3737
cls/template view items.
38-
38+
3939
The base :class:`Adapter` is subclassed by the
4040
:class:`SimpleListAdapter` and :class:`ListAdapter`. The :class:`DictAdapter`
4141
is a more advanced and flexible subclass of :class:`ListAdapter`.
@@ -66,7 +66,7 @@
6666
your data items create a corresponding view subitem (the cls or template)
6767
presented in a list by the View. The base :class:`AbstractView` currently has
6868
one concrete implementation: the :class:`ListView`.
69-
69+
7070
:doc:`api-kivy.uix.abstractview`,
7171
:doc:`api-kivy.uix.listview`.
7272

kivy/adapters/adapter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from kivy.factory import Factory
4848
from kivy.compat import string_types
4949

50+
5051
class Adapter(EventDispatcher):
5152
'''An :class:`~kivy.adapters.adapter.Adapter` is a bridge between data and
5253
an :class:`~kivy.uix.abstractview.AbstractView` or one of its subclasses,

kivy/adapters/args_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
Please see the `list_composite.py <https://github.com/\
4646
kivy/kivy/tree/master/examples/widgets/lists/list_composite.py>`_ for a complete
4747
example.
48-
48+
4949
'''
5050
list_item_args_converter = lambda row_index, x: {'text': x,
5151
'size_hint_y': None,

kivy/adapters/listadapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ class ListAdapter(Adapter, EventDispatcher):
130130
the data. You could accomplish the same functionality by writing code to
131131
operate on list selection, but having selection stored in the data
132132
ListProperty might prove convenient in some cases.
133-
133+
134134
.. note::
135-
135+
136136
This setting should be set to True if you wish to initialize the view
137137
with item views already selected.
138138

kivy/clock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
`dt` argument::
99
1010
# dt means delta-time
11-
def my_callback(dt):
11+
def my_callback(dt):
1212
pass
1313
1414
# call my_callback every 0.5 seconds

kivy/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
The ConfigParser should work correctly with utf-8 now. The values are
3636
converted from ascii to unicode only when needed. The method get() returns
3737
utf-8 strings.
38-
38+
3939
.. _configuration-tokens:
4040
4141
Available configuration tokens
@@ -227,7 +227,7 @@
227227
.. note::
228228
229229
These options control only the initalization of the app and a restart
230-
is required for value changes to take effect.
230+
is required for value changes to take effect.
231231
232232
.. versionchanged:: 1.9.0
233233
`borderless` has been added to the graphics section.

kivy/core/audio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
.. note::
2727
2828
The core audio library does not support recording audio. If you require
29-
this functionality, please refer to the
29+
this functionality, please refer to the
3030
`audiostream <https://github.com/kivy/audiostream>`_ extension.
3131
3232
'''

kivy/core/clipboard/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def get_types(self):
5353
def _ensure_clipboard(self):
5454
''' Ensure that the clipboard has been properly initialised.
5555
'''
56-
56+
5757
if hasattr(self, '_clip_mime_type'):
5858
return
59-
59+
6060
if platform == 'win':
6161
self._clip_mime_type = 'text/plain;charset=utf-8'
6262
# windows clipboard uses a utf-16 encoding
@@ -128,7 +128,8 @@ def _paste(self):
128128
_clipboards.append(
129129
('winctypes', 'clipboard_winctypes', 'ClipboardWindows'))
130130
elif _platform == 'linux':
131-
_clipboards.append(('dbusklipper', 'clipboard_dbusklipper', 'ClipboardDbusKlipper'))
131+
_clipboards.append(
132+
('dbusklipper', 'clipboard_dbusklipper', 'ClipboardDbusKlipper'))
132133

133134
_clipboards.append(
134135
('pygame', 'clipboard_pygame', 'ClipboardPygame'))

kivy/core/clipboard/clipboard_pygame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ def init(self):
3030

3131
def get(self, mimetype='text/plain'):
3232
self.init()
33+
<<<<<<< Updated upstream
3334
text = pygame.scrap.get(mimetype)
3435
if PY2:
3536
text = text.encode('utf-8')
3637

3738
return text
39+
=======
40+
return pygame.scrap.get(mimetype).encode('utf-8')
41+
>>>>>>> Stashed changes
3842

3943
def put(self, data, mimetype='text/plain'):
4044
self.init()

kivy/core/clipboard/clipboard_sdl2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
raise SystemError('unsupported platform for sdl2 clipboard')
1212

1313
try:
14-
from kivy.core.clipboard._clipboard_sdl2 import _get_text, _has_text, _set_text
14+
from kivy.core.clipboard._clipboard_sdl2 import (
15+
_get_text, _has_text, _set_text)
1516
except ImportError:
1617
raise SystemError('extension not compiled?')
1718

kivy/core/text/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ def render(self, real=False):
554554
# all text will be stripped by default. unicode NO-BREAK SPACE
555555
# characters will be preserved, so we replace the leading and
556556
# trailing spaces with \u00a0
557-
text = text.decode('utf8', errors=options['unicode_errors']) if isinstance(text, bytes) else text
557+
text = text.decode('utf8', errors=options['unicode_errors'])\
558+
if isinstance(text, bytes) else text
558559
lspace = len(text) - len(text.lstrip())
559560
rspace = len(text) - len(text.rstrip())
560561
text = (u'\u00a0' * lspace) + text.strip() + (u'\u00a0' * rspace)

kivy/core/text/markup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def _real_render(self):
437437
anchor = options['_anchor']
438438
if anchor is not None:
439439
if not anchor in anchors:
440-
anchors[anchor] = (x, y)
440+
anchors[anchor] = (x, y)
441441
x += word.lw
442442
y += lh
443443

kivy/core/text/text_sdl2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class LabelSDL2(LabelBase):
1818
def _get_font_id(self):
1919
if PY2:
2020
try:
21-
return '|'.join([unicode(self.options[x]) for x \
21+
return '|'.join([unicode(self.options[x]) for x
2222
in ('font_size', 'font_name_r', 'bold', 'italic')])
2323
except UnicodeDecodeError:
2424
pass
25-
return '|'.join([str(self.options[x]) for x \
25+
return '|'.join([str(self.options[x]) for x
2626
in ('font_size', 'font_name_r', 'bold', 'italic')])
2727

2828
def get_extents(self, text):

kivy/core/video/video_ffpyplayer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,12 @@ def _redraw(self, *args):
177177
if self._out_fmt == 'yuv420p':
178178
w2 = int(w / 2)
179179
h2 = int(h / 2)
180-
self._tex_y = Texture.create(size=(w, h), colorfmt='luminance')
181-
self._tex_u = Texture.create(size=(w2, h2), colorfmt='luminance')
182-
self._tex_v = Texture.create(size=(w2, h2), colorfmt='luminance')
180+
self._tex_y = Texture.create(
181+
size=(w, h), colorfmt='luminance')
182+
self._tex_u = Texture.create(
183+
size=(w2, h2), colorfmt='luminance')
184+
self._tex_v = Texture.create(
185+
size=(w2, h2), colorfmt='luminance')
183186
self._fbo = fbo = Fbo(size=self._size)
184187
with fbo:
185188
BindTexture(texture=self._tex_u, index=1)
@@ -205,7 +208,8 @@ def _redraw(self, *args):
205208
self._tex_u.blit_buffer(du, colorfmt='luminance')
206209
self._tex_v.blit_buffer(dv, colorfmt='luminance')
207210
else:
208-
self._texture.blit_buffer(img.to_memoryview()[0], colorfmt='rgba')
211+
self._texture.blit_buffer(
212+
img.to_memoryview()[0], colorfmt='rgba')
209213

210214
self._fbo.ask_update()
211215
self._fbo.draw()

kivy/core/video/video_gstplayer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def _update_texture(self, buf):
125125
self.dispatch('on_load')
126126

127127
if self._texture:
128-
self._texture.blit_buffer(data, size=(width, height), colorfmt='rgb')
128+
self._texture.blit_buffer(
129+
data, size=(width, height), colorfmt='rgb')
129130

130131
def _get_uri(self):
131132
uri = self.filename

kivy/core/window/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,16 @@ def _set_rotation(self, x):
406406
softinput_mode = OptionProperty('', options=('', 'pan', 'scale', 'resize'))
407407
'''This specifies the behavior of window contents on display of soft
408408
keyboard on mobile platform. Can be one of '', 'pan', 'scale', 'resize'.
409-
409+
410410
When '' The main window is left as it is allowing the user to use
411411
:attr:`keyboard_height` to manage the window contents the way they want.
412-
412+
413413
when 'pan' The main window pans moving the bottom part of the window to be
414414
always on top of the keyboard.
415-
415+
416416
when 'resize' The window is resized and the contents scaled to fit the
417417
remaining space.
418-
418+
419419
..versionadded::1.9.0
420420
421421
:attr:`softinput_mode` is a :class:`OptionProperty` defaults to None.
@@ -509,8 +509,8 @@ def __self__(self):
509509
'on_motion', 'on_touch_down', 'on_touch_move', 'on_touch_up',
510510
'on_mouse_down', 'on_mouse_move', 'on_mouse_up',
511511
'on_keyboard', 'on_key_down', 'on_key_up', 'on_dropfile',
512-
'on_request_close', 'on_joy_axis', 'on_joy_hat', 'on_joy_ball',
513-
'on_joy_button_down', "on_joy_button_up")
512+
'on_request_close', 'on_joy_axis', 'on_joy_hat',
513+
'on_joy_ball', 'on_joy_button_down', "on_joy_button_up")
514514

515515
def __new__(cls, **kwargs):
516516
if cls.__instance is None:
@@ -908,7 +908,6 @@ def update_viewport(self):
908908
w2, h2 = w / 2., h / 2.
909909
r = radians(self.rotation)
910910

911-
912911
x, y = 0, 0
913912
_h = h
914913
if smode:
@@ -1038,6 +1037,7 @@ def on_joy_button_down(self, stickid, buttonid):
10381037
10391038
.. versionadded:: 1.9.0'''
10401039
pass
1040+
10411041
def on_joy_button_up(self, stickid, buttonid):
10421042
'''Event called when a joystick has a button released
10431043

kivy/core/window/window_pygame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def create_window(self, *largs):
7979

8080
if self._fake_fullscreen:
8181
if not self.borderless:
82-
self.fullscreen = self._fake_fullscreen = False
82+
self.fullscreen = self._fake_fullscreen = False
8383
elif not self.fullscreen or self.fullscreen == 'auto':
8484
self.borderless = self._fake_fullscreen = False
8585

kivy/input/providers/androidjoystick.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def update(self, dispatch_fn):
9595
elif pressed:
9696
touch = touches[jid]
9797
# avoid same touch position
98-
if touch.sx == x and touch.sy == y \
99-
and touch.pressure == pressure:
98+
if (touch.sx == x and touch.sy == y
99+
and touch.pressure == pressure):
100100
continue
101101
touch.move([x, y, pressure, radius])
102102
dispatch_fn('update', touch)

kivy/input/providers/hidinput.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ def process_as_multitouch(tv_sec, tv_usec, ev_type,
466466
elif ev_code == ABS_MT_TOUCH_MINOR:
467467
point['size_h'] = ev_value
468468

469-
def process_as_mouse_or_keyboard(tv_sec, tv_usec, ev_type, ev_code, ev_value):
469+
def process_as_mouse_or_keyboard(
470+
tv_sec, tv_usec, ev_type, ev_code, ev_value):
470471

471472
if ev_type == EV_SYN:
472473
if ev_code == SYN_REPORT:
@@ -521,22 +522,35 @@ def process_as_mouse_or_keyboard(tv_sec, tv_usec, ev_type, ev_code, ev_value):
521522
point['_avoid'] = True
522523
else:
523524
if ev_value == 1:
524-
l = keyboard_keys[ev_code][-1 if 'shift' in Window._modifiers else 0]
525+
l = keyboard_keys[ev_code][-1
526+
if 'shift' in Window._modifiers else 0]
525527
if l == 'shift':
526528
Window._modifiers.append('shift')
527529
print(ev_code, l)
528-
Window.dispatch('on_key_down', Keyboard.keycodes[l.lower()], ev_code, keys_str.get(l, l), Window._modifiers)
530+
Window.dispatch(
531+
'on_key_down',
532+
Keyboard.keycodes[l.lower()],
533+
ev_code, keys_str.get(l, l),
534+
Window._modifiers)
529535
if ev_value == 0:
530-
l = keyboard_keys[ev_code][-1 if 'shift' in Window._modifiers else 0]
531-
Window.dispatch('on_key_up', Keyboard.keycodes[l.lower()], ev_code, keys_str.get(l, l), Window._modifiers)
536+
l = keyboard_keys[ev_code][-1
537+
if 'shift' in Window._modifiers else 0]
538+
Window.dispatch(
539+
'on_key_up',
540+
Keyboard.keycodes[l.lower()],
541+
ev_code,
542+
keys_str.get(l, l),
543+
Window._modifiers)
532544
if l == 'shift':
533545
Window._modifiers.remove('shift')
534546
# if ev_value == 2:
535547
# Window.dispatch('on_key_down', ev_code)
536548

537549
def process(points):
538550
if not is_multitouch:
539-
Window.mouse_pos = points[0]['x'] * Window.width, points[0]['y'] * Window.height
551+
Window.mouse_pos = (
552+
points[0]['x'] * Window.width,
553+
points[0]['y'] * Window.height)
540554

541555
actives = [args['id']
542556
for args in points
@@ -636,8 +650,10 @@ def normalize(value, vmin, vmax):
636650
'<%s> range ABS Y position is %d - %d' % (
637651
device_name, abs_min, abs_max))
638652
elif y == ABS_PRESSURE:
639-
range_min_abs_pressure = drs('min_abs_pressure', abs_min)
640-
range_max_abs_pressure = drs('max_abs_pressure', abs_max)
653+
range_min_abs_pressure = drs(
654+
'min_abs_pressure', abs_min)
655+
range_max_abs_pressure = drs(
656+
'max_abs_pressure', abs_max)
641657
Logger.info('HIDMotionEvent: ' +
642658
'<%s> range ABS pressure is %d - %d' % (
643659
device_name, abs_min, abs_max))

kivy/modules/inspector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ def show_widget_info(self):
422422
try:
423423
widget.bind(**{key: partial(
424424
self.update_node_content, weakref.ref(node))})
425-
except: pass
425+
except:
426+
pass
426427
treeview.add_node(node)
427428

428429
def update_node_content(self, node, *l):

kivy/modules/touchring.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
Opacity of the image.
1818
`show_cursor`: boolean, default to False
1919
.. versionadded:: 1.8.0
20-
`cursor_image`: str, defaults to 'atlas://data/images/defaulttheme/slider_cursor'
21-
Image used to represent the cursor if displayed
20+
`cursor_image`: str, defaults to
21+
'atlas://data/images/defaulttheme/slider_cursor' Image used to
22+
represent the cursor if displayed
2223
.. versionadded:: 1.8.0
2324
`cursor_size`: tuple, defaults to (None, None)
2425
Apparent size of the mouse cursor, if displayed, default value

kivy/network/urlrequest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,9 @@ def on_error(req, error):
502502
pprint('Got an error:')
503503
pprint(error)
504504

505-
req = UrlRequest('http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Kivy&prop=revisions&rvprop=content',
506-
on_success, on_error)
505+
req = UrlRequest('http://en.wikipedia.org/w/api.php?format'
506+
'=json&action=query&titles=Kivy&prop=revisions&rvprop=content',
507+
on_success, on_error)
507508
while not req.is_finished:
508509
sleep(1)
509510
Clock.tick()

0 commit comments

Comments
 (0)