From 4c6690bd6fc416f939aaae626d45dbac5451affe Mon Sep 17 00:00:00 2001 From: dessant Date: Sun, 18 Dec 2016 16:11:41 +0200 Subject: [PATCH] pep8 fixes --- examples/android/takepicture/main.py | 6 ++-- examples/demo/kivycatalog/main.py | 2 +- examples/demo/multistroke/gesturedatabase.py | 2 +- examples/keyboard/main.py | 14 ++++---- examples/kinect/kinectviewer.py | 4 +-- examples/shader/shadertree.py | 3 +- examples/widgets/lists/fixtures.py | 3 +- examples/widgets/lists/fruit_detail_view.py | 7 ++-- examples/widgets/lists/list_ops.py | 4 +-- examples/widgets/unicode_textinput.py | 15 ++++---- kivy/adapters/args_converters.py | 2 +- kivy/adapters/listadapter.py | 8 ++--- kivy/clock.py | 8 ++--- kivy/core/spelling/spelling_osxappkit.py | 5 +-- kivy/geometry.py | 4 +-- kivy/interactive.py | 4 +-- kivy/lang/__init__.py | 3 +- kivy/lang/builder.py | 38 ++++++++++---------- 18 files changed, 70 insertions(+), 62 deletions(-) diff --git a/examples/android/takepicture/main.py b/examples/android/takepicture/main.py index 874d49bf3..43f9756ca 100644 --- a/examples/android/takepicture/main.py +++ b/examples/android/takepicture/main.py @@ -5,9 +5,9 @@ Take picture .. author:: Mathieu Virbel Little example to demonstrate how to start an Intent, and get the result. -When you use the Android.startActivityForResult(), the result will be dispatched -into onActivityResult. You can catch the event with the android.activity API -from python-for-android project. +When you use the Android.startActivityForResult(), the result will be +dispatched into onActivityResult. You can catch the event with the +android.activity API from python-for-android project. If you want to compile it, don't forget to add the CAMERA permission:: diff --git a/examples/demo/kivycatalog/main.py b/examples/demo/kivycatalog/main.py index 01395c3fb..0085e1d04 100755 --- a/examples/demo/kivycatalog/main.py +++ b/examples/demo/kivycatalog/main.py @@ -81,7 +81,7 @@ class KivyRenderTextInput(CodeInput): ctrl, cmd = 64, 1024 key, key_str = keycode - if text and not key in (list(self.interesting_keys.keys()) + [27]): + if text and key not in (list(self.interesting_keys.keys()) + [27]): # This allows *either* ctrl *or* cmd, but not both. if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']): if key == ord('s'): diff --git a/examples/demo/multistroke/gesturedatabase.py b/examples/demo/multistroke/gesturedatabase.py index 2fbb95742..6034f1255 100644 --- a/examples/demo/multistroke/gesturedatabase.py +++ b/examples/demo/multistroke/gesturedatabase.py @@ -134,7 +134,7 @@ class GestureDatabase(GridLayout): if i.ids.select.state == 'down': self.selected_count -= 1 for g in i.gesture_list: -# if g in self.recognizer.db: # not needed, for testing + # if g in self.recognizer.db: # not needed, for testing self.recognizer.db.remove(g) self.ids.gesture_list.remove_widget(i) diff --git a/examples/keyboard/main.py b/examples/keyboard/main.py index 1dac4457f..6f98f1a54 100755 --- a/examples/keyboard/main.py +++ b/examples/keyboard/main.py @@ -2,9 +2,9 @@ Custom Keyboards ================ -This demo shows how to create and display custom keyboards on screen. Note that -the new "input_type" property of the TextInput means that this is rarely needed. -We provide this demo for the sake of completeness. +This demo shows how to create and display custom keyboards on screen. +Note that the new "input_type" property of the TextInput means that this +is rarely needed. We provide this demo for the sake of completeness. """ # Author: Zen-CODE from kivy.app import App @@ -18,8 +18,8 @@ from kivy.config import Config from kivy.uix.screenmanager import Screen, ScreenManager from kivy import require -# This example uses features introduced in Kivy 1.8.0, namely being able to load -# custom json files from the app folder +# This example uses features introduced in Kivy 1.8.0, namely being able +# to load custom json files from the app folder. require("1.8.0") Builder.load_string(''' @@ -167,8 +167,8 @@ class KeyboardScreen(Screen): """ Add a buttons for each available keyboard layout. When clicked, the buttons will change the keyboard layout to the one selected. """ layouts = list(VKeyboard().available_layouts.keys()) - layouts.append("numeric.json") # Add the file in our app directory - # Note the .json extension is required + # Add the file in our app directory, the .json extension is required. + layouts.append("numeric.json") for key in layouts: self.kbContainer.add_widget( Button( diff --git a/examples/kinect/kinectviewer.py b/examples/kinect/kinectviewer.py index 3255a7639..b79cab71c 100644 --- a/examples/kinect/kinectviewer.py +++ b/examples/kinect/kinectviewer.py @@ -123,8 +123,8 @@ void main (void) { float dr = th / 10.; v = min(v, dr) / dr; - // calculate the distance between the center of the square and current pixel - // display the pixel only if the distance is inside the circle + // calculate the distance between the center of the square and current + // pixel; display the pixel only if the distance is inside the circle float vdist = length(abs(tex_coord0 - center) * size / square); float value = 1 - v; if ( vdist < value ) { diff --git a/examples/shader/shadertree.py b/examples/shader/shadertree.py index ff76e8b6c..6f4c8b241 100644 --- a/examples/shader/shadertree.py +++ b/examples/shader/shadertree.py @@ -196,7 +196,8 @@ class ShaderTreeApp(App): def change(*largs): sw.fs = available_shaders[self.shader_index] - self.shader_index = (self.shader_index + 1) % len(available_shaders) + self.shader_index = ((self.shader_index + 1) % + len(available_shaders)) btn.bind(on_release=change) root.add_widget(btn) return root diff --git a/examples/widgets/lists/fixtures.py b/examples/widgets/lists/fixtures.py index 30e0c5a44..831f42212 100644 --- a/examples/widgets/lists/fixtures.py +++ b/examples/widgets/lists/fixtures.py @@ -59,7 +59,8 @@ fruit_data_list_of_dicts = [ { 'name': 'Cantaloupe', 'Serving Size': '1/4 medium (134 g/4.8 oz)', - 'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120, 80, 2, 2], + 'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120, + 80, 2, 2], 'is_selected': False}, { 'name': 'Grapefruit', diff --git a/examples/widgets/lists/fruit_detail_view.py b/examples/widgets/lists/fruit_detail_view.py index 1d9fa3cbe..d659e4cff 100644 --- a/examples/widgets/lists/fruit_detail_view.py +++ b/examples/widgets/lists/fruit_detail_view.py @@ -104,9 +104,9 @@ class FruitImageDetailView(BoxLayout): container.add_widget(Label(text=self.fruit_name)) for attribute in fruit_data_attributes: container.add_widget(Label(text="{0}:".format(attribute), - halign='right')) + halign='right')) container.add_widget( - Label(text=str(fruit_data[self.fruit_name][attribute]))) + Label(text=str(fruit_data[self.fruit_name][attribute]))) self.add_widget(container) def fruit_changed(self, list_adapter, *args): @@ -118,7 +118,8 @@ class FruitImageDetailView(BoxLayout): # [TODO] Would we want touch events for the composite, as well as # the components? Just the components? Just the composite? # - # Is selected_object an instance of ThumbnailedListItem (composite)? + # Is selected_object an instance of ThumbnailedListItem + # (composite)? # # Or is it a ListItemButton? # diff --git a/examples/widgets/lists/list_ops.py b/examples/widgets/lists/list_ops.py index 268428b14..604fdbd78 100644 --- a/examples/widgets/lists/list_ops.py +++ b/examples/widgets/lists/list_ops.py @@ -101,8 +101,8 @@ class SelectionMonitor(Widget): self.sel_count_6 = len(adapter.selection) -letters_dict = \ - {l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'} +letters_dict = { + l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'} listview_selection_buttons = {} diff --git a/examples/widgets/unicode_textinput.py b/examples/widgets/unicode_textinput.py index 619f41a4b..cc873e387 100644 --- a/examples/widgets/unicode_textinput.py +++ b/examples/widgets/unicode_textinput.py @@ -124,7 +124,7 @@ class LoadDialog(FloatLayout): class Unicode_TextInput(BoxLayout): txt_input = ObjectProperty(None) - unicode_string = StringProperty('''Latin-1 supplement: éé çç ßß + unicode_string = StringProperty("""Latin-1 supplement: éé çç ßß List of major languages taken from Google Translate ____________________________________________________ @@ -150,11 +150,13 @@ Dutch: De snelle bruine vos springt over de luie oude hond. Estonian: Kiire pruun rebane hüppab üle laisa vana koer. Filipino: Ang mabilis na brown soro jumps sa ang tamad lumang aso. Finnish: Nopea ruskea kettu hyppää yli laiska vanha koira. -French: Le renard brun rapide saute par dessus le chien paresseux vieux. +French: Le renard brun rapide saute par dessus le chien + paresseux vieux. Galician: A lixeira raposo marrón ataca o can preguiceiro de idade. Gregorian: სწრაფი ყავისფერი მელა jumps გამო ზარმაცი წლის ძაღლი. German: Der schnelle braune Fuchs springt über den faulen alten Hund. -Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο γέρικο σκυλί. +Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο + γέρικο σκυλί. Gujrati: આ ઝડપી ભુરો શિયાળ તે બેકાર જૂના કૂતરા પર કૂદકા. Gurmukhi: ਤੇਜ ਭੂਰੇ ਰੰਗ ਦੀ ਲੂੰਬੜੀ ਆਲਸੀ ਬੁੱਢੇ ਕੁੱਤੇ ਦੇ ਉਤੋਂ ਦੀ ਟੱਪਦੀ ਹੈ । Hiation Creole: Rapid mawon Rena a so sou chen an parese fin vye granmoun. @@ -186,15 +188,16 @@ Slovenian: Kožuščku hudobnega nad leni starega psa. Spanish: La cigüeña tocaba el saxofón en el viejo perro perezoso. Swahili: Haraka brown fox anaruka juu ya mbwa wavivu zamani. Swedish: Den snabba bruna räven hoppar över den lata gammal hund. -Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது தொடரப்படுகிறது +Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது + தொடரப்படுகிறது Telugu: శీఘ్ర బ్రౌన్ ఫాక్స్ సోమరితనం పాత కుక్క కంటే హెచ్చుతగ్గుల. Thai: สีน้ำตาลอย่างรวดเร็วจิ้งจอกกระโดดมากกว่าสุนัขเก่าที่ขี้เกียจ Turkish: Hızlı kahverengi tilki tembel köpeğin üstünden atlar. Ukranian: Швидкий коричневий лис перестрибує через лінивий старий пес. Urdu: فوری بھوری لومڑی سست بوڑھے کتے پر کودتا. Vietnamese: Các con cáo nâu nhanh chóng nhảy qua con chó lười biếng cũ. -Welsh: Mae\'r cyflym frown llwynog neidio dros y ci hen ddiog. -Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.''') +Welsh: Mae'r cyflym frown llwynog neidio dros y ci hen ddiog. +Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.""") def dismiss_popup(self): self._popup.dismiss() diff --git a/kivy/adapters/args_converters.py b/kivy/adapters/args_converters.py index 386dbec79..e724ef08c 100755 --- a/kivy/adapters/args_converters.py +++ b/kivy/adapters/args_converters.py @@ -37,7 +37,7 @@ arguments via the *kwargs* keyword:: 'cls_dicts': [{'cls': ListItemButton, 'kwargs': {'text': rec['text']}}, {'cls': ListItemLabel, - 'kwargs': {'text': "Middle-{0}".format(rec['text']), + 'kwargs': {'text': rec['text'], 'is_representing_cls': True}}, {'cls': ListItemButton, 'kwargs': {'text': rec['text']}}]} diff --git a/kivy/adapters/listadapter.py b/kivy/adapters/listadapter.py index 0a31a135d..3b21e4d5e 100644 --- a/kivy/adapters/listadapter.py +++ b/kivy/adapters/listadapter.py @@ -248,8 +248,8 @@ class ListAdapter(Adapter, EventDispatcher): if item['is_selected']: self.handle_selection(view_instance) elif hasattr(item, 'is_selected'): - if (inspect.isfunction(item.is_selected) - or inspect.ismethod(item.is_selected)): + if (inspect.isfunction(item.is_selected) or + inspect.ismethod(item.is_selected)): if item.is_selected(): self.handle_selection(view_instance) else: @@ -331,8 +331,8 @@ class ListAdapter(Adapter, EventDispatcher): elif type(item) == dict: item['is_selected'] = value elif hasattr(item, 'is_selected'): - if (inspect.isfunction(item.is_selected) - or inspect.ismethod(item.is_selected)): + if (inspect.isfunction(item.is_selected) or + inspect.ismethod(item.is_selected)): item.is_selected() else: item.is_selected = value diff --git a/kivy/clock.py b/kivy/clock.py index 261af1648..f2b119de7 100644 --- a/kivy/clock.py +++ b/kivy/clock.py @@ -642,10 +642,10 @@ class ClockBaseInterruptBehavior(ClockBaseBehavior): return if not event.timeout or ( - not self.interupt_next_only and event.timeout - <= 1 / fps # remaining time - - (self.time() - self._last_tick) # elapsed time - + 4 / 5. * self.get_resolution()): # resolution fudge factor + not self.interupt_next_only and event.timeout <= + 1 / fps - # remaining time + (self.time() - self._last_tick) + # elapsed time + 4 / 5. * self.get_resolution()): # resolution fudge factor self._event.set() def idle(self): diff --git a/kivy/core/spelling/spelling_osxappkit.py b/kivy/core/spelling/spelling_osxappkit.py index df8d03167..2afda71be 100644 --- a/kivy/core/spelling/spelling_osxappkit.py +++ b/kivy/core/spelling/spelling_osxappkit.py @@ -57,7 +57,8 @@ class SpellingOSXAppKit(SpellingBase): except AttributeError: # From 10.6 onwards you're supposed to do it like this: checkrange = NSMakeRange(0, len(fragment)) - g = l.guessesForWordRange_inString_language_inSpellDocumentWithTag_( - checkrange, fragment, l.language(), 0) + g = l.\ + guessesForWordRange_inString_language_inSpellDocumentWithTag_( + checkrange, fragment, l.language(), 0) # Right, this was much easier, Apple! :-) return list(g) diff --git a/kivy/geometry.py b/kivy/geometry.py index ba4778804..e4443c515 100644 --- a/kivy/geometry.py +++ b/kivy/geometry.py @@ -35,8 +35,8 @@ def circumcircle(a, b, c): mPQ = (P + Q) * .5 mQR = (Q + R) * .5 - numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y - - mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x) + numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y - + mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x) denom = (-Q.x * R.y + P.x * R.y - P.x * Q.y + Q.y * R.x - P.y * R.x + P.y * Q.x) diff --git a/kivy/interactive.py b/kivy/interactive.py index 7332b764c..fceb9c876 100644 --- a/kivy/interactive.py +++ b/kivy/interactive.py @@ -242,8 +242,8 @@ class SafeMembrane(object): return SafeMembrane(r) def __setattr__(self, attr, val, osa=object.__setattr__): - if (attr == '_ref' - or hasattr(type(self), attr) and not attr.startswith('__')): + if (attr == '_ref' or + hasattr(type(self), attr) and not attr.startswith('__')): osa(self, attr, val) else: self.safeIn() diff --git a/kivy/lang/__init__.py b/kivy/lang/__init__.py index e337c1e3b..d3e06e4ca 100755 --- a/kivy/lang/__init__.py +++ b/kivy/lang/__init__.py @@ -857,7 +857,8 @@ will first be unloaded and then reloaded again. For example: ''' -from kivy.lang.builder import Observable, Builder, BuilderBase, BuilderException +from kivy.lang.builder import (Observable, Builder, BuilderBase, + BuilderException) from kivy.lang.parser import Parser, ParserException, global_idmap __all__ = ('Observable', 'Builder', 'BuilderBase', 'BuilderException', diff --git a/kivy/lang/builder.py b/kivy/lang/builder.py index 921228a2b..f2ae7eb68 100755 --- a/kivy/lang/builder.py +++ b/kivy/lang/builder.py @@ -707,25 +707,25 @@ class BuilderBase(object): .. code-block:: python - >>> w = Builder.load_string(\''' - ... Widget: - ... height: self.width / 2. if self.disabled else self.width - ... x: self.y + 50 - ... \''') - >>> w.size - [100, 100] - >>> w.pos - [50, 0] - >>> w.width = 500 - >>> w.size - [500, 500] - >>> Builder.unbind_widget(w.uid) - >>> w.width = 222 - >>> w.y = 500 - >>> w.size - [222, 500] - >>> w.pos - [50, 500] + >>> w = Builder.load_string(\''' + ... Widget: + ... height: self.width / 2. if self.disabled else self.width + ... x: self.y + 50 + ... \''') + >>> w.size + [100, 100] + >>> w.pos + [50, 0] + >>> w.width = 500 + >>> w.size + [500, 500] + >>> Builder.unbind_widget(w.uid) + >>> w.width = 222 + >>> w.y = 500 + >>> w.size + [222, 500] + >>> w.pos + [50, 500] .. versionadded:: 1.7.2 '''