~ipython-dev/ipython/0.10.1

« back to all changes in this revision

Viewing changes to IPython/Extensions/ipy_kitcfg.py

  • Committer: Fernando Perez
  • Date: 2008-06-02 01:26:30 UTC
  • mfrom: (0.1.130 ipython-local)
  • Revision ID: fernando.perez@berkeley.edu-20080602012630-m14vezrhydzvahf8
Merge in all development done in bzr since February 16 2008.

At that time, a clean bzr branch was started from the SVN tree, but
without SVN history.  That SVN history has now been used as the basis
of this branch, and the development done on the history-less BZR
branch has been added and is the content of this merge.  

This branch will be the new official main line of development in
Launchpad (equivalent to the old SVN trunk).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os,sys
2
 
 
3
 
import ipy_rehashdir,glob
4
 
from ipy_rehashdir import selflaunch, PyLauncher
5
 
 
6
 
def pylaunchers():
7
 
    """Create launchers for python scripts in cwd and store them in alias table
8
 
    
9
 
    This is useful if you want to invoke .py scripts from ipykit session,
10
 
    just adding .py files in PATH does not work without file association.
11
 
    
12
 
    .ipy files will be run like macros.
13
 
    
14
 
    """
15
 
    fs = glob.glob('*.py') + glob.glob('*.ipy')
16
 
    for f in fs:
17
 
        l = PyLauncher(f)
18
 
        n = os.path.splitext(f)[0]
19
 
        ip.defalias(n, l)
20
 
        ip.magic('store '+n)
21
 
 
22
 
 
23
 
def exta_imports():
24
 
    # add some modules that you'd want to be bundled in the ipykit
25
 
    # library zip file here. Do this if you get ImportErrors from scripts you
26
 
    # try to launch with 'py' or pylaunchers. In theory you could include
27
 
    # the whole stdlib here for full script coverage
28
 
    
29
 
    # note that this is never run, it's just here for py2exe
30
 
    import distutils.dir_util
31
 
  
32
 
def kitroot():
33
 
    return os.environ.get('IPYKITROOT', None)
34
 
    
35
 
def main():
36
 
 
37
 
    if not kitroot():
38
 
        print "Can't configure ipykit, IPYKITROOT should be set."
39
 
        return
40
 
        
41
 
    os.environ["PATH"] = os.environ["PATH"] + ";" + kitroot() + "\\bin;"
42
 
    ip.to_user_ns("pylaunchers")
43
 
    cmds = ip.db.get('syscmdlist', None)
44
 
    if cmds is None:
45
 
        ip.magic('rehashx')
46
 
        cmds = ip.db.get('syscmdlist', [])
47
 
    #print cmds
48
 
    if 'sc1' in cmds:
49
 
        print "Default editor: Sc1"
50
 
        import ipy_editors
51
 
        ipy_editors.scite('sc1')
52
 
    
53
 
    # for icp, imv, imkdir, etc.
54
 
    import ipy_fsops
55
 
 
56
 
greeting = """\n\n === Welcome to ipykit ===
57
 
 
58
 
%quickref - learn quickly about IPython.
59
 
 
60
 
"""
61
 
    
62
 
def ipython_firstrun(ip):
63
 
 
64
 
    print "First run of ipykit - configuring"
65
 
 
66
 
    ip.defalias('py',selflaunch)
67
 
    ip.defalias('d','dir /w /og /on')
68
 
    ip.magic('store py')
69
 
    ip.magic('store d')
70
 
    
71
 
    bins = kitroot() +'/bin'
72
 
 
73
 
    print greeting
74
 
        
75
 
def init_ipython(ipy):
76
 
    global ip
77
 
    ip = ipy
78
 
    main()
79
 
 
80