Show More
@@ -37,7 +37,7 b' def parse_args(args):' | |||
|
37 | 37 | raise IpyShellCmdException("No files found:" + str(tup2[0:-1])) |
|
38 | 38 | return flist, trg |
|
39 | 39 | |
|
40 | def icp(arg): | |
|
40 | def icp(ip,arg): | |
|
41 | 41 | """ icp files... targetdir |
|
42 | 42 | |
|
43 | 43 | Copy all files to target, creating dirs for target if necessary |
@@ -57,7 +57,7 b' def icp(arg):' | |||
|
57 | 57 | return fs |
|
58 | 58 | ip.defalias("icp",icp) |
|
59 | 59 | |
|
60 | def imv(arg): | |
|
60 | def imv(ip,arg): | |
|
61 | 61 | """ imv src tgt |
|
62 | 62 | |
|
63 | 63 | Move source to target. |
@@ -71,7 +71,7 b' def imv(arg):' | |||
|
71 | 71 | return fs |
|
72 | 72 | ip.defalias("imv",imv) |
|
73 | 73 | |
|
74 | def irm(arg): | |
|
74 | def irm(ip,arg): | |
|
75 | 75 | """ irm path[s]... |
|
76 | 76 | |
|
77 | 77 | Remove file[s] or dir[s] path. Dirs are deleted recursively. |
@@ -87,7 +87,7 b' def irm(arg):' | |||
|
87 | 87 | |
|
88 | 88 | ip.defalias("irm",irm) |
|
89 | 89 | |
|
90 | def imkdir(arg): | |
|
90 | def imkdir(ip,arg): | |
|
91 | 91 | """ imkdir path |
|
92 | 92 | |
|
93 | 93 | Creates dir path, and all dirs on the road |
@@ -98,7 +98,7 b' def imkdir(arg):' | |||
|
98 | 98 | |
|
99 | 99 | ip.defalias("imkdir",imkdir) |
|
100 | 100 | |
|
101 | def igrep(arg): | |
|
101 | def igrep(ip,arg): | |
|
102 | 102 | """ igrep PAT files... |
|
103 | 103 | |
|
104 | 104 | Very dumb file scan, case-insensitive. |
@@ -124,7 +124,7 b' def igrep(arg):' | |||
|
124 | 124 | |
|
125 | 125 | ip.defalias("igrep",igrep) |
|
126 | 126 | |
|
127 | def collect(arg): | |
|
127 | def collect(ip,arg): | |
|
128 | 128 | """ collect foo/a.txt rec:bar=*.py |
|
129 | 129 | |
|
130 | 130 | Copies foo/a.txt to ~/_ipython/collect/foo/a.txt and *.py from bar, |
@@ -154,7 +154,7 b' def collect(arg):' | |||
|
154 | 154 | |
|
155 | 155 | ip.defalias("collect",collect) |
|
156 | 156 | |
|
157 | def inote(arg): | |
|
157 | def inote(ip,arg): | |
|
158 | 158 | """ inote Hello world |
|
159 | 159 | |
|
160 | 160 | Adds timestamp and Hello world to ~/_ipython/notes.txt |
@@ -170,5 +170,4 b' def inote(arg):' | |||
|
170 | 170 | except IndexError: |
|
171 | 171 | ip.IP.hooks.editor(fname) |
|
172 | 172 | |
|
173 |
ip.defalias("inote",inote) |
|
|
174 | ||
|
173 | ip.defalias("inote",inote) |
@@ -21,7 +21,7 b' ip = IPython.ipapi.get()' | |||
|
21 | 21 | |
|
22 | 22 | import os,re,fnmatch,sys |
|
23 | 23 | |
|
24 | def selflaunch(line): | |
|
24 | def selflaunch(ip,line): | |
|
25 | 25 | """ Launch python script with 'this' interpreter |
|
26 | 26 | |
|
27 | 27 | e.g. d:\foo\ipython.exe a.py |
@@ -40,7 +40,7 b' class PyLauncher:' | |||
|
40 | 40 | """ |
|
41 | 41 | def __init__(self,script): |
|
42 | 42 | self.script = os.path.abspath(script) |
|
43 | def __call__(self, line): | |
|
43 | def __call__(self, ip, line): | |
|
44 | 44 | selflaunch("py " + self.script + ' ' + line) |
|
45 | 45 | def __repr__(self): |
|
46 | 46 | return 'PyLauncher("%s")' % self.script |
@@ -6,11 +6,21 b' ip = IPython.ipapi.get()' | |||
|
6 | 6 | import os, subprocess |
|
7 | 7 | |
|
8 | 8 | workdir = None |
|
9 | def workdir_f(line): | |
|
9 | def workdir_f(ip,line): | |
|
10 | """ Exceute commands residing in cwd elsewhere | |
|
11 | ||
|
12 | Example:: | |
|
13 | ||
|
14 | workdir /myfiles | |
|
15 | cd bin | |
|
16 | workdir myscript.py | |
|
17 | ||
|
18 | executes myscript.py (stored in bin, but not in path) in /myfiles | |
|
19 | """ | |
|
10 | 20 | global workdir |
|
11 | 21 | dummy,cmd = line.split(None,1) |
|
12 | 22 | if os.path.isdir(cmd): |
|
13 | workdir = cmd | |
|
23 | workdir = os.path.abspath(cmd) | |
|
14 | 24 | print "Set workdir",workdir |
|
15 | 25 | elif workdir is None: |
|
16 | 26 | print "Please set workdir first by doing e.g. 'workdir q:/'" |
@@ -22,12 +32,12 b' def workdir_f(line):' | |||
|
22 | 32 | head, tail = sp |
|
23 | 33 | if os.path.isfile(head): |
|
24 | 34 | cmd = os.path.abspath(head) + ' ' + tail |
|
25 |
print "Execute command" |
|
|
26 | ret = subprocess.call(cmd, shell = True, cwd = workdir) | |
|
35 | print "Execute command '" + cmd+ "' in",workdir | |
|
36 | olddir = os.getcwd() | |
|
37 | os.chdir(workdir) | |
|
38 | try: | |
|
39 | os.system(cmd) | |
|
40 | finally: | |
|
41 | os.chdir(olddir) | |
|
27 | 42 | |
|
28 | 43 | ip.defalias("workdir",workdir_f) |
|
29 | ||
|
30 | ||
|
31 | ||
|
32 | ||
|
33 |
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||
|
6 | 6 | |
|
7 | 7 | This file contains all the classes and helper functions specific to IPython. |
|
8 | 8 | |
|
9 |
$Id: iplib.py 271 |
|
|
9 | $Id: iplib.py 2719 2007-09-06 18:53:34Z vivainio $ | |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | #***************************************************************************** |
@@ -2174,9 +2174,9 b' want to merge them back into the new files.""" % locals()' | |||
|
2174 | 2174 | # print "=>",tgt #dbg |
|
2175 | 2175 | if callable(tgt): |
|
2176 | 2176 | if '$' in line_info.line: |
|
2177 | call_meth = '(_ip.itpl(%s))' | |
|
2177 | call_meth = '(_ip, _ip.itpl(%s))' | |
|
2178 | 2178 | else: |
|
2179 | call_meth = '(%s)' | |
|
2179 | call_meth = '(_ip,%s)' | |
|
2180 | 2180 | line_out = ("%s_sh.%s" + call_meth) % (line_info.preWhitespace, |
|
2181 | 2181 | line_info.iFun, |
|
2182 | 2182 | make_quoted_expr(line_info.line)) |
@@ -1,3 +1,10 b'' | |||
|
1 | 2007-09-06 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * ipy_rehashdir.py, ipy_workdir.py, ipy_fsops.py, iplib.py: | |
|
4 | Callable aliases now pass the _ip as first arg. This breaks | |
|
5 | compatibility with earlier 0.8.2.svn series! (though they should | |
|
6 | not have been in use yet outside these few extensions) | |
|
7 | ||
|
1 | 8 | 2007-09-05 Ville Vainio <vivainio@gmail.com> |
|
2 | 9 | |
|
3 | 10 | * external/mglob.py: expand('dirname') => ['dirname'], instead |
@@ -305,7 +312,7 b'' | |||
|
305 | 312 | |
|
306 | 313 | * IPython/Extensions/ipipe.py: Added a new table icap, which executes a |
|
307 | 314 | Python string and captures the output. (Idea and original patch by |
|
308 |
St |
|
|
315 | Stefan van der Walt) | |
|
309 | 316 | |
|
310 | 317 | 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu> |
|
311 | 318 | |
@@ -325,7 +332,7 b'' | |||
|
325 | 332 | in the input line. Split the statusbar to be able to display the currently |
|
326 | 333 | active refresh interval. (Patch by Nik Tautenhahn) |
|
327 | 334 | |
|
328 |
2007-05-29 J |
|
|
335 | 2007-05-29 Jorgen Stenarson <jorgen.stenarson@bostream.nu> | |
|
329 | 336 | |
|
330 | 337 | * fixing set_term_title to use ctypes as default |
|
331 | 338 | |
@@ -515,7 +522,7 b'' | |||
|
515 | 522 | * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import |
|
516 | 523 | ipy_stock_completers on default profile, do import on sh profile. |
|
517 | 524 | |
|
518 |
2007-04-22 J |
|
|
525 | 2007-04-22 Jorgen Stenarson <jorgen.stenarson@bostream.nu> | |
|
519 | 526 | |
|
520 | 527 | * Fix bug in iplib.py/safe_execfile when launching ipython with a script |
|
521 | 528 | like ipython.py foo.py which raised a IndexError. |
@@ -731,7 +738,7 b'' | |||
|
731 | 738 | * IPython/iplib.py (raw_input): Fix mishandling of unicode at |
|
732 | 739 | input. Patch sent by Stefan. |
|
733 | 740 | |
|
734 |
2007-03-20 J |
|
|
741 | 2007-03-20 Jorgen Stenarson <jorgen.stenarson@bostream.nu> | |
|
735 | 742 | * IPython/Extensions/ipy_stock_completer.py |
|
736 | 743 | shlex_split, fix bug in shlex_split. len function |
|
737 | 744 | call was missing an if statement. Caused shlex_split to |
@@ -789,7 +796,7 b'' | |||
|
789 | 796 | |
|
790 | 797 | * Extensions/ipy_stock_completers.py: Fixed exception |
|
791 | 798 | on mismatching quotes in %run completer. Patch by |
|
792 |
J |
|
|
799 | Jorgen Stenarson. Closes #127. | |
|
793 | 800 | |
|
794 | 801 | 2007-03-14 Ville Vainio <vivainio@gmail.com> |
|
795 | 802 | |
@@ -819,7 +826,7 b'' | |||
|
819 | 826 | * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn: |
|
820 | 827 | Close help window if exiting igrid. |
|
821 | 828 | |
|
822 |
2007-03-02 J |
|
|
829 | 2007-03-02 Jorgen Stenarson <jorgen.stenarson@bostream.nu> | |
|
823 | 830 | |
|
824 | 831 | * IPython/Extensions/ipy_defaults.py: Check if readline is available |
|
825 | 832 | before calling functions from readline. |
@@ -1,3 +1,6 b'' | |||
|
1 | import sys | |
|
2 | sys.path.append('..') | |
|
3 | ||
|
1 | 4 | import IPython.ipapi |
|
2 | 5 | |
|
3 | 6 | IPython.ipapi.make_session() |
@@ -17,7 +20,8 b' def test_db():' | |||
|
17 | 20 | def test_defalias(): |
|
18 | 21 | slot = [None] |
|
19 | 22 | # test callable alias |
|
20 | def cb(s): | |
|
23 | def cb(localip,s): | |
|
24 | assert localip is ip | |
|
21 | 25 | slot[0] = s |
|
22 | 26 | |
|
23 | 27 | ip.defalias('testalias', cb) |
General Comments 0
You need to be logged in to leave comments.
Login now