Skip to content

Commit

Permalink
PEP up more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Letiliel committed Jun 21, 2014
1 parent 97000f2 commit 11c43f9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lutris/game.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding:Utf-8 -*-
""" Module that actually runs the games. """
"""Module that actually runs the games."""
import os
import time
import shutil
Expand Down
14 changes: 7 additions & 7 deletions lutris/gui/config_dialogs.py
@@ -1,4 +1,4 @@
""" Configuration dialogs """
"""Configuration dialogs"""
from gi.repository import Gtk

from lutris.config import LutrisConfig
Expand Down Expand Up @@ -99,11 +99,11 @@ def build_action_area(self, label, button_callback):
self.action_area.pack_start(button, True, True, 0)

def on_cancel_clicked(self, widget=None):
"""Dialog destroy callback"""
"""Dialog destroy callback."""
self.destroy()

def on_save(self, _button):
"""OK button pressed in the Add Game Dialog"""
"""OK button pressed in the Add Game Dialog."""
name = self.name_entry.get_text()
self.lutris_config.config["realname"] = name
self.lutris_config.config["runner"] = self.runner_name
Expand All @@ -122,7 +122,7 @@ def on_save(self, _button):


class AddGameDialog(Gtk.Dialog, GameDialogCommon):
"""Add game dialog class"""
"""Add game dialog class."""

def __init__(self, parent, game=None):
super(AddGameDialog, self).__init__()
Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(self, parent, game=None):
self.run()

def on_runner_changed(self, widget):
"""Action called when runner drop down is changed"""
"""Action called when runner drop down is changed."""
runner_index = widget.get_active()
current_page = self.notebook.get_current_page()
self.clear_tabs()
Expand All @@ -172,7 +172,7 @@ def on_runner_changed(self, widget):


class EditGameConfigDialog(Gtk.Dialog, GameDialogCommon):
"""Game config edit dialog"""
"""Game config edit dialog."""
def __init__(self, parent, game):
super(EditGameConfigDialog, self).__init__()
self.parent_window = parent
Expand All @@ -195,7 +195,7 @@ def __init__(self, parent, game):


class RunnerConfigDialog(Gtk.Dialog):
"""Runners management dialog"""
"""Runners management dialog."""
def __init__(self, runner):
Gtk.Dialog.__init__(self)
runner_name = runner.__class__.__name__
Expand Down
34 changes: 17 additions & 17 deletions lutris/gui/lutriswindow.py
@@ -1,4 +1,4 @@
""" Main window for the Lutris interface """
"""Main window for the Lutris interface."""
# pylint: disable=E0611
import os
import subprocess
Expand Down Expand Up @@ -40,7 +40,7 @@ def load_view(view, games=[], filter_text=None, icon_type=None):


class LutrisWindow(object):
"""Handler class for main window signals"""
"""Handler class for main window signals."""
def __init__(self):

ui_filename = os.path.join(
Expand Down Expand Up @@ -168,7 +168,7 @@ def sync_icons(self):
callback=self.on_image_downloaded)

