diff options
author | Arisu <arisu@styl.us.to> | 2011-10-10 15:05:13 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-10-10 15:46:14 +0200 |
commit | bed99432cccb3eaae263c1c77e91fb4bb165cf6b (patch) | |
tree | 63513c947ae2ea0ef17fe62abc2d243031a0f89c | |
parent | 0dbd3faa556ce5c2cb38cc6937fb0c8f98d3656b (diff) | |
download | ranger-bed99432cccb3eaae263c1c77e91fb4bb165cf6b.tar.gz |
Eliminate orphaned and redundant definitions of variables and imports
-rw-r--r-- | ranger/api/commands.py | 6 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/core/helper.py | 4 | ||||
-rw-r--r-- | ranger/core/loader.py | 2 | ||||
-rw-r--r-- | ranger/defaults/commands.py | 6 | ||||
-rw-r--r-- | ranger/ext/relative_symlink.py | 1 | ||||
-rw-r--r-- | ranger/ext/signals.py | 10 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 6 | ||||
-rw-r--r-- | ranger/fsobject/file.py | 2 | ||||
-rw-r--r-- | ranger/fsobject/fsobject.py | 5 | ||||
-rw-r--r-- | ranger/gui/bar.py | 4 | ||||
-rw-r--r-- | ranger/gui/colorscheme.py | 2 | ||||
-rw-r--r-- | ranger/gui/displayable.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 1 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 1 | ||||
-rw-r--r-- | ranger/gui/widgets/taskview.py | 1 |
16 files changed, 13 insertions, 42 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py index f984342c..74a8ff99 100644 --- a/ranger/api/commands.py +++ b/ranger/api/commands.py @@ -39,7 +39,7 @@ class CommandContainer(object): pass def load_commands_from_module(self, module): - for varname, var in vars(module).items(): + for var in vars(module).values(): try: if issubclass(var, Command) and var != Command \ and var != FunctionCommand: @@ -162,7 +162,7 @@ class Command(FileManagerAware): # COMPAT: this is still used in old commands.py configs def _tab_only_directories(self): - from os.path import dirname, basename, expanduser, join, isdir + from os.path import dirname, basename, expanduser, join line = parse(self.line) cwd = self.fm.env.cwd.path @@ -211,7 +211,7 @@ class Command(FileManagerAware): return (line.start(1) + join(rel_dirname, dirname) for dirname in dirnames) def _tab_directory_content(self): - from os.path import dirname, basename, expanduser, join, isdir + from os.path import dirname, basename, expanduser, join line = parse(self.line) cwd = self.fm.env.cwd.path diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 02e0f9b7..09b86a0f 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -28,7 +28,6 @@ from ranger.ext.direction import Direction from ranger.ext.relative_symlink import relative_symlink from ranger.ext.keybinding_parser import key_to_string, construct_keybinding from ranger.ext.shell_escape import shell_quote -from ranger import fsobject from ranger.core.shared import FileManagerAware, EnvironmentAware, \ SettingsAware from ranger.fsobject import File @@ -803,7 +802,6 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): self.run(app='pager', files=[File(temporary_file.name)]) def dump_commands(self): - from inspect import cleandoc temporary_file = tempfile.NamedTemporaryFile() def write(string): temporary_file.write(string.encode('utf-8')) diff --git a/ranger/core/helper.py b/ranger/core/helper.py index a4c56712..c090a09f 100644 --- a/ranger/core/helper.py +++ b/ranger/core/helper.py @@ -22,7 +22,7 @@ from ranger import * def parse_arguments(): """Parse the program arguments""" - from optparse import OptionParser, SUPPRESS_HELP + from optparse import OptionParser from ranger import __version__ from ranger.ext.openstruct import OpenStruct from os.path import expanduser @@ -130,7 +130,7 @@ def load_settings(fm, clean): if not os.path.exists(fm.confpath('plugins', '__init__.py')): f = open(fm.confpath('plugins', '__init__.py'), 'w') f.close() - import types + ranger.fm = fm for plugin in sorted(plugins): try: diff --git a/ranger/core/loader.py b/ranger/core/loader.py index d063148b..018a31df 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -16,10 +16,8 @@ from collections import deque from time import time, sleep from subprocess import Popen, PIPE -from time import time from ranger.core.shared import FileManagerAware from ranger.ext.signals import SignalDispatcher -import math import os import sys import select diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index 504ec5c8..55de33c1 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -97,7 +97,7 @@ class cd(Command): self.fm.cd(destination) def tab(self): - from os.path import dirname, basename, expanduser, join, isdir + from os.path import dirname, basename, expanduser, join line = parse(self.line) cwd = self.fm.env.cwd.path @@ -189,10 +189,8 @@ class shell(Command): def tab(self): line = parse(self.line) if line.chunk(1) and line.chunk(1)[0] == '-': - flags = line.chunk(1)[1:] command = line.rest(2) else: - flags = '' command = line.rest(1) start = self.line[0:len(self.line) - len(command)] @@ -610,7 +608,6 @@ class touch(Command): def execute(self): from os.path import join, expanduser, lexists - from os import mkdir line = parse(self.line) fname = join(self.fm.env.cwd.path, expanduser(line.rest(1))) @@ -689,7 +686,6 @@ class rename(Command): def execute(self): from ranger.fsobject import File from os import access - from os.path import join line = parse(self.line) new_name = line.rest(1) diff --git a/ranger/ext/relative_symlink.py b/ranger/ext/relative_symlink.py index bba00e39..62f18a4f 100644 --- a/ranger/ext/relative_symlink.py +++ b/ranger/ext/relative_symlink.py @@ -14,7 +14,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from os import symlink, sep -from os.path import dirname, join def relative_symlink(src, dst): common_base = get_common_base(src, dst) diff --git a/ranger/ext/signals.py b/ranger/ext/signals.py index d885dd06..b318036f 100644 --- a/ranger/ext/signals.py +++ b/ranger/ext/signals.py @@ -153,15 +153,13 @@ class SignalDispatcher(object): handlers = self._signals[signal_name] = [] nargs = function.__code__.co_argcount - try: - instance = function.__self__ - except: - if weak: - function = weakref.proxy(function) - else: + if getattr(function, '__self__', None): nargs -= 1 if weak: function = (function.__func__, weakref.proxy(function.__self__)) + elif weak: + function = weakref.proxy(function) + handler = SignalHandler(signal_name, function, priority, nargs > 0) handlers.append(handler) handlers.sort(key=lambda handler: -handler._priority) diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 6b4a66f1..bd652655 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -14,20 +14,16 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os.path -import stat -from stat import S_ISLNK, S_ISDIR from os import stat as os_stat, lstat as os_lstat -from os.path import join, isdir, basename from collections import deque from time import time from ranger.core.loader import Loadable from ranger.ext.mount_path import mount_path -from ranger.fsobject import BAD_INFO, File, FileSystemObject +from ranger.fsobject import File, FileSystemObject from ranger.core.shared import SettingsAware from ranger.ext.accumulator import Accumulator from ranger.ext.lazy_property import lazy_property -import ranger.fsobject def sort_by_basename(path): """returns path.basename (for sorting)""" diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py index c24b560f..3acd70f2 100644 --- a/ranger/fsobject/file.py +++ b/ranger/fsobject/file.py @@ -15,8 +15,6 @@ import re from ranger.fsobject import FileSystemObject -from subprocess import Popen, PIPE -from ranger.core.loader import CommandLoader N_FIRST_BYTES = 256 control_characters = set(chr(n) for n in diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 647b7604..84b07e61 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -18,10 +18,8 @@ CONTAINER_EXTENSIONS = ('7z', 'ace', 'ar', 'arc', 'bz', 'bz2', 'cab', 'cpio', 'shar', 'tar', 'tbz', 'tgz', 'xar', 'xpi', 'xz', 'zip') import re -from os import access, listdir, lstat, readlink, stat -from time import time +from os import lstat, stat from os.path import abspath, basename, dirname, realpath, splitext, extsep -from . import BAD_INFO from ranger.core.shared import FileManagerAware from ranger.ext.shell_escape import shell_escape from ranger.ext.spawn import spawn @@ -65,7 +63,6 @@ class FileSystemObject(FileManagerAware): media, video) = (False,) * 21 - mimetype_tuple = () size = 0 diff --git a/ranger/gui/bar.py b/ranger/gui/bar.py index f2b1571a..c9502024 100644 --- a/ranger/gui/bar.py +++ b/ranger/gui/bar.py @@ -72,7 +72,6 @@ class Bar(object): oversize = leftsize + rightsize - wid if oversize <= 0: return self.fill_gap(' ', wid, gapwidth=False) - nonfixed_items = self.left.nonfixed_items() # Shrink items to a minimum size until there is enough room. for item in self.left: @@ -122,9 +121,6 @@ class BarSide(list): n += item.min_size return n - def nonfixed_items(self): - return sum(1 for item in self if not item.fixed) - class ColoredString(object): def __init__(self, string, *lst): diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py index 5a2a97ef..e577621b 100644 --- a/ranger/gui/colorscheme.py +++ b/ranger/gui/colorscheme.py @@ -156,7 +156,7 @@ def _colorscheme_name_to_class(signal): and is_scheme(scheme_module.Scheme): signal.value = scheme_module.Scheme() else: - for name, var in scheme_module.__dict__.items(): + for var in scheme_module.__dict__.values(): if var != ColorScheme and is_scheme(var): signal.value = var() break diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py index 70455b35..e20640d4 100644 --- a/ranger/gui/displayable.py +++ b/ranger/gui/displayable.py @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import _curses - from ranger.core.shared import FileManagerAware, EnvironmentAware from ranger.gui.curses_shortcuts import CursesShortcuts diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 2c865cbe..1000f753 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -276,7 +276,6 @@ class BrowserColumn(Pager): this_color.append('link') this_color.append(drawn.exists and 'good' or 'bad') - string = drawn.basename wtext = WideString(text) if len(wtext) > space: wtext = wtext[:space - 1] + ellipsis diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 23b18a99..08c6020d 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -17,7 +17,6 @@ """ The pager displays text and allows you to scroll inside it. """ -import re from . import Widget from ranger.gui import ansi from ranger.ext.direction import Direction diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index 805fa270..caa4dd77 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -17,7 +17,6 @@ The TaskView allows you to modify what the loader is doing. """ -import curses from collections import deque from . import Widget |