home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __docformat__ = 'restructuredtext en'
- import os
- import __builtin__
- from util import Bunch
-
- class Magic(object):
-
- def __init__(self, interpreter, config = None):
- self.interpreter = interpreter
- if config is None:
- config = Bunch(ESC_MAGIC = '%')
-
- self.config = config
-
-
- def has_magic(self, name):
- return hasattr(self, 'magic_' + name)
-
-
- def object_find(self, name):
- name = name.strip()
- user_ns = self.interpreter.user_ns
- internal_ns = { }
- builtin_ns = __builtin__.__dict__
- alias_ns = { }
- namespaces = [
- ('Interactive', user_ns),
- ('IPython internal', internal_ns),
- ('Python builtin', builtin_ns),
- ('Alias', alias_ns)]
- found = False
- obj = None
- space = None
- ds = None
- ismagic = False
- isalias = False
- parts = name.split('.')
- head = parts[0]
- rest = parts[1:]
- for nsname, ns in namespaces:
-
- try:
- obj = ns[head]
- except KeyError:
- continue
- continue
-
- for part in rest:
-
- try:
- obj = getattr(obj, part)
- continue
- break
- continue
-
- else:
- found = True
- space = nsname
- isalias = ns == alias_ns
- break
-
- if not found:
- if name.startswith(self.config.ESC_MAGIC):
- name = name[1:]
-
- obj = getattr(self, 'magic_' + name, None)
- if obj is not None:
- found = True
- space = 'IPython internal'
- ismagic = True
-
-
- if not found and head in ("''", '""', '[]', '{}', '()'):
- obj = eval(head)
- found = True
- space = 'Interactive'
-
- return dict(found = found, obj = obj, namespace = space, ismagic = ismagic, isalias = isalias)
-
-
- def magic_pwd(self, parameter_s = ''):
- return os.getcwd()
-
-
- def magic_env(self, parameter_s = ''):
- return os.environ.data
-
-
-