~ellisonbg/ipython/trunk-dev

« back to all changes in this revision

Viewing changes to IPython/quarantine/envpersist.py

  • Committer: Brian Granger
  • Date: 2010-01-31 23:57:46 UTC
  • mfrom: (1109.1.113 ipython)
  • Revision ID: ellisonbg@gmail.com-20100131235746-rj81qa8klooepq2m
Merging from upstream trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
""" %env magic command for storing environment variables persistently
3
3
"""
4
4
 
5
 
import IPython.ipapi
6
 
ip = IPython.ipapi.get()
 
5
from IPython.core import ipapi
 
6
from IPython.core.error import TryNext
 
7
 
 
8
ip = ipapi.get()
7
9
 
8
10
import os,sys
9
11
 
16
18
        os.environ[k] = os.environ.get(k,"") + v
17
19
    for k,v in env['pre']:
18
20
        os.environ[k] = v + os.environ.get(k,"")
19
 
    raise IPython.ipapi.TryNext
 
21
    raise TryNext
20
22
  
21
23
ip.set_hook('late_startup_hook', restore_env)
22
24
 
85
87
    """ Custom completer that lists all env vars """
86
88
    return os.environ.keys()
87
89
 
88
 
ip.expose_magic('env', persist_env)
 
90
ip.define_magic('env', persist_env)
89
91
ip.set_hook('complete_command',env_completer, str_key = '%env')
90
92