about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2017-05-21 02:02:15 +0200
committerrandnobx <randynobx@gmail.com>2017-05-20 20:08:24 -0400
commit9a20699a86ae33fbf60182de4d73d1d457817233 (patch)
treefca44de5ee57ca893f1a523ba268db49befa0ec7
parentcb069868a4f5a162dedb75ff2a181fcf59ccd2ce (diff)
downloadranger-9a20699a86ae33fbf60182de4d73d1d457817233.tar.gz
Separate the inode filter constants into their own class
-rw-r--r--ranger/container/directory.py13
-rw-r--r--ranger/core/main.py3
2 files changed, 9 insertions, 7 deletions
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 69b619ea..5bc822c4 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -92,13 +92,14 @@ def mtimelevel(path, level):
         mtime = max(mtime, max([-1] + [os.stat(d).st_mtime for d in dirlist]))
     return mtime
 
+class InodeFilterConstants(object):
+    DIRS = 'd'
+    FILES = 'f'
+    LINKS = 'l'
 
 class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public-methods
         FileSystemObject, Accumulator, Loadable):
 
-    FILTER_DIRS = 'd'
-    FILTER_FILES = 'f'
-    FILTER_LINKS = 'l'
 
     is_directory = True
     enterable = False
@@ -262,11 +263,11 @@ class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public
                 # Use local inode_type_filter is present, global otherwise
                 inode_filter = self.inode_type_filter or self.settings.global_inode_type_filter
                 # Apply filter
-                if self.FILTER_DIRS in inode_filter and obj.is_directory:
+                if InodeFilterConstants.DIRS in inode_filter and obj.is_directory:
                     return True
-                elif self.FILTER_FILES in inode_filter and obj.is_file and not obj.is_link:
+                elif InodeFilterConstants.FILES in inode_filter and obj.is_file and not obj.is_link:
                     return True
-                elif self.FILTER_LINKS in inode_filter and obj.is_link:
+                elif InodeFilterConstants.LINKS in inode_filter and obj.is_link:
                     return True
                 return False
             filters.append(inode_filter_func)
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 35c5eb62..3e68e15c 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -120,7 +120,8 @@ def main(
         load_settings(fm, args.clean)
 
         if args.choosedir:
-            fm.settings.global_inode_type_filter = 'd'
+            from ranger.container.directory import InodeFilterConstants
+            fm.settings.global_inode_type_filter = InodeFilterConstants.DIRS
 
         if args.list_unused_keys:
             from ranger.ext.keybinding_parser import (special_keys,