diff options
author | hut <hut@lavabit.com> | 2010-04-13 13:44:58 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-13 13:44:58 +0200 |
commit | 48970395e4643cb74c37547363b196c7c4029678 (patch) | |
tree | 5ac3af57f1b8ab0e1df242fde4e14b2f0e0f2490 /ranger | |
parent | cf8b174eff6a9e016903d1071289453c8d9407d5 (diff) | |
download | ranger-48970395e4643cb74c37547363b196c7c4029678.tar.gz |
cleaner use of Awareness classes
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__main__.py | 5 | ||||
-rw-r--r-- | ranger/core/environment.py | 3 | ||||
-rw-r--r-- | ranger/core/fm.py | 3 | ||||
-rw-r--r-- | ranger/shared/__init__.py | 7 |
4 files changed, 10 insertions, 8 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py index 674ad8f6..98ce47da 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -75,7 +75,7 @@ def main(): from ranger.ext import curses_interrupt_handler from ranger.core.fm import FM from ranger.core.environment import Environment - from ranger.shared.settings import SettingsAware + from ranger.shared import * from ranger.gui.defaultui import DefaultUI as UI from ranger.fsobject.file import File @@ -111,11 +111,12 @@ def main(): else: path = '.' - Environment(path) + EnvironmentAware._assign(Environment(path)) try: my_ui = UI() my_fm = FM(ui=my_ui) + FileManagerAware._assign(my_fm) # Run the file manager my_fm.initialize() diff --git a/ranger/core/environment.py b/ranger/core/environment.py index 00b152d3..e5deda07 100644 --- a/ranger/core/environment.py +++ b/ranger/core/environment.py @@ -58,9 +58,6 @@ class Environment(SettingsAware, SignalDispatcher): self.hostname = socket.gethostname() self.home_path = os.path.expanduser('~') - from ranger.shared import EnvironmentAware - EnvironmentAware.env = self - self.signal_bind('move', self._set_cf_from_signal, priority=0.1, weak=True) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 626ce838..224ef06f 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -58,9 +58,6 @@ class FM(Actions, SignalDispatcher): self.run = Runner(ui=self.ui, apps=self.apps, logfunc=mylogfunc) - from ranger.shared import FileManagerAware - FileManagerAware.fm = self - self.log.append('Ranger {0} started! Process ID is {1}.' \ .format(__version__, os.getpid())) self.log.append('Running on Python ' + sys.version.replace('\n','')) diff --git a/ranger/shared/__init__.py b/ranger/shared/__init__.py index a476bd5f..048b9e7a 100644 --- a/ranger/shared/__init__.py +++ b/ranger/shared/__init__.py @@ -20,9 +20,16 @@ class Awareness(object): class EnvironmentAware(Awareness): env = None + @staticmethod + def _assign(instance): + EnvironmentAware.env = instance + class FileManagerAware(Awareness): fm = None + @staticmethod + def _assign(instance): + FileManagerAware.fm = instance from .mimetype import MimeTypeAware from .settings import SettingsAware |