def connect_signals(self):
"""Connects signals from the view with the main window.
"""Connect signals from the view with the main window.
This must be called each time the view is rebuilt.
"""
self.view.connect('game-installed', self.on_game_installed)
Expand All @@ -177,7 +177,7 @@ def connect_signals(self):
self.window.connect("configure-event", self.get_size)

def get_icon_type(self, view_type):
"""Returns the icon style depending on the type of view"""
"""Return the icon style depending on the type of view."""
if view_type == 'icon':
icon_type = settings.read_setting('icon_type_iconview')
default = settings.ICON_TYPE_ICONVIEW
Expand All @@ -192,7 +192,7 @@ def get_size(self, widget, _):
self.window_size = widget.get_size()

def refresh_status(self):
"""Refresh status bar"""
"""Refresh status bar."""
if self.running_game:
if hasattr(self.running_game.game_thread, "pid"):
pid = self.running_game.game_thread.pid
Expand All @@ -215,7 +215,7 @@ def refresh_status(self):
return True

def about(self, _widget, _data=None):
"""Opens the about dialog"""
"""Open the about dialog."""
dialogs.AboutDialog()

def on_remove_game(self, _widget, _data=None):
Expand All @@ -231,7 +231,7 @@ def on_game_deleted(self, game_slug, from_library=False):

# Callbacks
def on_connect(self, *args):
"""Callback when a user connects to his account"""
"""Callback when a user connects to his account."""
login_dialog = dialogs.ClientLoginDialog()
login_dialog.connect('connected', self.on_connect_success)

Expand All @@ -241,7 +241,7 @@ def on_connect_success(self, dialog, token):
self.sync_library()

def on_destroy(self, *args):
"""Signal for window close"""
"""Signal for window close."""
view_type = 'icon' if 'IconView' in str(type(self.view)) else 'list'
settings.write_setting('view_type', view_type)
width, height = self.window_size
Expand All @@ -254,11 +254,11 @@ def on_game_installed(self, widget, slug):
widget.update_image(slug, is_installed=True)

def on_runners_activate(self, _widget, _data=None):
"""Callback when manage runners is activated"""
"""Callback when manage runners is activated."""
RunnersDialog()

def on_preferences_activate(self, _widget, _data=None):
"""Callback when preferences is activated"""
"""Callback when preferences is activated."""
SystemConfigDialog()

def on_show_installed_games_toggled(self, widget, data=None):
Expand All @@ -280,7 +280,7 @@ def on_search_entry_changed(self, widget):
self.view.emit('filter-updated', widget.get_text())

def on_game_clicked(self, *args):
"""Launch a game"""
"""Launch a game."""
game_slug = self.view.selected_game
if game_slug:
self.running_game = Game(game_slug)
Expand All @@ -305,7 +305,7 @@ def set_library_synced(result, error):
)

def reset(self, *args):
"""Reset the desktop to it's initial state"""
"""Reset the desktop to it's initial state."""
if self.running_game:
self.running_game.quit_game()
self.status_label.set_text("Stopped %s" % self.running_game.name)
Expand All @@ -328,7 +328,7 @@ def do_add_game():
GLib.idle_add(do_add_game)

def add_game(self, _widget, _data=None):
""" Add a new game """
"""Add a new game."""
add_game_dialog = AddGameDialog(self)
if add_game_dialog.runner_name and add_game_dialog.slug:
self.add_game_to_view(add_game_dialog.slug)
Expand All @@ -350,7 +350,7 @@ def on_browse_files(self, widget):
)

def edit_game_configuration(self, _button):
"""Edit game preferences"""
"""Edit game preferences."""
game = Game(self.view.selected_game)
if game.is_installed:
EditGameConfigDialog(self, self.view.selected_game)
Expand All @@ -372,7 +372,7 @@ def on_viewbtn_toggled(self, widget):
self.list_view_menuitem.set_active(view_type == 'list')

def switch_view(self, view_type):
"""Switches between icon view and list view"""
"""Switche between icon view and list view."""
logger.debug("Switching view")
self.icon_type = self.get_icon_type(view_type)
self.view.destroy()
Expand Down Expand Up @@ -407,14 +407,14 @@ def on_icon_type_activate(self, menuitem):
self.switch_view(self.current_view_type)

def create_menu_shortcut(self, *args):
"""Adds the game to the system's Games menu"""
"""Add the game to the system's Games menu."""
game_slug = slugify(self.view.selected_game)
create_launcher(game_slug, menu=True)
dialogs.NoticeDialog(
"Shortcut added to the Games category of the global menu.")

def create_desktop_shortcut(self, *args):
"""Adds the game to the system's Games menu"""
"""Add the game to the system's Games menu."""
game_slug = slugify(self.view.selected_game)
create_launcher(game_slug, desktop=True)
dialogs.NoticeDialog('Shortcut created on your desktop.')
12 changes: 6 additions & 6 deletions lutris/gui/widgets.py
Expand Up @@ -27,7 +27,7 @@


def sort_func(store, a_iter, b_iter, _user_data):
"""Default sort function"""
"""Default sort function."""
a_name = store.get(a_iter, COL_NAME)
b_name = store.get(b_iter, COL_NAME)

