Skip to content

Commit

Permalink
PEP8 style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Dec 24, 2016
1 parent a5af2b7 commit dea9279
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
20 changes: 11 additions & 9 deletions digitalocean_indicator/DoIndicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:///", '')
Expand All @@ -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:
Expand All @@ -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.")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions digitalocean_indicator/OAuthWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
self.hide()
6 changes: 3 additions & 3 deletions digitalocean_indicator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 12 additions & 13 deletions digitalocean_indicator_lib/Builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -96,18 +95,18 @@ 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)

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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions digitalocean_indicator_lib/PreferencesDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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.
"""

Expand All @@ -57,4 +57,3 @@ def finish_initializing(self, builder):

def on_btn_close_clicked(self, widget, data=None):
self.destroy()

1 change: 0 additions & 1 deletion digitalocean_indicator_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
while keeping its api constant'''
from . helpers import set_up_logging
from . digitalocean_indicatorconfig import get_version

2 changes: 1 addition & 1 deletion digitalocean_indicator_lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down

0 comments on commit dea9279

Please sign in to comment.