diff options
-rw-r--r-- | README | 8 | ||||
-rw-r--r-- | ranger/api/__init__.py | 4 | ||||
-rw-r--r-- | ranger/api/apps.py (renamed from ranger/applications.py) | 0 | ||||
-rw-r--r-- | ranger/api/keys.py (renamed from ranger/keyapi.py) | 0 | ||||
-rw-r--r-- | ranger/api/options.py | 17 | ||||
-rw-r--r-- | ranger/defaults/apps.py | 2 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 2 | ||||
-rw-r--r-- | ranger/defaults/options.py | 7 | ||||
-rw-r--r-- | ranger/shared/settings.py | 16 |
9 files changed, 41 insertions, 15 deletions
diff --git a/README b/README index 764ab57e..352fbaee 100644 --- a/README +++ b/README @@ -83,12 +83,8 @@ apps.py defines how files are run, keys.py defines keybindings. The files in ranger/defaults/ can be copied into ~/.ranger/ for per-user modifications. Colorschemes can be placed in ~/.ranger/colorschemes. -The options.py defines the import path of "apps", "keys" and the -colorscheme. To use the files you placed in ~/.ranger/, you may need -to make this changes in the options.py: - -"from ranger.defaults import apps, keys" => "import apps, keys" -"from ranger import colorschemes" => "import colorschemes" +The configuration files should be self-explanatory. If you need more +information, check out the source code. == Guidelines for developers: diff --git a/ranger/api/__init__.py b/ranger/api/__init__.py new file mode 100644 index 00000000..cc64a7c0 --- /dev/null +++ b/ranger/api/__init__.py @@ -0,0 +1,4 @@ +""" +Files in this module contain helper functions used in +configuration files. +""" diff --git a/ranger/applications.py b/ranger/api/apps.py index c01e13a7..c01e13a7 100644 --- a/ranger/applications.py +++ b/ranger/api/apps.py diff --git a/ranger/keyapi.py b/ranger/api/keys.py index 308fab2b..308fab2b 100644 --- a/ranger/keyapi.py +++ b/ranger/api/keys.py diff --git a/ranger/api/options.py b/ranger/api/options.py new file mode 100644 index 00000000..210e7f61 --- /dev/null +++ b/ranger/api/options.py @@ -0,0 +1,17 @@ +# Copyright (c) 2009, 2010 hut <hut@lavabit.com> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +import re +from re import compile as regexp +from ranger import colorschemes diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index 9c1ae5c3..3d54b2c1 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -14,7 +14,7 @@ import os from re import compile, VERBOSE -from ranger.applications import * +from ranger.api.apps import * INTERPRETED_LANGUAGES = compile(r''' ^(text|application)\/x-( diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 211c0d2d..7f508d03 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -32,7 +32,7 @@ arg.keybuffer: the keybuffer instance Check ranger.keyapi for more information """ -from ranger.keyapi import * +from ranger.api.keys import * def _vimlike_aliases(command_list): bind, hint, alias = make_abbreviations(command_list) diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index e5ba8679..d2df0b05 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -12,9 +12,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from ranger.defaults import apps, keys -from ranger import colorschemes -import re +from ranger.api.options import * colorscheme = colorschemes.default @@ -32,5 +30,4 @@ show_hidden = False collapse_preview = True autosave_bookmarks = True -hidden_filter = re.compile( \ - r'^\.|~$|\.(:?pyc|pyo|bak|swp)$') +hidden_filter = regexp(r'^\.|~$|\.(:?pyc|pyo|bak|swp)$') diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index ac024494..2a86e052 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -19,7 +19,6 @@ preview_files max_history_size colorscheme collapse_preview hidden_filter flushinput max_dirsize_for_autopreview autosave_bookmarks -apps keys """.split() # -- globalize the settings -- @@ -41,10 +40,21 @@ class SettingsAware(object): if hasattr(custom_options, setting): setattr(options, setting, getattr(custom_options, setting)) elif not hasattr(options, setting): - raise Exception("Following option was not defined: " + setting) + raise Exception("This option was not defined: " + setting) except ImportError: pass + try: + import apps + except ImportError: + from ranger.defaults import apps + + try: + import keys + except ImportError: + from ranger.defaults import keys + + # If a module is specified as the colorscheme, replace it with one # valid colorscheme inside that module. @@ -68,3 +78,5 @@ class SettingsAware(object): for setting in ALLOWED_SETTINGS: SettingsAware.settings[setting] = getattr(options, setting) + SettingsAware.settings.keys = keys + SettingsAware.settings.apps = apps |