Expand All @@ -40,7 +40,7 @@ def sort_func(store, a_iter, b_iter, _user_data):


def filter_view(model, _iter, user_data):
"""Filter the game list"""
"""Filter the game list."""
filter_text = user_data(None)
if not filter_text:
return True
Expand Down Expand Up @@ -154,7 +154,7 @@ def fill_store(self, games):
self.add_game(game)

def add_game(self, game):
"""Adds a game into the store """
"""Add a game into the store."""
if not game.name:
return
pixbuf = get_pixbuf_for_game(game.slug, self.icon_type,
Expand Down Expand Up @@ -219,7 +219,7 @@ def update_image(self, game_slug, is_installed=False):
row[COL_INSTALLED] = is_installed

def popup_contextual_menu(self, view, event):
"""Contextual menu"""
"""Contextual menu."""
if event.button != 3:
return
try:
Expand All @@ -235,7 +235,7 @@ def popup_contextual_menu(self, view, event):


class GameTreeView(Gtk.TreeView, GameView):
"""Show the main list of games"""
"""Show the main list of games."""
__gsignals__ = GameView.__gsignals__

def __init__(self, games, filter_text="", icon_type=None):
Expand Down Expand Up @@ -330,7 +330,7 @@ def set_fluid_columns(self, width):
self.set_columns(nb_columns)

def on_size_allocate(self, widget, rect):
""" Recalculate the colum spacing based on total widget width """
"""Recalculate the colum spacing based on total widget width."""
width = self.get_parent().get_allocated_width()
self.set_fluid_columns(width - 20)
self.do_size_allocate(widget, rect)
Expand Down
20 changes: 10 additions & 10 deletions lutris/runners/runner.py
@@ -1,5 +1,5 @@
# -*- coding:Utf-8 -*-
"""Generic runner"""
"""Generic runner."""
import os
import subprocess
import platform
Expand All @@ -21,7 +21,7 @@ def get_arch():


class Runner(object):
"""Generic runner (base class for other runners)"""
"""Generic runner (base class for other runners)."""
is_watchable = True # Is the game's pid a parent of Lutris ?
tarballs = {
'i386': None,
Expand All @@ -32,7 +32,7 @@ class Runner(object):
runner_options = []

def __init__(self, settings=None):
"""Initialize runner"""
"""Initialize runner."""
self.game = None
self.depends = None
self.arch = get_arch()
Expand All @@ -41,12 +41,12 @@ def __init__(self, settings=None):

@property
def description(self):
"""Return the class' docstring as the description"""
"""Return the class' docstring as the description."""
return self.__doc__

@description.setter
def description(self, value):
"""Leave the ability to override the docstring"""
"""Leave the ability to override the docstring."""
self.__doc__ = value

@property
Expand Down Expand Up @@ -83,12 +83,12 @@ def system_config(self):

@property
def default_path(self):
"""Return the default path where games are installed"""
"""Return the default path where games are installed."""
return self.system_config.get('game_path')

@property
def browse_dir(self):
"""Return the directory shown when the user browse game files"""
"""Return the directory shown when the user browse game files."""
return self.get_game_path()

@property
Expand All @@ -101,7 +101,7 @@ def load(self, game):
self.game = game

def play(self):
"""dummy method, must be implemented by derived runnners"""
"""Dummy method, must be implemented by derived runnners."""
raise NotImplementedError("Implement the play method in your runner")

def check_depends(self):
Expand All @@ -120,7 +120,7 @@ def check_depends(self):
return runner_instance.is_installed()

def is_installed(self):
"""Return True if runner is installed else False"""
"""Return True if runner is installed else False."""
is_installed = False
# Check 'get_executable' first
if hasattr(self, 'get_executable'):
Expand All @@ -146,7 +146,7 @@ def get_game_path(self):
return self.system_config.get('game_path')

def install(self):
""" Install runner using package management systems."""
"""Install runner using package management systems."""
# Prioritize provided tarballs.
tarball = self.tarballs.get(self.arch)
if tarball:
Expand Down

0 comments on commit 11c43f9

Please sign in to comment.