summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__main__.py2
-rw-r--r--ranger/actions.py1
-rw-r--r--ranger/fm.py55
-rw-r--r--ranger/gui/colorscheme.py2
-rw-r--r--ranger/gui/curses_shortcuts.py12
-rw-r--r--ranger/gui/defaultui.py2
-rw-r--r--ranger/gui/displayable.py20
-rw-r--r--ranger/gui/mouse_event.py1
-rw-r--r--ranger/gui/widgets/__init__.py3
-rw-r--r--ranger/gui/widgets/console.py11
-rw-r--r--ranger/gui/widgets/statusbar.py2
-rw-r--r--ranger/gui/widgets/taskview.py2
-rw-r--r--ranger/gui/widgets/titlebar.py3
13 files changed, 60 insertions, 56 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index ba41e5c9..24cf62c1 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -17,7 +17,6 @@
 
 import os
 import sys
-from signal import signal, SIGINT
 
 def main():
 	"""initialize objects and run the filemanager"""
@@ -28,6 +27,7 @@ def main():
 		print('ranger requires the python curses module. Aborting.')
 		sys.exit(1)
 
+	from signal import signal, SIGINT
 	from locale import setlocale, LC_ALL
 	from optparse import OptionParser, SUPPRESS_HELP
 
diff --git a/ranger/actions.py b/ranger/actions.py
index b04c717a..a881f7c2 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -19,7 +19,6 @@ from inspect import cleandoc
 from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
 from ranger.gui.widgets import console_mode as cmode
-
 from ranger.applications import run
 
 class Actions(EnvironmentAware, SettingsAware):
diff --git a/ranger/fm.py b/ranger/fm.py
index df2cb15f..3471dcd4 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -84,35 +84,32 @@ class FM(Actions):
 
 		try:
 			while True:
-				try:
-					self.bookmarks.update_if_outdated()
-					self.loader.work()
-					if hasattr(self.ui, 'throbber'):
-						if self.loader.has_work():
-							self.ui.throbber(self.loader.status)
-						else:
-							self.ui.throbber(remove=True)
-
-					self.ui.redraw()
-
-					self.ui.set_load_mode(self.loader.has_work())
-
-					key = self.ui.get_next_key()
-
-					if key > 0:
-						if self.input_blocked and \
-								time() > self.input_blocked_until:
-							self.input_blocked = False
-						if not self.input_blocked:
-							self.ui.handle_key(key)
-
-					gc_tick += 1
-					if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE:
-						gc_tick = 0
-						self.env.garbage_collect()
-
-				finally:
-					pass
+				self.bookmarks.update_if_outdated()
+				self.loader.work()
+				if hasattr(self.ui, 'throbber'):
+					if self.loader.has_work():
+						self.ui.throbber(self.loader.status)
+					else:
+						self.ui.throbber(remove=True)
+
+				self.ui.redraw()
+
+				self.ui.set_load_mode(self.loader.has_work())
+
+				key = self.ui.get_next_key()
+
+				if key > 0:
+					if self.input_blocked and \
+							time() > self.input_blocked_until:
+						self.input_blocked = False
+					if not self.input_blocked:
+						self.ui.handle_key(key)
+
+				gc_tick += 1
+				if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE:
+					gc_tick = 0
+					self.env.garbage_collect()
+
 		finally:
 			self.bookmarks.remember(self.env.pwd)
 			self.bookmarks.save()
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index 6368fb05..70961e02 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -42,7 +42,7 @@ colorscheme = colorschemes.filename.classname
 
 from ranger.ext.openstruct import OpenStruct
 
