diff options
author | hut <hut@lavabit.com> | 2009-11-25 17:55:34 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-11-25 17:55:34 +0100 |
commit | 5822dff7d91472bf2fc337c68f144e0ce1de09ae (patch) | |
tree | 7d40218b67f13c9c95141aa5bcb4aa292c42924a /code/environment.py | |
parent | cfbb8c84355f28bc7f669105f90c7aae0a972569 (diff) | |
download | ranger-5822dff7d91472bf2fc337c68f144e0ce1de09ae.tar.gz |
implemented more stuff
Diffstat (limited to 'code/environment.py')
-rw-r--r-- | code/environment.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/code/environment.py b/code/environment.py index d0ff5763..515fc8c6 100644 --- a/code/environment.py +++ b/code/environment.py @@ -1,3 +1,5 @@ +import directory + class Vector(): def __init__(self, x, y): self.x = x @@ -6,11 +8,31 @@ class Vector(): class Environment(): # A collection of data which is relevant for more than # one class. - def __init__(self): + def __init__(self, opt): + self.opt = opt self.path = None + self.pathway = () self.directories = {} self.pwd = None # current directory self.cf = None # current file self.keybuffer = '' self.copy = None self.termsize = Vector(80, 24) + + def at_level(self, level): + if level <= 0: + try: + return self.pathway[level - 1] + except IndexError: + return None + else: + return self.cf + + def get_directory(self, path): + import os + path = os.path.abspath(path) + try: + return self.directories[path] + except KeyError: + self.directories[path] = directory.Directory(path) + return self.directories[path] |