From dea9279c1870c6a8ea5310508aa2c7d5e7fa35bf Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Fri, 23 Dec 2016 22:07:44 -0500 Subject: [PATCH] PEP8 style fixes. --- digitalocean_indicator/DoIndicator.py | 20 ++++++++------- digitalocean_indicator/OAuthWindow.py | 4 +-- digitalocean_indicator/__init__.py | 6 ++--- digitalocean_indicator_lib/Builder.py | 25 +++++++++---------- .../PreferencesDialog.py | 5 ++-- digitalocean_indicator_lib/__init__.py | 1 - digitalocean_indicator_lib/helpers.py | 2 +- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/digitalocean_indicator/DoIndicator.py b/digitalocean_indicator/DoIndicator.py index e4b14e7..90fd38e 100644 --- a/digitalocean_indicator/DoIndicator.py +++ b/digitalocean_indicator/DoIndicator.py @@ -57,9 +57,10 @@ def __str__(self): class Indicator: def __init__(self, token=None): - self.indicator = AppIndicator3.Indicator.new('digitalocean-indicator', - '', - AppIndicator3.IndicatorCategory.APPLICATION_STATUS) + self.indicator = AppIndicator3.Indicator.new( + 'digitalocean-indicator', + '', + AppIndicator3.IndicatorCategory.APPLICATION_STATUS) self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) icon_uri = get_media_file("digitalocean-indicator.svg") icon_path = icon_uri.replace("file:///", '') @@ -86,7 +87,7 @@ def __init__(self, token=None): # Refresh menu every 10 min by default self.change_timeout = False self.interval = self.settings.get_int("refresh-interval") - GLib.timeout_add_seconds(self.interval*60, self.timeout_set) + GLib.timeout_add_seconds(self.interval * 60, self.timeout_set) def build_menu(self): try: @@ -98,9 +99,10 @@ def build_menu(self): msg = _("No network connection.") IndicatorError(e, msg, self) - except (digitalocean.baseapi.TokenError, digitalocean.baseapi.DataReadError), e: - msg = _("Please connect to your DigitalOcean account.") - IndicatorError(e, msg, self) + except (digitalocean.baseapi.TokenError, + digitalocean.baseapi.DataReadError), e: + msg = _("Please connect to your DigitalOcean account.") + IndicatorError(e, msg, self) except Exception, e: msg = _("Unable to reach the DigitalOcean API.") @@ -244,7 +246,7 @@ def build_droplet_details(self, droplet): def timeout_set(self): self.rebuild_menu() if self.change_timeout: - GLib.timeout_add_seconds(self.interval*60, self.timeout_set) + GLib.timeout_add_seconds(self.interval * 60, self.timeout_set) return False return True @@ -286,7 +288,7 @@ def on_preferences_changed(self, settings, key, data=None): if key == "refresh-interval": self.change_timeout = True self.interval = settings.get_int(key) - GLib.timeout_add_seconds(self.interval*60, self.timeout_set) + GLib.timeout_add_seconds(self.interval * 60, self.timeout_set) else: self.preferences_changed = True diff --git a/digitalocean_indicator/OAuthWindow.py b/digitalocean_indicator/OAuthWindow.py index 451945d..1bf2b4a 100644 --- a/digitalocean_indicator/OAuthWindow.py +++ b/digitalocean_indicator/OAuthWindow.py @@ -15,7 +15,7 @@ class AuthWin(Gtk.Dialog): def __init__(self, parent): Gtk.Dialog.__init__(self, "My Dialog", parent, 0, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) oauth_url = "{0}/authorize?response_type=token&client_id={1}&redirect_uri={2}&scope=read%20write".format( BASE_URL, CLIENT_ID, CALLBACK_URL) @@ -46,4 +46,4 @@ def navigation_callback(self, view, frame, request, action, decision): expires_in = res['expires_in'][0] access_token = res[CALLBACK_URL + '/#access_token'][0] self.settings.set_string("do-api-token", access_token) - self.hide() \ No newline at end of file + self.hide() diff --git a/digitalocean_indicator/__init__.py b/digitalocean_indicator/__init__.py index bb787ad..da707e6 100644 --- a/digitalocean_indicator/__init__.py +++ b/digitalocean_indicator/__init__.py @@ -29,9 +29,9 @@ def parse_options(): """Support for command line options""" parser = optparse.OptionParser(version="%%prog %s" % get_version()) - parser.add_option( - "-v", "--verbose", action="count", dest="verbose", - help=_("Show debug messages (-vv debugs digitalocean_indicator_lib also)")) + parser.add_option("-v", "--verbose", + action="count", dest="verbose", + help="Show debug messages") (options, args) = parser.parse_args() set_up_logging(options) diff --git a/digitalocean_indicator_lib/Builder.py b/digitalocean_indicator_lib/Builder.py index ab74b93..dfe2e49 100644 --- a/digitalocean_indicator_lib/Builder.py +++ b/digitalocean_indicator_lib/Builder.py @@ -53,8 +53,7 @@ def __init__(self): # pylint: disable=R0201 # this is a method so that a subclass of Builder can redefine it - def default_handler(self, - handler_name, filename, *args, **kwargs): + def default_handler(self, handler_name, filename, *args, **kwargs): '''helps the apprentice guru glade defined handlers that do not exist come here instead. @@ -96,10 +95,10 @@ def add_from_file(self, filename): # populate connections list ele_signals = ele_widget.findall("signal") - connections = [ - (name, - ele_signal.attrib['name'], - ele_signal.attrib['handler']) for ele_signal in ele_signals] + connections = [(name, + ele_signal.attrib['name'], + ele_signal.attrib['handler']) + for ele_signal in ele_signals] if connections: self.connections.extend(connections) @@ -107,7 +106,7 @@ def add_from_file(self, filename): ele_signals = tree.getiterator("signal") for ele_signal in ele_signals: self.glade_handler_dict.update( - {ele_signal.attrib["handler"]: None}) + {ele_signal.attrib["handler"]: None}) def connect_signals(self, callback_obj): '''connect the handlers defined in glade @@ -129,7 +128,7 @@ def connect_signals(self, callback_obj): # replace the run time warning logger.warn("expected handler '%s' in %s", - item[0], filename) + item[0], filename) # connect glade define handlers Gtk.Builder.connect_signals(self, connection_dict) @@ -138,7 +137,7 @@ def connect_signals(self, callback_obj): for connection in self.connections: widget_name, signal_name, handler_name = connection logger.debug("connect builder by design '%s', '%s', '%s'", - widget_name, signal_name, handler_name) + widget_name, signal_name, handler_name) def get_ui(self, callback_obj=None, by_name=True): '''Creates the ui object with widgets as attributes @@ -174,7 +173,7 @@ def __init__(self, widget_dict): cannot_message = """cannot bind ui.%s, name already exists consider using a pythonic name instead of design name '%s'""" consider_message = """consider using a pythonic name instead of design name '%s'""" - + for (widget_name, widget) in widget_dict.items(): pyname = make_pyname(widget_name) if pyname != widget_name: @@ -284,13 +283,13 @@ def auto_connect_by_name(callback_obj, builder): handler_names.append("on_%s" % sig) do_connect(item, sig, handler_names, - callback_handler_dict, builder.connections) + callback_handler_dict, builder.connections) log_unconnected_functions(callback_handler_dict, builder.connections) def do_connect(item, signal_name, handler_names, - callback_handler_dict, connections): + callback_handler_dict, connections): '''connect this signal to an unused handler''' widget_name, widget = item @@ -303,7 +302,7 @@ def do_connect(item, signal_name, handler_names, connections.append(connection) logger.debug("connect builder by name '%s','%s', '%s'", - widget_name, signal_name, handler_name) + widget_name, signal_name, handler_name) def log_unconnected_functions(callback_handler_dict, connections): diff --git a/digitalocean_indicator_lib/PreferencesDialog.py b/digitalocean_indicator_lib/PreferencesDialog.py index a28d5c5..5a3943e 100644 --- a/digitalocean_indicator_lib/PreferencesDialog.py +++ b/digitalocean_indicator_lib/PreferencesDialog.py @@ -30,7 +30,7 @@ class PreferencesDialog(Gtk.Dialog): def __new__(cls): """Special static method that's automatically called by Python when constructing a new instance of this class. - + Returns a fully instantiated PreferencesDialog object. """ builder = get_builder('PreferencesDigitaloceanIndicatorDialog') @@ -45,7 +45,7 @@ def finish_initializing(self, builder): and creating a PreferencesDialog object with it in order to finish initializing the start of the new PerferencesDigitaloceanIndicatorDialog instance. - + Put your initialization code in here and leave __init__ undefined. """ @@ -57,4 +57,3 @@ def finish_initializing(self, builder): def on_btn_close_clicked(self, widget, data=None): self.destroy() - diff --git a/digitalocean_indicator_lib/__init__.py b/digitalocean_indicator_lib/__init__.py index 0aa33bd..1a31cb5 100644 --- a/digitalocean_indicator_lib/__init__.py +++ b/digitalocean_indicator_lib/__init__.py @@ -20,4 +20,3 @@ while keeping its api constant''' from . helpers import set_up_logging from . digitalocean_indicatorconfig import get_version - diff --git a/digitalocean_indicator_lib/helpers.py b/digitalocean_indicator_lib/helpers.py index 22f44f7..f3ac688 100644 --- a/digitalocean_indicator_lib/helpers.py +++ b/digitalocean_indicator_lib/helpers.py @@ -27,7 +27,7 @@ def get_builder(builder_file_name): """Return a fully-instantiated Gtk.Builder instance from specified ui file - + :param builder_file_name: The name of the builder file, without extension. Assumed to be in the 'ui' directory under the data path. """