-CONTEXT_KEYS = [ 'reset', 'error',
+CONTEXT_KEYS = ['reset', 'error',
 		'in_browser', 'in_statusbar', 'in_titlebar', 'in_console',
 		'in_pager', 'in_taskview',
 		'directory', 'file', 'hostname',
diff --git a/ranger/gui/curses_shortcuts.py b/ranger/gui/curses_shortcuts.py
index 10e6a3cd..4e02fca5 100644
--- a/ranger/gui/curses_shortcuts.py
+++ b/ranger/gui/curses_shortcuts.py
@@ -12,11 +12,11 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-from ranger.shared import SettingsAware
 import _curses
 
-class CursesShortcuts(SettingsAware):
+from ranger.shared import SettingsAware
 
+class CursesShortcuts(SettingsAware):
 	"""
 	This class defines shortcuts to faciliate operations with curses.
 	color(*keys) -- sets the color associated with the keys from
@@ -40,7 +40,7 @@ class CursesShortcuts(SettingsAware):
 
 	def color(self, keylist = None, *keys):
 		"""Change the colors from now on."""
-		keys = combine(keylist, keys)
+		keys = _combine(keylist, keys)
 		attr = self.settings.colorscheme.get_attr(*keys)
 		try:
 			self.win.attrset(attr)
@@ -49,7 +49,7 @@ class CursesShortcuts(SettingsAware):
 
 	def color_at(self, y, x, wid, keylist = None, *keys):
 		"""Change the colors at the specified position"""
-		keys = combine(keylist, keys)
+		keys = _combine(keylist, keys)
 		attr = self.settings.colorscheme.get_attr(*keys)
 		try:
 			self.win.chgat(y, x, wid, attr)
@@ -60,8 +60,8 @@ class CursesShortcuts(SettingsAware):
 		"""Change the colors to the default colors"""
 		CursesShortcuts.color(self, 'reset')
 
-def combine(seq, tup):
-	"""Add seq and tup. Ensures that the result is a tuple."""
+def _combine(seq, tup):
+	# Add seq and tup. Ensures that the result is a tuple.
 	try:
 		if isinstance(seq, str): raise TypeError
 		return tuple(tuple(seq) + tup)
diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py
index 7985dfc9..ebebe638 100644
--- a/ranger/gui/defaultui.py
+++ b/ranger/gui/defaultui.py
@@ -12,10 +12,10 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
+from ranger.gui.ui import UI
 
 RATIO = ( 3, 3, 12, 9 )
 
-from ranger.gui.ui import UI
 class DefaultUI(UI):
 	def setup(self):
 		"""Build up the UI by initializing widgets."""
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 54596389..5c46a0dc 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -12,13 +12,12 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-from ranger.shared import FileManagerAware, EnvironmentAware
-from ranger.gui.curses_shortcuts import CursesShortcuts
 import _curses
 
+from ranger.shared import FileManagerAware, EnvironmentAware
+from ranger.gui.curses_shortcuts import CursesShortcuts
 
 class Displayable(EnvironmentAware, FileManagerAware, CursesShortcuts):
-
 	"""
 	Displayables are objects which are displayed on the screen.
 
@@ -86,7 +85,8 @@ class Displayable(EnvironmentAware, FileManagerAware, CursesShortcuts):
 		return True
 
 	def __contains__(self, item):
-		"""Is item inside the boundaries?
+		"""
+		Is item inside the boundaries?
 		item can be an iterable like [y, x] or an object with x and y methods.
 		"""
 		try:
@@ -107,7 +107,8 @@ class Displayable(EnvironmentAware, FileManagerAware, CursesShortcuts):
 		"""
 
 	def destroy(self):
-		"""Called when the object is destroyed.
+		"""
+		Called when the object is destroyed.
 		Override this!
 		"""
 
@@ -120,13 +121,15 @@ class Displayable(EnvironmentAware, FileManagerAware, CursesShortcuts):
 				(y >= self.y and y < self.y + self.hei)
 
 	def click(self, event):
-		"""Called when a mouse key is pressed and self.focused is True.
+		"""
+		Called when a mouse key is pressed and self.focused is True.
 		Override this!
 		"""
 		pass
 
 	def press(self, key):
-		"""Called when a key is pressed and self.focused is True.
+		"""
+		Called when a key is pressed and self.focused is True.
 		Override this!
 		"""
 		pass
@@ -141,7 +144,8 @@ class Displayable(EnvironmentAware, FileManagerAware, CursesShortcuts):
 				self.win.erase()
 	
 	def finalize(self):
-		"""Called after every displayable is done drawing.
+		"""
+		Called after every displayable is done drawing.
 		Override this!
 		"""
 		pass
diff --git a/ranger/gui/mouse_event.py b/ranger/gui/mouse_event.py
index 7c2aa577..b500a5c6 100644
--- a/ranger/gui/mouse_event.py
+++ b/ranger/gui/mouse_event.py
@@ -13,6 +13,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 import curses
+
 class MouseEvent(object):
 	PRESSED = [ 0,
 			curses.BUTTON1_PRESSED,
diff --git a/ranger/gui/widgets/__init__.py b/ranger/gui/widgets/__init__.py
index 04f6aacc..3ec387be 100644
--- a/ranger/gui/widgets/__init__.py
+++ b/ranger/gui/widgets/__init__.py
@@ -15,6 +15,7 @@
 from ranger.gui.displayable import Displayable
 
 class Widget(Displayable):
-	"""The Widget class defines no methods and only exists for
+	"""
+	The Widget class defines no methods and only exists for
 	classification of widgets.
 	"""
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index d3b6138b..90192bee 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -15,20 +15,21 @@
 """The Console widget implements a vim-like console for entering
 commands, searching and executing files."""
 import string
+import curses
+from collections import deque
+
 from . import Widget
 from ranger import commands
 from ranger.gui.widgets.console_mode import is_valid_mode, mode_to_class
 from ranger import log
 from ranger.ext.shell_escape import shell_escape
-import curses
-from collections import deque
 
 DEFAULT_HISTORY = 0
 SEARCH_HISTORY = 1
 QUICKOPEN_HISTORY = 2
 OPEN_HISTORY = 3
 
-class CustomTemplate(string.Template):
+class _CustomTemplate(string.Template):
 	"""A string.Template subclass for use in the OpenConsole"""
 	delimiter = '%'
 	idpattern = '[a-z]'
@@ -364,7 +365,7 @@ class OpenConsole(ConsoleWithTab):
 		from subprocess import STDOUT, PIPE
 		command, flags = self._parse()
 		if command:
-			if CustomTemplate.delimiter in command:
+			if _CustomTemplate.delimiter in command:
 				command = self._substitute_metachars(command)
 			log(command)
 			self.fm.execute_command(command, flags=flags)
@@ -385,7 +386,7 @@ class OpenConsole(ConsoleWithTab):
 		dct['s'] = ' '.join(shell_escape(fl.basename) \
 				for fl in self.fm.env.get_selection())
 
-		return CustomTemplate(command).safe_substitute(dct)
+		return _CustomTemplate(command).safe_substitute(dct)
 	
 	def _parse(self):
 		if '!' in self.line:
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index a68b0454..0fcab000 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -20,12 +20,12 @@ print for the current file.  The right side shows directory information
 such as the space used by all the files in this directory.
 """
 
-from . import Widget
 from pwd import getpwuid
 from grp import getgrgid
 from os import getuid
 from time import strftime, localtime
 
+from . import Widget
 from ranger.gui.bar import Bar
 
 class StatusBar(Widget):
diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py
index f9ea4d89..909577d8 100644
--- a/ranger/gui/widgets/taskview.py
+++ b/ranger/gui/widgets/taskview.py
@@ -17,11 +17,11 @@ The TaskView allows you to modify what the loader is doing.
 """
 
 import curses
+from collections import deque
 
 from . import Widget
 from ranger.ext.accumulator import Accumulator
 from ranger.container import CommandList
-from collections import deque
 
 class TaskView(Widget, Accumulator):
 	old_lst = None
diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py
index 0046d9c2..b702b3e7 100644
--- a/ranger/gui/widgets/titlebar.py
+++ b/ranger/gui/widgets/titlebar.py
@@ -18,8 +18,9 @@ The titlebar is the widget at the top, giving you broad orientation.
 It displays the current path among other things.
 """
 
-from . import Widget
 from math import floor
+
+from . import Widget
 from ranger.gui.bar import Bar
 
 class TitleBar(Widget):