diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | examples/plugin_new_macro.py | 4 | ||||
-rw-r--r-- | ranger/api/commands.py | 53 | ||||
-rwxr-xr-x | ranger/config/commands.py | 2 | ||||
-rw-r--r-- | ranger/container/directory.py | 18 | ||||
-rw-r--r-- | ranger/container/file.py | 3 | ||||
-rw-r--r-- | ranger/container/fsobject.py | 14 | ||||
-rw-r--r-- | ranger/container/history.py | 109 | ||||
-rw-r--r-- | ranger/core/actions.py | 12 | ||||
-rw-r--r-- | ranger/core/fm.py | 2 | ||||
-rw-r--r-- | ranger/core/loader.py | 7 | ||||
-rw-r--r-- | ranger/core/main.py | 4 | ||||
-rw-r--r-- | ranger/core/shared.py | 6 | ||||
-rwxr-xr-x | ranger/ext/rifle.py | 20 | ||||
-rw-r--r-- | ranger/ext/signals.py | 42 | ||||
-rw-r--r-- | ranger/gui/displayable.py | 8 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 3 | ||||
-rw-r--r-- | ranger/gui/widgets/console.py | 6 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 7 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 4 |
20 files changed, 154 insertions, 172 deletions
diff --git a/Makefile b/Makefile index 7b87a607..8636b170 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ test_pytest: py.test tests test: test_pylint test_flake8 test_doctest test_pytest - @echo "Finished testing." + @echo "Finished testing: All tests passed!" man: pod2man --stderr --center='ranger manual' --date='$(NAME)-$(VERSION)' \ diff --git a/examples/plugin_new_macro.py b/examples/plugin_new_macro.py index cb4d7413..ce46a558 100644 --- a/examples/plugin_new_macro.py +++ b/examples/plugin_new_macro.py @@ -11,7 +11,7 @@ import time import ranger.core.actions # Save the original macro function -GET_MACROS_OLD = ranger.core.actions.Actions._get_macros # pylint: disable=protected-access +GET_MACROS_OLD = ranger.core.actions.Actions.get_macros # Define a new macro function @@ -22,4 +22,4 @@ def get_macros_with_date(self): # Overwrite the old one -ranger.core.actions.Actions._get_macros = get_macros_with_date # pylint: disable=protected-access +ranger.core.actions.Actions.get_macros = get_macros_with_date diff --git a/ranger/api/commands.py b/ranger/api/commands.py index 6b761de8..57f00456 100644 --- a/ranger/api/commands.py +++ b/ranger/api/commands.py @@ -30,12 +30,10 @@ class CommandContainer(object): def alias(self, name, full_command): cmd = type(name, (AliasCommand, ), dict()) - # pylint: disable=protected-access - cmd._based_function = name - cmd._function_name = name - cmd._object_name = name - cmd._line = full_command - # pylint: enable=protected-access + cmd.based_function = name + cmd.function_name = name + cmd.object_name = name + cmd.line = full_command self.commands[name] = cmd def load_commands_from_module(self, module): @@ -54,11 +52,9 @@ class CommandContainer(object): attribute = getattr(obj, attribute_name) if hasattr(attribute, '__call__'): cmd = type(attribute_name, (FunctionCommand, ), dict(__doc__=attribute.__doc__)) - # pylint: disable=protected-access - cmd._based_function = attribute - cmd._function_name = attribute.__name__ - cmd._object_name = obj.__class__.__name__ - # pylint: enable=protected-access + cmd.based_function = attribute + cmd.function_name = attribute.__name__ + cmd.object_name = obj.__class__.__name__ self.commands[attribute_name] = cmd def get_command(self, name, abbrev=True): @@ -367,20 +363,19 @@ class Command(FileManagerAware): class FunctionCommand(Command): - _based_function = None - _object_name = "" - _function_name = "unknown" + based_function = None + object_name = "" + function_name = "unknown" def execute(self): # pylint: disable=too-many-branches - if not self._based_function: + if not self.based_function: return if len(self.args) == 1: try: - # pylint: disable=not-callable - return self._based_function(**{'narg': self.quantifier}) - # pylint: enable=not-callable + return self.based_function( # pylint: disable=not-callable + **{'narg': self.quantifier}) except TypeError: - return self._based_function() # pylint: disable=not-callable + return self.based_function() # pylint: disable=not-callable args, keywords = list(), dict() for arg in self.args[1:]: @@ -407,29 +402,29 @@ class FunctionCommand(Command): try: if self.quantifier is None: - return self._based_function(*args, **keywords) # pylint: disable=not-callable + return self.based_function(*args, **keywords) # pylint: disable=not-callable else: try: - return self._based_function(*args, **keywords) # pylint: disable=not-callable + return self.based_function(*args, **keywords) # pylint: disable=not-callable except TypeError: del keywords['narg'] - return self._based_function(*args, **keywords) # pylint: disable=not-callable + return self.based_function(*args, **keywords) # pylint: disable=not-callable except TypeError: if ranger.args.debug: raise else: self.fm.notify( "Bad arguments for %s.%s: %s, %s" % ( - self._object_name, self._function_name, repr(args), repr(keywords)), + self.object_name, self.function_name, repr(args), repr(keywords)), bad=True, ) class AliasCommand(Command): - _based_function = None - _object_name = "" - _function_name = "unknown" - _line = "" + based_function = None + object_name = "" + function_name = "unknown" + line = "" def execute(self): return self._make_cmd().execute() @@ -449,8 +444,8 @@ class AliasCommand(Command): return self._make_cmd().cancel() def _make_cmd(self): - cmd_class = self.fm.commands.get_command(self._line.split()[0]) - cmd = cmd_class(self._line + ' ' + self.rest(1)) + cmd_class = self.fm.commands.get_command(self.line.split()[0]) + cmd = cmd_class(self.line + ' ' + self.rest(1)) cmd.quickly_executed = self.quickly_executed cmd.quantifier = self.quantifier cmd.escape_macros_for_shell = self.escape_macros_for_shell diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 13df6bd9..b200f500 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1500,7 +1500,7 @@ class linemode(default_linemode): self.fm.notify("Unhandled linemode: `%s'" % mode, bad=True) return - self.fm.thisdir._set_linemode_of_children(mode) # pylint: disable=protected-access + self.fm.thisdir.set_linemode_of_children(mode) # Ask the browsercolumns to redraw for col in self.fm.ui.browser.columns: diff --git a/ranger/container/directory.py b/ranger/container/directory.py index d3c0e885..dee047f1 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -125,7 +125,7 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public vcs = None has_vcschild = False - _cumulative_size_calculated = False + cumulative_size_calculated = False sort_dict = { 'basename': sort_by_basename, @@ -173,7 +173,7 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public return self.files def mark_item(self, item, val): - item._mark(val) # pylint: disable=protected-access + item.mark_set(val) if val: if item in self.files and item not in self.marked_items: self.marked_items.append(item) @@ -208,7 +208,7 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public def _clear_marked_items(self): for item in self.marked_items: - item._mark(False) # pylint: disable=protected-access + item.mark_set(False) del self.marked_items[:] def get_selection(self): @@ -298,7 +298,7 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public for fname in filelist] self.load_content_mtime = os.stat(mypath).st_mtime - if self._cumulative_size_calculated: + if self.cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". @@ -381,10 +381,10 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public self._clear_marked_items() for item in self.files_all: if item.path in marked_paths: - item._mark(True) # pylint: disable=protected-access + item.mark_set(True) self.marked_items.append(item) else: - item._mark(False) # pylint: disable=protected-access + item.mark_set(False) self.sort() @@ -500,7 +500,7 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public return cum def look_up_cumulative_size(self): - self._cumulative_size_calculated = True + self.cumulative_size_calculated = True self.size = self._get_cumulative_size() self.infostring = ('-> ' if self.is_link else ' ') + human_readable(self.size) @@ -654,9 +654,9 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public """Is the directory empty?""" return self.files is None or len(self.files) == 0 - def _set_linemode_of_children(self, mode): + def set_linemode_of_children(self, mode): for fobj in self.files: - fobj._set_linemode(mode) # pylint: disable=protected-access + fobj.set_linemode(mode) def __nonzero__(self): """Always True""" diff --git a/ranger/container/file.py b/ranger/container/file.py index 88097a2c..efb2a7d8 100644 --- a/ranger/container/file.py +++ b/ranger/container/file.py @@ -46,8 +46,7 @@ class File(FileSystemObject): preview_data = None preview_known = False preview_loading = False - - _linemode = "filename" + linemode = "filename" _firstbytes = None @property diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py index facf3b96..37603c0c 100644 --- a/ranger/container/fsobject.py +++ b/ranger/container/fsobject.py @@ -87,7 +87,7 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes vcsstatus = None vcsremotestatus = None - _linemode = DEFAULT_LINEMODE + linemode = DEFAULT_LINEMODE linemode_dict = dict( (linemode.name, linemode()) for linemode in [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode, @@ -119,14 +119,14 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes for method, argument, linemode in self.fm.default_linemodes: if linemode in self.linemode_dict: if method == "always": - self._linemode = linemode + self.linemode = linemode break if method == "path" and argument.search(path): - self._linemode = linemode + self.linemode = linemode break if method == "tag" and self.realpath in self.fm.tags and \ self.fm.tags.marker(self.realpath) in argument: - self._linemode = linemode + self.linemode = linemode break def __repr__(self): @@ -243,7 +243,7 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes directory = self.fm.get_directory(self.dirname) directory.mark_item(self) - def _mark(self, boolean): + def mark_set(self, boolean): """Called by directory.mark_item() and similar functions""" self.marked = bool(boolean) @@ -357,5 +357,5 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes return True return False - def _set_linemode(self, mode): - self._linemode = mode + def set_linemode(self, mode): + self.linemode = mode diff --git a/ranger/container/history.py b/ranger/container/history.py index b3a1943e..9361e373 100644 --- a/ranger/container/history.py +++ b/ranger/container/history.py @@ -15,48 +15,46 @@ class History(object): def __init__(self, maxlen=None, unique=True): assert maxlen is not None, "maxlen cannot be None" if isinstance(maxlen, History): - # pylint: disable=protected-access - self._history = list(maxlen._history) - self._index = maxlen._index - # pylint: enable=protected-access + self.history = list(maxlen.history) + self.index = maxlen.index self.maxlen = maxlen.maxlen self.unique = maxlen.unique else: - self._history = [] - self._index = 0 + self.history = [] + self.index = 0 self.maxlen = maxlen self.unique = unique def add(self, item): # Remove everything after index - if self._index < len(self._history) - 2: - del self._history[:self._index + 1] + if self.index < len(self.history) - 2: + del self.history[:self.index + 1] # Remove Duplicates if self.unique: try: - self._history.remove(item) + self.history.remove(item) except ValueError: pass else: - if self._history and self._history[-1] == item: - del self._history[-1] + if self.history and self.history[-1] == item: + del self.history[-1] # Remove first if list is too long - if len(self._history) > max(self.maxlen - 1, 0): - del self._history[0] + if len(self.history) > max(self.maxlen - 1, 0): + del self.history[0] # Append the item and fast forward - self._history.append(item) - self._index = len(self._history) - 1 + self.history.append(item) + self.index = len(self.history) - 1 def modify(self, item, unique=False): - if self._history and unique: + if self.history and unique: try: - self._history.remove(item) + self.history.remove(item) except ValueError: pass else: - self._index -= 1 + self.index -= 1 try: - self._history[self._index] = item + self.history[self.index] = item except IndexError: self.add(item) @@ -73,86 +71,85 @@ class History(object): """ assert isinstance(other_history, History) - if not self._history: - self._index = 0 + if not self.history: + self.index = 0 future_length = 0 else: - future_length = len(self._history) - self._index - 1 + future_length = len(self.history) - self.index - 1 - self._history[:self._index] = list( - other_history._history[:other_history._index + 1]) # pylint: disable=protected-access - if len(self._history) > self.maxlen: - # pylint: disable=protected-access,invalid-unary-operand-type - self._history = self._history[-self.maxlen:] - # pylint: enable=protected-access,invalid-unary-operand-type + self.history[:self.index] = list( + other_history.history[:other_history.index + 1]) + if len(self.history) > self.maxlen: + self.history = self.history[ + -self.maxlen:] # pylint: disable=invalid-unary-operand-type - self._index = len(self._history) - future_length - 1 - assert self._index < len(self._history) + self.index = len(self.history) - future_length - 1 + assert self.index < len(self.history) def __len__(self): - return len(self._history) + return len(self.history) def current(self): - if self._history: - return self._history[self._index] + if self.history: + return self.history[self.index] else: raise HistoryEmptyException def top(self): try: - return self._history[-1] + return self.history[-1] except IndexError: raise HistoryEmptyException def bottom(self): try: - return self._history[0] + return self.history[0] except IndexError: raise HistoryEmptyException def back(self): - self._index -= 1 - if self._index < 0: - self._index = 0 + self.index -= 1 + if self.index < 0: + self.index = 0 return self.current() def move(self, n): - self._index += n - if self._index > len(self._history) - 1: - self._index = len(self._history) - 1 - if self._index < 0: - self._index = 0 + self.index += n + if self.index > len(self.history) - 1: + self.index = len(self.history) - 1 + if self.index < 0: + self.index = 0 return self.current() def search(self, string, n): if n != 0 and string: step = 1 if n > 0 else -1 - i = self._index + i = self.index steps_left = steps_left_at_start = int(abs(n)) while steps_left: i += step - if i >= len(self._history) or i < 0: + if i >= len(self.history) or i < 0: break - if self._history[i].startswith(string): + if self.history[i].startswith(string): steps_left -= 1 if steps_left != steps_left_at_start: - self._index = i + self.index = i return self.current() def __iter__(self): - return self._history.__iter__() + return self.history.__iter__() def forward(self): - if self._history: - self._index += 1 - if self._index > len(self._history) - 1: - self._index = len(self._history) - 1 + if self.history: + self.index += 1 + if self.index > len(self.history) - 1: + self.index = len(self.history) - 1 else: - self._index = 0 + self.index = 0 return self.current() def fast_forward(self): - if self._history: - self._index = len(self._history) - 1 + if self.history: + self.index = len(self.history) - 1 else: - self._index = 0 + self.index = 0 diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 84f0fdde..7e549d30 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -250,7 +250,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def substitute_macros(self, string, # pylint: disable=redefined-outer-name additional=None, escape=False): - macros = self._get_macros() + macros = self.get_macros() if additional: macros.update(additional) if escape: @@ -268,7 +268,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m raise ValueError("Could not apply macros to `%s'" % string) return result - def _get_macros(self): # pylint: disable=too-many-branches,too-many-statements + def get_macros(self): # pylint: disable=too-many-branches,too-many-statements macros = {} macros['rangerdir'] = ranger.RANGERDIR @@ -869,7 +869,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def display_command_help(self, console_widget): try: - command = console_widget._get_cmd_class() # pylint: disable=protected-access + command = console_widget.get_cmd_class() except KeyError: self.notify("Feature not available!", bad=True) return @@ -1113,7 +1113,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m name = self.current_tab tab = self.tabs[name] if name == self.current_tab: - direction = -1 if name == self._get_tab_list()[-1] else 1 + direction = -1 if name == self.get_tab_list()[-1] else 1 previous = self.current_tab self.tab_move(direction) if previous == self.current_tab: @@ -1142,7 +1142,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if narg: return self.tab_open(narg) assert isinstance(offset, int) - tablist = self._get_tab_list() + tablist = self.get_tab_list() current_index = tablist.index(self.current_tab) newtab = tablist[(current_index + offset) % len(tablist)] if newtab != self.current_tab: @@ -1199,7 +1199,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if file_selection: self.fm.select_file(file_selection) - def _get_tab_list(self): + def get_tab_list(self): assert self.tabs, "There must be at least 1 tab at all times" return sorted(self.tabs) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 3496f5c9..2db18c40 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -83,7 +83,7 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes """If ui/bookmarks are None, they will be initialized here.""" self.tabs = dict((n + 1, Tab(path)) for n, path in enumerate(self.start_paths)) - tab_list = self._get_tab_list() + tab_list = self.get_tab_list() if tab_list: self.current_tab = tab_list[0] self.thistab = self.tabs[self.current_tab] diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 0bf7d59a..274dc610 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -12,15 +12,16 @@ import select import sys import errno -from ranger.core.shared import FileManagerAware -from ranger.ext.signals import SignalDispatcher -from ranger.ext.human_readable import human_readable try: import chardet # pylint: disable=import-error HAVE_CHARDET = True except ImportError: HAVE_CHARDET = False +from ranger.core.shared import FileManagerAware +from ranger.ext.signals import SignalDispatcher +from ranger.ext.human_readable import human_readable + class Loadable(object): paused = False diff --git a/ranger/core/main.py b/ranger/core/main.py index 281f89f5..2cf9470a 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -77,7 +77,7 @@ def main( sys.stdout.write(line) return 1 if args.fail_unless_cd else 0 # COMPAT - SettingsAware._setup(Settings()) # pylint: disable=protected-access + SettingsAware.settings_set(Settings()) if args.selectfile: args.selectfile = os.path.abspath(args.selectfile) @@ -103,7 +103,7 @@ def main( try: # Initialize objects fm = FM(paths=paths) - FileManagerAware._setup(fm) # pylint: disable=protected-access + FileManagerAware.fm_set(fm) load_settings(fm, args.clean) if args.list_unused_keys: diff --git a/ranger/core/shared.py b/ranger/core/shared.py index 73b42aad..0f466d1b 100644 --- a/ranger/core/shared.py +++ b/ranger/core/shared.py @@ -5,18 +5,16 @@ from __future__ import (absolute_import, division, print_function) -from ranger.ext.lazy_property import lazy_property # NOQA pylint: disable=unused-import - class FileManagerAware(object): # pylint: disable=too-few-public-methods """Subclass this to gain access to the global "FM" object.""" @staticmethod - def _setup(fm): + def fm_set(fm): FileManagerAware.fm = fm class SettingsAware(object): # pylint: disable=too-few-public-methods """Subclass this to gain access to the global "SettingObject" object.""" @staticmethod - def _setup(settings): + def settings_set(settings): SettingsAware.settings = settings diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index c6b96f73..89ee7fa2 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -34,13 +34,13 @@ ENCODING = 'utf-8' try: from ranger.ext.get_executables import get_executables except ImportError: - _cached_executables = None # pylint: disable=invalid-name + _CACHED_EXECUTABLES = None def get_executables(): """Return all executable files in $PATH + Cache them.""" - global _cached_executables # pylint: disable=global-statement,invalid-name - if _cached_executables is not None: - return _cached_executables + global _CACHED_EXECUTABLES # pylint: disable=global-statement + if _CACHED_EXECUTABLES is not None: + return _CACHED_EXECUTABLES if 'PATH' in os.environ: paths = os.environ['PATH'].split(':') @@ -49,7 +49,7 @@ except ImportError: from stat import S_IXOTH, S_IFREG paths_seen = set() - _cached_executables = set() + _CACHED_EXECUTABLES = set() for path in paths: if path in paths_seen: continue @@ -65,8 +65,8 @@ except ImportError: except OSError: continue if filestat.st_mode & (S_IXOTH | S_IFREG): - _cached_executables.add(item) - return _cached_executables + _CACHED_EXECUTABLES.add(item) + return _CACHED_EXECUTABLES try: @@ -216,7 +216,7 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes elif function == 'path': return bool(re.search(argument, os.path.abspath(files[0]))) elif function == 'mime': - return bool(re.search(argument, self._get_mimetype(files[0]))) + return bool(re.search(argument, self.get_mimetype(files[0]))) elif function == 'has': if argument.startswith("$"): if argument[1:] in os.environ: @@ -245,7 +245,7 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes elif function == 'else': return True - def _get_mimetype(self, fname): + def get_mimetype(self, fname): # Spawn "file" to determine the mime-type of the given file. if self._mimetype: return self._mimetype @@ -448,7 +448,7 @@ def main(): # pylint: disable=too-many-locals if result == ASK_COMMAND: # TODO: implement interactive asking for file type? print("Unknown file type: %s" % - rifle._get_mimetype(positional[0])) # pylint: disable=protected-access + rifle.get_mimetype(positional[0])) if __name__ == '__main__': diff --git a/ranger/ext/signals.py b/ranger/ext/signals.py index 50141565..cbd35643 100644 --- a/ranger/ext/signals.py +++ b/ranger/ext/signals.py @@ -96,10 +96,10 @@ class SignalHandler(object): # pylint: disable=too-few-public-methods active = True def __init__(self, signal_name, function, priority, pass_signal): - self._priority = max(0, min(1, priority)) - self._signal_name = signal_name - self._function = function - self._pass_signal = pass_signal + self.priority = max(0, min(1, priority)) + self.signal_name = signal_name + self.function = function + self.pass_signal = pass_signal class SignalDispatcher(object): @@ -112,7 +112,7 @@ class SignalDispatcher(object): """Remove all signals.""" for handler_list in self._signals.values(): for handler in handler_list: - handler._function = None # pylint: disable=protected-access + handler.function = None self._signals = dict() def signal_bind(self, signal_name, function, priority=0.5, weak=False, autosort=True): @@ -152,7 +152,7 @@ class SignalDispatcher(object): handlers.append(handler) if autosort: handlers.sort( - key=lambda handler: -handler._priority) # pylint: disable=protected-access + key=lambda handler: -handler.priority) return handler def signal_force_sort(self, signal_name=None): @@ -164,10 +164,10 @@ class SignalDispatcher(object): if signal_name is None: for handlers in self._signals.values(): handlers.sort( - key=lambda handler: -handler._priority) # pylint: disable=protected-access + key=lambda handler: -handler.priority) elif signal_name in self._signals: self._signals[signal_name].sort( - key=lambda handler: -handler._priority) # pylint: disable=protected-access + key=lambda handler: -handler.priority) else: return False @@ -179,11 +179,11 @@ class SignalDispatcher(object): """ try: handlers = self._signals[ - signal_handler._signal_name] # pylint: disable=protected-access + signal_handler.signal_name] except KeyError: pass else: - signal_handler._function = None # pylint: disable=protected-access + signal_handler.function = None try: handlers.remove(signal_handler) except IndexError: @@ -226,16 +226,14 @@ class SignalDispatcher(object): while i: i -= 1 handler = handler_list[i] - # pylint: disable=protected-access try: - if isinstance(handler._function, tuple): - handler._function[1].__class__ # pylint: disable=pointless-statement + if isinstance(handler.function, tuple): + handler.function[1].__class__ # pylint: disable=pointless-statement else: - handler._function.__class__ # pylint: disable=pointless-statement + handler.function.__class__ # pylint: disable=pointless-statement except ReferenceError: - handler._function = None + handler.function = None del handler_list[i] - # pylint: enable=protected-access def signal_emit(self, signal_name, **kw): """Emits a signal and call every function that was bound to that signal. @@ -259,20 +257,18 @@ class SignalDispatcher(object): # propagate for handler in tuple(handlers): if handler.active: - # pylint: disable=protected-access try: - if isinstance(handler._function, tuple): - fnc = MethodType(*handler._function) + if isinstance(handler.function, tuple): + fnc = MethodType(*handler.function) else: - fnc = handler._function - if handler._pass_signal: + fnc = handler.function + if handler.pass_signal: fnc(signal) else: fnc() except ReferenceError: - handler._function = None + handler.function = None handlers.remove(handler) - # pylint: enable=protected-access if signal.stopped: return False return True diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py index 1f4b7397..16cb275f 100644 --- a/ranger/gui/displayable.py +++ b/ranger/gui/displayable.py @@ -265,7 +265,7 @@ class DisplayableContainer(Displayable): def press(self, key): """Recursively called on objects in container""" - focused_obj = self._get_focused_obj() + focused_obj = self.get_focused_obj() if focused_obj: focused_obj.press(key) @@ -274,7 +274,7 @@ class DisplayableContainer(Displayable): def click(self, event): """Recursively called on objects in container""" - focused_obj = self._get_focused_obj() + focused_obj = self.get_focused_obj() if focused_obj and focused_obj.click(event): return True @@ -313,13 +313,13 @@ class DisplayableContainer(Displayable): else: obj.parent = None - def _get_focused_obj(self): + def get_focused_obj(self): # Finds a focused displayable object in the container. for displayable in self.container: if displayable.focused: return displayable try: - obj = displayable._get_focused_obj() # pylint: disable=protected-access + obj = displayable.get_focused_obj() except AttributeError: pass else: diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 5a656ba0..28160265 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -275,8 +275,7 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes # Extract linemode-related information from the drawn object metadata = None - current_linemode = \ - drawn.linemode_dict[drawn._linemode] # pylint: disable=protected-access + current_linemode = drawn.linemode_dict[drawn.linemode] if current_linemode.uses_metadata: metadata = self.fm.metadata.get_metadata(drawn.path) if not all(getattr(metadata, tag) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 6a7332c2..c0655e5c 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -440,7 +440,7 @@ class Console(Widget): # pylint: disable=too-many-instance-attributes,too-many- def _get_cmd(self, quiet=False): try: - command_class = self._get_cmd_class() + command_class = self.get_cmd_class() except KeyError: if not quiet: error = "Command not found: `%s'" % self.line.split()[0] @@ -448,7 +448,7 @@ class Console(Widget): # pylint: disable=too-many-instance-attributes,too-many- else: return command_class(self.line) - def _get_cmd_class(self): + def get_cmd_class(self): return self.fm.commands.get_command(self.line.split()[0]) def _get_tab(self, tabnum): @@ -485,7 +485,7 @@ class Console(Widget): # pylint: disable=too-many-instance-attributes,too-many- def on_line_change(self): self.history_search_pattern = self.line try: - cls = self._get_cmd_class() + cls = self.get_cmd_class() except (KeyError, ValueError, IndexError): pass else: diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 8e9e259e..eb2250ae 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -265,11 +265,8 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes if len(target.marked_items) == target.size: right.add(human_readable(target.disk_usage, separator='')) else: - sumsize = sum( - f.size for f in target.marked_items - if not f.is_directory or - f._cumulative_size_calculated # pylint: disable=protected-access - ) + sumsize = sum(f.size for f in target.marked_items + if not f.is_directory or f.cumulative_size_calculated) right.add(human_readable(sumsize, separator='')) right.add("/" + str(len(target.marked_items))) else: diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index d4ca904c..6f4a4cf1 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -57,7 +57,7 @@ class TitleBar(Widget): return False pos = self.wid - 1 - for tabname in reversed(self.fm._get_tab_list()): # pylint: disable=protected-access + for tabname in reversed(self.fm.get_tab_list()): tabtext = self._get_tab_text(tabname) pos -= len(tabtext) if event.x > pos: @@ -128,7 +128,7 @@ class TitleBar(Widget): bar.addright(' ', 'space', fixed=True) self.tab_width = 0 if len(self.fm.tabs) > 1: - for tabname in self.fm._get_tab_list(): # pylint: disable=protected-access + for tabname in self.fm.get_tab_list(): tabtext = self._get_tab_text(tabname) self.tab_width += len(tabtext) clr = 'good' if tabname == self.fm.current_tab else 'bad' |