Show More
The requested changes are too big and content was truncated. Show full diff
@@ -1,31 +1,31 b'' | |||||
1 | import inspect |
|
1 | import inspect | |
2 | import IPython.ipapi |
|
2 | import IPython.ipapi | |
3 | from IPython.genutils import arg_split |
|
3 | from IPython.genutils import arg_split | |
4 | ip = IPython.ipapi.get() |
|
4 | ip = IPython.ipapi.get() | |
5 |
|
5 | |||
6 | from IPython import Debugger |
|
6 | from IPython import Debugger | |
7 |
|
7 | |||
8 | def call_pydb(self, args): |
|
8 | def call_pydb(self, args): | |
9 | """Invoke pydb with the supplied parameters.""" |
|
9 | """Invoke pydb with the supplied parameters.""" | |
10 | try: |
|
10 | try: | |
11 | import pydb |
|
11 | import pydb | |
12 | except ImportError: |
|
12 | except ImportError: | |
13 | raise ImportError("pydb doesn't seem to be installed.") |
|
13 | raise ImportError("pydb doesn't seem to be installed.") | |
14 |
|
14 | |||
15 | if not hasattr(pydb.pydb, "runv"): |
|
15 | if not hasattr(pydb.pydb, "runv"): | |
16 | raise ImportError("You need pydb version 1.19 or later installed.") |
|
16 | raise ImportError("You need pydb version 1.19 or later installed.") | |
17 |
|
17 | |||
18 | argl = arg_split(args) |
|
18 | argl = arg_split(args) | |
19 | # print argl # dbg |
|
19 | # print argl # dbg | |
20 | if len(inspect.getargspec(pydb.runv)[0]) == 2: |
|
20 | if len(inspect.getargspec(pydb.runv)[0]) == 2: | |
21 | pdb = Debugger.Pdb() |
|
21 | pdb = Debugger.Pdb() | |
22 | ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )() |
|
22 | ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )() | |
23 | else: |
|
23 | else: | |
24 | ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )() |
|
24 | ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )() | |
25 |
|
25 | |||
26 |
|
26 | |||
27 | ip.expose_magic("pydb",call_pydb) |
|
27 | ip.expose_magic("pydb",call_pydb) | |
28 |
|
28 | |||
29 |
|
29 | |||
30 |
|
30 | |||
31 |
|
31 |
@@ -1,218 +1,218 b'' | |||||
1 | """ Tab completion support for a couple of linux package managers |
|
1 | """ Tab completion support for a couple of linux package managers | |
2 |
|
2 | |||
3 | This is also an example of how to write custom completer plugins |
|
3 | This is also an example of how to write custom completer plugins | |
4 | or hooks. |
|
4 | or hooks. | |
5 |
|
5 | |||
6 | Practical use: |
|
6 | Practical use: | |
7 |
|
7 | |||
8 | [ipython]|1> import ipy_linux_package_managers |
|
8 | [ipython]|1> import ipy_linux_package_managers | |
9 | [ipython]|2> apt-get u<<< press tab here >>> |
|
9 | [ipython]|2> apt-get u<<< press tab here >>> | |
10 | update upgrade |
|
10 | update upgrade | |
11 | [ipython]|2> apt-get up |
|
11 | [ipython]|2> apt-get up | |
12 |
|
12 | |||
13 | """ |
|
13 | """ | |
14 | import IPython.ipapi |
|
14 | import IPython.ipapi | |
15 | import glob,os,shlex,sys |
|
15 | import glob,os,shlex,sys | |
16 |
|
16 | |||
17 | ip = IPython.ipapi.get() |
|
17 | ip = IPython.ipapi.get() | |
18 |
|
18 | |||
19 | def vcs_completer(commands, event): |
|
19 | def vcs_completer(commands, event): | |
20 | """ utility to make writing typical version control app completers easier |
|
20 | """ utility to make writing typical version control app completers easier | |
21 |
|
21 | |||
22 | VCS command line apps typically have the format: |
|
22 | VCS command line apps typically have the format: | |
23 |
|
23 | |||
24 | [sudo ]PROGNAME [help] [command] file file... |
|
24 | [sudo ]PROGNAME [help] [command] file file... | |
25 |
|
25 | |||
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | cmd_param = event.line.split() |
|
29 | cmd_param = event.line.split() | |
30 | if event.line.endswith(' '): |
|
30 | if event.line.endswith(' '): | |
31 | cmd_param.append('') |
|
31 | cmd_param.append('') | |
32 |
|
32 | |||
33 | if cmd_param[0] == 'sudo': |
|
33 | if cmd_param[0] == 'sudo': | |
34 | cmd_param = cmd_param[1:] |
|
34 | cmd_param = cmd_param[1:] | |
35 |
|
35 | |||
36 | if len(cmd_param) == 2 or 'help' in cmd_param: |
|
36 | if len(cmd_param) == 2 or 'help' in cmd_param: | |
37 | return commands.split() |
|
37 | return commands.split() | |
38 |
|
38 | |||
39 | return ip.IP.Completer.file_matches(event.symbol) |
|
39 | return ip.IP.Completer.file_matches(event.symbol) | |
40 |
|
40 | |||
41 |
|
41 | |||
42 |
|
42 | |||
43 | def apt_completers(self, event): |
|
43 | def apt_completers(self, event): | |
44 | """ This should return a list of strings with possible completions. |
|
44 | """ This should return a list of strings with possible completions. | |
45 |
|
45 | |||
46 | Note that all the included strings that don't start with event.symbol |
|
46 | Note that all the included strings that don't start with event.symbol | |
47 | are removed, in order to not confuse readline. |
|
47 | are removed, in order to not confuse readline. | |
48 |
|
48 | |||
49 | """ |
|
49 | """ | |
50 | # print event # dbg |
|
50 | # print event # dbg | |
51 |
|
51 | |||
52 | # commands are only suggested for the 'command' part of package manager |
|
52 | # commands are only suggested for the 'command' part of package manager | |
53 | # invocation |
|
53 | # invocation | |
54 |
|
54 | |||
55 | cmd = (event.line + "<placeholder>").rsplit(None,1)[0] |
|
55 | cmd = (event.line + "<placeholder>").rsplit(None,1)[0] | |
56 | # print cmd |
|
56 | # print cmd | |
57 | if cmd.endswith('apt-get') or cmd.endswith('yum'): |
|
57 | if cmd.endswith('apt-get') or cmd.endswith('yum'): | |
58 | return ['update', 'upgrade', 'install', 'remove'] |
|
58 | return ['update', 'upgrade', 'install', 'remove'] | |
59 |
|
59 | |||
60 | # later on, add dpkg -l / whatever to get list of possible |
|
60 | # later on, add dpkg -l / whatever to get list of possible | |
61 | # packages, add switches etc. for the rest of command line |
|
61 | # packages, add switches etc. for the rest of command line | |
62 | # filling |
|
62 | # filling | |
63 |
|
63 | |||
64 | raise IPython.ipapi.TryNext |
|
64 | raise IPython.ipapi.TryNext | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | # re_key specifies the regexp that triggers the specified completer |
|
67 | # re_key specifies the regexp that triggers the specified completer | |
68 |
|
68 | |||
69 | ip.set_hook('complete_command', apt_completers, re_key = '.*apt-get') |
|
69 | ip.set_hook('complete_command', apt_completers, re_key = '.*apt-get') | |
70 | ip.set_hook('complete_command', apt_completers, re_key = '.*yum') |
|
70 | ip.set_hook('complete_command', apt_completers, re_key = '.*yum') | |
71 |
|
71 | |||
72 | pkg_cache = None |
|
72 | pkg_cache = None | |
73 |
|
73 | |||
74 | def module_completer(self,event): |
|
74 | def module_completer(self,event): | |
75 | """ Give completions after user has typed 'import' """ |
|
75 | """ Give completions after user has typed 'import' """ | |
76 |
|
76 | |||
77 | # only a local version for py 2.4, pkgutil has no walk_packages() there |
|
77 | # only a local version for py 2.4, pkgutil has no walk_packages() there | |
78 | if sys.version_info < (2,5): |
|
78 | if sys.version_info < (2,5): | |
79 | for el in [f[:-3] for f in glob.glob("*.py")]: |
|
79 | for el in [f[:-3] for f in glob.glob("*.py")]: | |
80 | yield el |
|
80 | yield el | |
81 | return |
|
81 | return | |
82 |
|
82 | |||
83 | global pkg_cache |
|
83 | global pkg_cache | |
84 | import pkgutil,imp,time |
|
84 | import pkgutil,imp,time | |
85 | #current = |
|
85 | #current = | |
86 | if pkg_cache is None: |
|
86 | if pkg_cache is None: | |
87 | print "\n\n[Standby while scanning modules, this can take a while]\n\n" |
|
87 | print "\n\n[Standby while scanning modules, this can take a while]\n\n" | |
88 | pkg_cache = list(pkgutil.walk_packages()) |
|
88 | pkg_cache = list(pkgutil.walk_packages()) | |
89 |
|
89 | |||
90 | already = set() |
|
90 | already = set() | |
91 | for ld, name, ispkg in pkg_cache: |
|
91 | for ld, name, ispkg in pkg_cache: | |
92 | if name.count('.') < event.symbol.count('.') + 1: |
|
92 | if name.count('.') < event.symbol.count('.') + 1: | |
93 | if name not in already: |
|
93 | if name not in already: | |
94 | already.add(name) |
|
94 | already.add(name) | |
95 | yield name + (ispkg and '.' or '') |
|
95 | yield name + (ispkg and '.' or '') | |
96 | return |
|
96 | return | |
97 |
|
97 | |||
98 | ip.set_hook('complete_command', module_completer, str_key = 'import') |
|
98 | ip.set_hook('complete_command', module_completer, str_key = 'import') | |
99 | ip.set_hook('complete_command', module_completer, str_key = 'from') |
|
99 | ip.set_hook('complete_command', module_completer, str_key = 'from') | |
100 |
|
100 | |||
101 | svn_commands = """\ |
|
101 | svn_commands = """\ | |
102 | add blame praise annotate ann cat checkout co cleanup commit ci copy |
|
102 | add blame praise annotate ann cat checkout co cleanup commit ci copy | |
103 | cp delete del remove rm diff di export help ? h import info list ls |
|
103 | cp delete del remove rm diff di export help ? h import info list ls | |
104 | lock log merge mkdir move mv rename ren propdel pdel pd propedit pedit |
|
104 | lock log merge mkdir move mv rename ren propdel pdel pd propedit pedit | |
105 | pe propget pget pg proplist plist pl propset pset ps resolved revert |
|
105 | pe propget pget pg proplist plist pl propset pset ps resolved revert | |
106 | status stat st switch sw unlock update |
|
106 | status stat st switch sw unlock update | |
107 | """ |
|
107 | """ | |
108 |
|
108 | |||
109 | def svn_completer(self,event): |
|
109 | def svn_completer(self,event): | |
110 | return vcs_completer(svn_commands, event) |
|
110 | return vcs_completer(svn_commands, event) | |
111 |
|
111 | |||
112 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') |
|
112 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') | |
113 |
|
113 | |||
114 | hg_commands = """ |
|
114 | hg_commands = """ | |
115 | add addremove annotate archive backout branch branches bundle cat |
|
115 | add addremove annotate archive backout branch branches bundle cat | |
116 | clone commit copy diff export grep heads help identify import incoming |
|
116 | clone commit copy diff export grep heads help identify import incoming | |
117 | init locate log manifest merge outgoing parents paths pull push |
|
117 | init locate log manifest merge outgoing parents paths pull push | |
118 | qapplied qclone qcommit qdelete qdiff qfold qguard qheader qimport |
|
118 | qapplied qclone qcommit qdelete qdiff qfold qguard qheader qimport | |
119 | qinit qnew qnext qpop qprev qpush qrefresh qrename qrestore qsave |
|
119 | qinit qnew qnext qpop qprev qpush qrefresh qrename qrestore qsave | |
120 | qselect qseries qtop qunapplied recover remove rename revert rollback |
|
120 | qselect qseries qtop qunapplied recover remove rename revert rollback | |
121 | root serve showconfig status strip tag tags tip unbundle update verify |
|
121 | root serve showconfig status strip tag tags tip unbundle update verify | |
122 | version |
|
122 | version | |
123 | """ |
|
123 | """ | |
124 |
|
124 | |||
125 | def hg_completer(self,event): |
|
125 | def hg_completer(self,event): | |
126 | """ Completer for mercurial commands """ |
|
126 | """ Completer for mercurial commands """ | |
127 |
|
127 | |||
128 | return vcs_completer(hg_commands, event) |
|
128 | return vcs_completer(hg_commands, event) | |
129 |
|
129 | |||
130 | ip.set_hook('complete_command', hg_completer, str_key = 'hg') |
|
130 | ip.set_hook('complete_command', hg_completer, str_key = 'hg') | |
131 |
|
131 | |||
132 |
|
132 | |||
133 | bzr_commands = """ |
|
133 | bzr_commands = """ | |
134 | add annotate bind branch break-lock bundle-revisions cat check |
|
134 | add annotate bind branch break-lock bundle-revisions cat check | |
135 | checkout commit conflicts deleted diff export gannotate gbranch |
|
135 | checkout commit conflicts deleted diff export gannotate gbranch | |
136 | gcommit gdiff help ignore ignored info init init-repository inventory |
|
136 | gcommit gdiff help ignore ignored info init init-repository inventory | |
137 | log merge missing mkdir mv nick pull push reconcile register-branch |
|
137 | log merge missing mkdir mv nick pull push reconcile register-branch | |
138 | remerge remove renames resolve revert revno root serve sign-my-commits |
|
138 | remerge remove renames resolve revert revno root serve sign-my-commits | |
139 | status testament unbind uncommit unknowns update upgrade version |
|
139 | status testament unbind uncommit unknowns update upgrade version | |
140 | version-info visualise whoami |
|
140 | version-info visualise whoami | |
141 | """ |
|
141 | """ | |
142 |
|
142 | |||
143 | def bzr_completer(self,event): |
|
143 | def bzr_completer(self,event): | |
144 | """ Completer for bazaar commands """ |
|
144 | """ Completer for bazaar commands """ | |
145 | cmd_param = event.line.split() |
|
145 | cmd_param = event.line.split() | |
146 | if event.line.endswith(' '): |
|
146 | if event.line.endswith(' '): | |
147 | cmd_param.append('') |
|
147 | cmd_param.append('') | |
148 |
|
148 | |||
149 | if len(cmd_param) > 2: |
|
149 | if len(cmd_param) > 2: | |
150 | cmd = cmd_param[1] |
|
150 | cmd = cmd_param[1] | |
151 | param = cmd_param[-1] |
|
151 | param = cmd_param[-1] | |
152 | output_file = (param == '--output=') |
|
152 | output_file = (param == '--output=') | |
153 | if cmd == 'help': |
|
153 | if cmd == 'help': | |
154 | return bzr_commands.split() |
|
154 | return bzr_commands.split() | |
155 | elif cmd in ['bundle-revisions','conflicts', |
|
155 | elif cmd in ['bundle-revisions','conflicts', | |
156 | 'deleted','nick','register-branch', |
|
156 | 'deleted','nick','register-branch', | |
157 | 'serve','unbind','upgrade','version', |
|
157 | 'serve','unbind','upgrade','version', | |
158 | 'whoami'] and not output_file: |
|
158 | 'whoami'] and not output_file: | |
159 | return [] |
|
159 | return [] | |
160 | else: |
|
160 | else: | |
161 | # the rest are probably file names |
|
161 | # the rest are probably file names | |
162 | return ip.IP.Completer.file_matches(event.symbol) |
|
162 | return ip.IP.Completer.file_matches(event.symbol) | |
163 |
|
163 | |||
164 | return bzr_commands.split() |
|
164 | return bzr_commands.split() | |
165 |
|
165 | |||
166 | ip.set_hook('complete_command', bzr_completer, str_key = 'bzr') |
|
166 | ip.set_hook('complete_command', bzr_completer, str_key = 'bzr') | |
167 |
|
167 | |||
168 |
|
168 | |||
169 | def runlistpy(self, event): |
|
169 | def runlistpy(self, event): | |
170 | comps = shlex.split(event.line) |
|
170 | comps = shlex.split(event.line) | |
171 | relpath = (len(comps) > 1 and comps[-1] or '') |
|
171 | relpath = (len(comps) > 1 and comps[-1] or '') | |
172 |
|
172 | |||
173 | #print "rp",relpath # dbg |
|
173 | #print "rp",relpath # dbg | |
174 | lglob = glob.glob |
|
174 | lglob = glob.glob | |
175 | isdir = os.path.isdir |
|
175 | isdir = os.path.isdir | |
176 | if relpath.startswith('~'): |
|
176 | if relpath.startswith('~'): | |
177 | relpath = os.path.expanduser(relpath) |
|
177 | relpath = os.path.expanduser(relpath) | |
178 | dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*') |
|
178 | dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*') | |
179 | if isdir(f)] |
|
179 | if isdir(f)] | |
180 | pys = [f.replace('\\','/') for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy')] |
|
180 | pys = [f.replace('\\','/') for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy')] | |
181 | return dirs + pys |
|
181 | return dirs + pys | |
182 |
|
182 | |||
183 | ip.set_hook('complete_command', runlistpy, str_key = '%run') |
|
183 | ip.set_hook('complete_command', runlistpy, str_key = '%run') | |
184 |
|
184 | |||
185 | def cd_completer(self, event): |
|
185 | def cd_completer(self, event): | |
186 | relpath = event.symbol |
|
186 | relpath = event.symbol | |
187 | #print event # dbg |
|
187 | #print event # dbg | |
188 | if '-b' in event.line: |
|
188 | if '-b' in event.line: | |
189 | # return only bookmark completions |
|
189 | # return only bookmark completions | |
190 | bkms = self.db.get('bookmarks',{}) |
|
190 | bkms = self.db.get('bookmarks',{}) | |
191 | return bkms.keys() |
|
191 | return bkms.keys() | |
192 |
|
192 | |||
193 |
|
193 | |||
194 | if event.symbol == '-': |
|
194 | if event.symbol == '-': | |
195 | # jump in directory history by number |
|
195 | # jump in directory history by number | |
196 | ents = ['-%d [%s]' % (i,s) for i,s in enumerate(ip.user_ns['_dh'])] |
|
196 | ents = ['-%d [%s]' % (i,s) for i,s in enumerate(ip.user_ns['_dh'])] | |
197 | if len(ents) > 1: |
|
197 | if len(ents) > 1: | |
198 | return ents |
|
198 | return ents | |
199 | return [] |
|
199 | return [] | |
200 |
|
200 | |||
201 | if relpath.startswith('~'): |
|
201 | if relpath.startswith('~'): | |
202 | relpath = os.path.expanduser(relpath).replace('\\','/') |
|
202 | relpath = os.path.expanduser(relpath).replace('\\','/') | |
203 | found = [] |
|
203 | found = [] | |
204 | for d in [f.replace('\\','/') + '/' for f in glob.glob(relpath+'*') |
|
204 | for d in [f.replace('\\','/') + '/' for f in glob.glob(relpath+'*') | |
205 | if os.path.isdir(f)]: |
|
205 | if os.path.isdir(f)]: | |
206 | if ' ' in d: |
|
206 | if ' ' in d: | |
207 | # we don't want to deal with any of that, complex code |
|
207 | # we don't want to deal with any of that, complex code | |
208 | # for this is elsewhere |
|
208 | # for this is elsewhere | |
209 | raise IPython.ipapi.TryNext |
|
209 | raise IPython.ipapi.TryNext | |
210 | found.append( d ) |
|
210 | found.append( d ) | |
211 |
|
211 | |||
212 | if not found: |
|
212 | if not found: | |
213 | if os.path.isdir(relpath): |
|
213 | if os.path.isdir(relpath): | |
214 | return [relpath] |
|
214 | return [relpath] | |
215 | raise IPython.ipapi.TryNext |
|
215 | raise IPython.ipapi.TryNext | |
216 | return found |
|
216 | return found | |
217 |
|
217 | |||
218 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
|
218 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
@@ -1,61 +1,61 b'' | |||||
1 | """ Preliminary "job control" extensions for IPython |
|
1 | """ Preliminary "job control" extensions for IPython | |
2 |
|
2 | |||
3 | requires python 2.4 (or separate 'subprocess' module |
|
3 | requires python 2.4 (or separate 'subprocess' module | |
4 |
|
4 | |||
5 | At the moment this is in a very "unhelpful" form, will be extended in the future. |
|
5 | At the moment this is in a very "unhelpful" form, will be extended in the future. | |
6 |
|
6 | |||
7 | Usage: |
|
7 | Usage: | |
8 |
|
8 | |||
9 | [ipython]|2> import jobctrl |
|
9 | [ipython]|2> import jobctrl | |
10 | [ipython]|3> &ls |
|
10 | [ipython]|3> &ls | |
11 | <3> <jobctrl.IpyPopen object at 0x00D87FD0> |
|
11 | <3> <jobctrl.IpyPopen object at 0x00D87FD0> | |
12 | [ipython]|4> _3.go |
|
12 | [ipython]|4> _3.go | |
13 | -----------> _3.go() |
|
13 | -----------> _3.go() | |
14 | ChangeLog |
|
14 | ChangeLog | |
15 | IPython |
|
15 | IPython | |
16 | MANIFEST.in |
|
16 | MANIFEST.in | |
17 | README |
|
17 | README | |
18 | README_Windows.txt |
|
18 | README_Windows.txt | |
19 |
|
19 | |||
20 | ... |
|
20 | ... | |
21 | """ |
|
21 | """ | |
22 |
|
22 | |||
23 | from subprocess import Popen,PIPE |
|
23 | from subprocess import Popen,PIPE | |
24 | import os |
|
24 | import os,shlex | |
25 |
|
25 | |||
26 | from IPython import genutils |
|
26 | from IPython import genutils | |
27 |
|
27 | |||
28 | import IPython.ipapi |
|
28 | import IPython.ipapi | |
29 |
|
29 | |||
30 | class IpyPopen(Popen): |
|
30 | class IpyPopen(Popen): | |
31 | def go(self): |
|
31 | def go(self): | |
32 | print self.communicate()[0] |
|
32 | print self.communicate()[0] | |
33 | def __repr__(self): |
|
33 | def __repr__(self): | |
34 | return '<IPython job "%s" PID=%d>' % (self.line, self.pid) |
|
34 | return '<IPython job "%s" PID=%d>' % (self.line, self.pid) | |
35 |
|
35 | |||
36 | def kill(self): |
|
36 | def kill(self): | |
37 | assert os.name == 'nt' # xxx add posix version |
|
37 | assert os.name == 'nt' # xxx add posix version | |
38 | os.system('taskkill /PID %d' % self.pid) |
|
38 | os.system('taskkill /PID %d' % self.pid) | |
39 |
|
39 | |||
40 | def startjob(job): |
|
40 | def startjob(job): | |
41 | p = IpyPopen(job, stdout=PIPE, shell = False) |
|
41 | p = IpyPopen(shlex.split(job), stdout=PIPE, shell = False) | |
42 | p.line = job |
|
42 | p.line = job | |
43 | return p |
|
43 | return p | |
44 |
|
44 | |||
45 | def jobctrl_prefilter_f(self,line): |
|
45 | def jobctrl_prefilter_f(self,line): | |
46 | if line.startswith('&'): |
|
46 | if line.startswith('&'): | |
47 | pre,fn,rest = self.split_user_input(line[1:]) |
|
47 | pre,fn,rest = self.split_user_input(line[1:]) | |
48 |
|
48 | |||
49 | line = ip.IP.expand_aliases(fn,rest) |
|
49 | line = ip.IP.expand_aliases(fn,rest) | |
50 | return '_ip.startjob(%s)' % genutils.make_quoted_expr(line) |
|
50 | return '_ip.startjob(%s)' % genutils.make_quoted_expr(line) | |
51 |
|
51 | |||
52 | raise IPython.ipapi.TryNext |
|
52 | raise IPython.ipapi.TryNext | |
53 |
|
53 | |||
54 | def install(): |
|
54 | def install(): | |
55 | global ip |
|
55 | global ip | |
56 | ip = IPython.ipapi.get() |
|
56 | ip = IPython.ipapi.get() | |
57 | # needed to make startjob visible as _ip.startjob('blah') |
|
57 | # needed to make startjob visible as _ip.startjob('blah') | |
58 | ip.startjob = startjob |
|
58 | ip.startjob = startjob | |
59 | ip.set_hook('input_prefilter', jobctrl_prefilter_f) |
|
59 | ip.set_hook('input_prefilter', jobctrl_prefilter_f) | |
60 |
|
60 | |||
61 | install() No newline at end of file |
|
61 | install() |
@@ -1,98 +1,98 b'' | |||||
1 | """ Fun magic line editor for ipython |
|
1 | """ Fun magic line editor for ipython | |
2 |
|
2 | |||
3 | Use this to easily edit lists of strings gradually without crafting long |
|
3 | Use this to easily edit lists of strings gradually without crafting long | |
4 | list comprehensions. |
|
4 | list comprehensions. | |
5 |
|
5 | |||
6 | 'l' is the magic variable name for every line (array element). Save the current |
|
6 | 'l' is the magic variable name for every line (array element). Save the current | |
7 | result (or more exactly, retrieve the last ipython computation result into |
|
7 | result (or more exactly, retrieve the last ipython computation result into | |
8 | %led work area) by running '%led s'. Just run '%led' to show the current work |
|
8 | %led work area) by running '%led s'. Just run '%led' to show the current work | |
9 | area data. |
|
9 | area data. | |
10 |
|
10 | |||
11 | Example use: |
|
11 | Example use: | |
12 |
|
12 | |||
13 | [ipython]|25> setups = !ls *setup*.py |
|
13 | [ipython]|25> setups = !ls *setup*.py | |
14 | == |
|
14 | == | |
15 | ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] |
|
15 | ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] | |
16 | [ipython]|26> setups |
|
16 | [ipython]|26> setups | |
17 | <26> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] |
|
17 | <26> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] | |
18 | [ipython]|27> %led s |
|
18 | [ipython]|27> %led s | |
19 | Data set from last result (_) |
|
19 | Data set from last result (_) | |
20 | <27> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] |
|
20 | <27> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] | |
21 | [ipython]|28> %led upper |
|
21 | [ipython]|28> %led upper | |
22 | cmd translated => l.upper() |
|
22 | cmd translated => l.upper() | |
23 | <28> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] |
|
23 | <28> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] | |
24 | [ipython]|29> %led |
|
24 | [ipython]|29> %led | |
25 | Magic line editor (for lists of strings) |
|
25 | Magic line editor (for lists of strings) | |
26 | current data is: |
|
26 | current data is: | |
27 | ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] |
|
27 | ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py'] | |
28 | [ipython]|30> %led upper |
|
28 | [ipython]|30> %led upper | |
29 | cmd translated => l.upper() |
|
29 | cmd translated => l.upper() | |
30 | <30> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] |
|
30 | <30> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] | |
31 | [ipython]|31> %led s |
|
31 | [ipython]|31> %led s | |
32 | Data set from last result (_) |
|
32 | Data set from last result (_) | |
33 | <31> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] |
|
33 | <31> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY'] | |
34 | [ipython]|32> %led "n:" + l |
|
34 | [ipython]|32> %led "n:" + l | |
35 | <32> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY'] |
|
35 | <32> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY'] | |
36 | [ipython]|33> %led s |
|
36 | [ipython]|33> %led s | |
37 | Data set from last result (_) |
|
37 | Data set from last result (_) | |
38 | <33> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY'] |
|
38 | <33> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY'] | |
39 | [ipython]|34> %led l. |
|
39 | [ipython]|34> %led l. | |
40 | l.__add__ l.__gt__ l.__reduce_ex__ l.endswith l.join l.rstrip |
|
40 | l.__add__ l.__gt__ l.__reduce_ex__ l.endswith l.join l.rstrip | |
41 | l.__class__ l.__hash__ l.__repr__ l.expandtabs l.ljust l.split |
|
41 | l.__class__ l.__hash__ l.__repr__ l.expandtabs l.ljust l.split | |
42 |
|
42 | |||
43 | ... (completions for string variable shown ) ... |
|
43 | ... (completions for string variable shown ) ... | |
44 |
|
44 | |||
45 | """ |
|
45 | """ | |
46 | import IPython.ipapi |
|
46 | import IPython.ipapi | |
47 | import pprint |
|
47 | import pprint | |
48 | ip = IPython.ipapi.get() |
|
48 | ip = IPython.ipapi.get() | |
49 |
|
49 | |||
50 | curdata = [] |
|
50 | curdata = [] | |
51 |
|
51 | |||
52 | def line_edit_f(self, cmd ): |
|
52 | def line_edit_f(self, cmd ): | |
53 | global curdata |
|
53 | global curdata | |
54 |
|
54 | |||
55 | if not cmd: |
|
55 | if not cmd: | |
56 |
|
56 | |||
57 | print "Magic line editor (for lists of strings)" |
|
57 | print "Magic line editor (for lists of strings)" | |
58 | if curdata: |
|
58 | if curdata: | |
59 | print "current data is:" |
|
59 | print "current data is:" | |
60 | pprint.pprint(curdata) |
|
60 | pprint.pprint(curdata) | |
61 | else: |
|
61 | else: | |
62 | print "No current data, you should set it by running '%led s'" |
|
62 | print "No current data, you should set it by running '%led s'" | |
63 | print "When you have your data in _ (result of last computation)." |
|
63 | print "When you have your data in _ (result of last computation)." | |
64 | return |
|
64 | return | |
65 |
|
65 | |||
66 | if cmd == 's': |
|
66 | if cmd == 's': | |
67 | curdata = ip.ev('_') |
|
67 | curdata = ip.ev('_') | |
68 | print "Data set from last result (_)" |
|
68 | print "Data set from last result (_)" | |
69 | newlines = curdata |
|
69 | newlines = curdata | |
70 |
|
70 | |||
71 | else: |
|
71 | else: | |
72 | # simple method call, e.g. upper |
|
72 | # simple method call, e.g. upper | |
73 | if cmd.isalpha(): |
|
73 | if cmd.isalpha(): | |
74 | cmd = 'l.' + cmd + '()' |
|
74 | cmd = 'l.' + cmd + '()' | |
75 | print "cmd translated =>",cmd |
|
75 | print "cmd translated =>",cmd | |
76 |
|
76 | |||
77 | newlines = [] |
|
77 | newlines = [] | |
78 | for l in curdata: |
|
78 | for l in curdata: | |
79 | try: |
|
79 | try: | |
80 | l2 = eval(cmd) |
|
80 | l2 = eval(cmd) | |
81 | except Exception,e: |
|
81 | except Exception,e: | |
82 | print "Dropping exception",e,"on line:",l |
|
82 | print "Dropping exception",e,"on line:",l | |
83 | continue |
|
83 | continue | |
84 | newlines.append(l2) |
|
84 | newlines.append(l2) | |
85 |
|
85 | |||
86 |
|
86 | |||
87 | return newlines |
|
87 | return newlines | |
88 |
|
88 | |||
89 | def line_edit_complete_f(self,event): |
|
89 | def line_edit_complete_f(self,event): | |
90 | """ Show all string methods in completions """ |
|
90 | """ Show all string methods in completions """ | |
91 | if event.symbol.startswith('l.'): |
|
91 | if event.symbol.startswith('l.'): | |
92 | return ['l.' + func for func in dir('')] |
|
92 | return ['l.' + func for func in dir('')] | |
93 |
|
93 | |||
94 | return dir('') + ['l.' + func for func in dir('')] |
|
94 | return dir('') + ['l.' + func for func in dir('')] | |
95 |
|
95 | |||
96 | ip.set_hook('complete_command', line_edit_complete_f , str_key = '%led') |
|
96 | ip.set_hook('complete_command', line_edit_complete_f , str_key = '%led') | |
97 |
|
97 | |||
98 | ip.expose_magic('led', line_edit_f) No newline at end of file |
|
98 | ip.expose_magic('led', line_edit_f) |
@@ -1,86 +1,85 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Release data for the IPython project. |
|
2 | """Release data for the IPython project. | |
3 |
|
3 | |||
4 |
$Id: Release.py |
|
4 | $Id: Release.py 2010 2006-12-20 15:29:17Z vivainio $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
7 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
8 | # |
|
8 | # | |
9 | # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray |
|
9 | # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray | |
10 | # <n8gray@caltech.edu> |
|
10 | # <n8gray@caltech.edu> | |
11 | # |
|
11 | # | |
12 | # Distributed under the terms of the BSD License. The full license is in |
|
12 | # Distributed under the terms of the BSD License. The full license is in | |
13 | # the file COPYING, distributed as part of this software. |
|
13 | # the file COPYING, distributed as part of this software. | |
14 | #***************************************************************************** |
|
14 | #***************************************************************************** | |
15 |
|
15 | |||
16 | # Name of the package for release purposes. This is the name which labels |
|
16 | # Name of the package for release purposes. This is the name which labels | |
17 | # the tarballs and RPMs made by distutils, so it's best to lowercase it. |
|
17 | # the tarballs and RPMs made by distutils, so it's best to lowercase it. | |
18 | name = 'ipython' |
|
18 | name = 'ipython' | |
19 |
|
19 | |||
20 | # For versions with substrings (like 0.6.16.svn), use an extra . to separate |
|
20 | # For versions with substrings (like 0.6.16.svn), use an extra . to separate | |
21 | # the new substring. We have to avoid using either dashes or underscores, |
|
21 | # the new substring. We have to avoid using either dashes or underscores, | |
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and |
|
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and | |
23 | # bdist_deb does not accept underscores (a Debian convention). |
|
23 | # bdist_deb does not accept underscores (a Debian convention). | |
24 |
|
24 | |||
25 |
revision = ' |
|
25 | revision = '2007' | |
26 |
|
26 | |||
27 |
|
|
27 | version = '0.7.3' | |
28 |
|
||||
29 | version = '0.7.3b3.r' + revision.rstrip('M') |
|
|||
30 |
|
28 | |||
|
29 | #version = '0.7.3rc2.r' + revision.rstrip('M') | |||
31 |
|
30 | |||
32 | description = "An enhanced interactive Python shell." |
|
31 | description = "An enhanced interactive Python shell." | |
33 |
|
32 | |||
34 | long_description = \ |
|
33 | long_description = \ | |
35 | """ |
|
34 | """ | |
36 | IPython provides a replacement for the interactive Python interpreter with |
|
35 | IPython provides a replacement for the interactive Python interpreter with | |
37 | extra functionality. |
|
36 | extra functionality. | |
38 |
|
37 | |||
39 | Main features: |
|
38 | Main features: | |
40 |
|
39 | |||
41 | * Comprehensive object introspection. |
|
40 | * Comprehensive object introspection. | |
42 |
|
41 | |||
43 | * Input history, persistent across sessions. |
|
42 | * Input history, persistent across sessions. | |
44 |
|
43 | |||
45 | * Caching of output results during a session with automatically generated |
|
44 | * Caching of output results during a session with automatically generated | |
46 | references. |
|
45 | references. | |
47 |
|
46 | |||
48 | * Readline based name completion. |
|
47 | * Readline based name completion. | |
49 |
|
48 | |||
50 | * Extensible system of 'magic' commands for controlling the environment and |
|
49 | * Extensible system of 'magic' commands for controlling the environment and | |
51 | performing many tasks related either to IPython or the operating system. |
|
50 | performing many tasks related either to IPython or the operating system. | |
52 |
|
51 | |||
53 | * Configuration system with easy switching between different setups (simpler |
|
52 | * Configuration system with easy switching between different setups (simpler | |
54 | than changing $PYTHONSTARTUP environment variables every time). |
|
53 | than changing $PYTHONSTARTUP environment variables every time). | |
55 |
|
54 | |||
56 | * Session logging and reloading. |
|
55 | * Session logging and reloading. | |
57 |
|
56 | |||
58 | * Extensible syntax processing for special purpose situations. |
|
57 | * Extensible syntax processing for special purpose situations. | |
59 |
|
58 | |||
60 | * Access to the system shell with user-extensible alias system. |
|
59 | * Access to the system shell with user-extensible alias system. | |
61 |
|
60 | |||
62 | * Easily embeddable in other Python programs. |
|
61 | * Easily embeddable in other Python programs. | |
63 |
|
62 | |||
64 | * Integrated access to the pdb debugger and the Python profiler. |
|
63 | * Integrated access to the pdb debugger and the Python profiler. | |
65 |
|
64 | |||
66 | The latest development version is always available at the IPython subversion |
|
65 | The latest development version is always available at the IPython subversion | |
67 | repository_. |
|
66 | repository_. | |
68 |
|
67 | |||
69 | .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev |
|
68 | .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev | |
70 | """ |
|
69 | """ | |
71 |
|
70 | |||
72 | license = 'BSD' |
|
71 | license = 'BSD' | |
73 |
|
72 | |||
74 | authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), |
|
73 | authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), | |
75 | 'Janko' : ('Janko Hauser','jhauser@zscout.de'), |
|
74 | 'Janko' : ('Janko Hauser','jhauser@zscout.de'), | |
76 | 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'), |
|
75 | 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'), | |
77 | 'Ville' : ('Ville Vainio','vivainio@gmail.com') |
|
76 | 'Ville' : ('Ville Vainio','vivainio@gmail.com') | |
78 | } |
|
77 | } | |
79 |
|
78 | |||
80 | url = 'http://ipython.scipy.org' |
|
79 | url = 'http://ipython.scipy.org' | |
81 |
|
80 | |||
82 | download_url = 'http://ipython.scipy.org/dist' |
|
81 | download_url = 'http://ipython.scipy.org/dist' | |
83 |
|
82 | |||
84 | platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'] |
|
83 | platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'] | |
85 |
|
84 | |||
86 | keywords = ['Interactive','Interpreter','Shell'] |
|
85 | keywords = ['Interactive','Interpreter','Shell'] |
@@ -1,54 +1,54 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ Imports and provides the "correct" version of readline for the platform. |
|
2 | """ Imports and provides the "correct" version of readline for the platform. | |
3 |
|
3 | |||
4 | Readline is used throughout IPython as "import IPython.rlineimpl as readline. |
|
4 | Readline is used throughout IPython as "import IPython.rlineimpl as readline. | |
5 |
|
5 | |||
6 | In addition to normal readline stuff, this module provides have_readline boolean |
|
6 | In addition to normal readline stuff, this module provides have_readline boolean | |
7 | and _outputfile variable used in genutils. |
|
7 | and _outputfile variable used in genutils. | |
8 |
|
8 | |||
9 | $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" |
|
9 | $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $""" | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | import sys |
|
12 | import sys | |
13 |
|
13 | |||
14 | have_readline = False |
|
14 | have_readline = False | |
15 |
|
15 | |||
16 | if sys.platform == 'win32': |
|
16 | if sys.platform == 'win32': | |
17 | try: |
|
17 | try: | |
18 | import pyreadline.rlmain |
|
18 | import pyreadline.rlmain | |
19 | #add config for inputrcpath here: |
|
19 | #add config for inputrcpath here: | |
20 | #pyreadline.rlmain.config_path="c:/python/test_config.ini" |
|
20 | #pyreadline.rlmain.config_path="c:/python/test_config.ini" | |
21 | from readline import * |
|
21 | from readline import * | |
22 | #print "Using the new pyreadline (thanks for participating in the testing!)" |
|
22 | #print "Using the new pyreadline (thanks for participating in the testing!)" | |
23 |
|
23 | |||
24 | have_readline = True |
|
24 | have_readline = True | |
25 |
|
25 | |||
26 | import readline as _rl |
|
26 | import readline as _rl | |
27 | except ImportError: |
|
27 | except ImportError: | |
28 | #print "IPython team recommends the new pyreadline for Windows use, " |
|
28 | #print "IPython team recommends the new pyreadline for Windows use, " | |
29 | #print "It's superior especially with non-US keyboard layouts." |
|
29 | #print "It's superior especially with non-US keyboard layouts." | |
30 | #print "Try installing it with 'easy_install pyreadline (ctypes is required) or" |
|
30 | #print "Try installing it with 'easy_install pyreadline (ctypes is required) or" | |
31 | #print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline" |
|
31 | #print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline" | |
32 | #print "Trying 'old' windows readline." |
|
32 | #print "Trying 'old' windows readline." | |
33 | #print "Using 'old' readline, you might want to try pyreadline:" |
|
33 | #print "Using 'old' readline, you might want to try pyreadline:" | |
34 | #print "http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro" |
|
34 | #print "http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro" | |
35 | try: |
|
35 | try: | |
36 | from readline import * |
|
36 | from readline import * | |
37 | import readline as _rl |
|
37 | import readline as _rl | |
38 | have_readline = True |
|
38 | have_readline = True | |
39 | except ImportError: |
|
39 | except ImportError: | |
40 | pass |
|
40 | pass | |
41 |
|
41 | |||
42 | if have_readline: |
|
42 | if have_readline: | |
43 | try: |
|
43 | try: | |
44 | _outputfile=_rl.GetOutputFile() |
|
44 | _outputfile=_rl.GetOutputFile() | |
45 | except NameError: |
|
45 | except NameError: | |
46 | print "Failed GetOutputFile" |
|
46 | print "Failed GetOutputFile" | |
47 | have_readline = False |
|
47 | have_readline = False | |
48 |
|
48 | |||
49 | else: |
|
49 | else: | |
50 | try: |
|
50 | try: | |
51 | from readline import * |
|
51 | from readline import * | |
52 | have_readline = True |
|
52 | have_readline = True | |
53 | except ImportError: |
|
53 | except ImportError: | |
54 | pass |
|
54 | pass |
@@ -1,65 +1,65 b'' | |||||
1 | from IPython.hooks import CommandChainDispatcher |
|
1 | from IPython.hooks import CommandChainDispatcher | |
2 | import IPython.hooks |
|
2 | import IPython.hooks | |
3 |
|
3 | |||
4 | import re |
|
4 | import re | |
5 |
|
5 | |||
6 | class StrDispatch(object): |
|
6 | class StrDispatch(object): | |
7 | """ Dispatch (lookup) a set of strings / regexps for match """ |
|
7 | """ Dispatch (lookup) a set of strings / regexps for match """ | |
8 | def __init__(self): |
|
8 | def __init__(self): | |
9 | self.strs = {} |
|
9 | self.strs = {} | |
10 | self.regexs = {} |
|
10 | self.regexs = {} | |
11 | def add_s(self, s, obj, priority= 0 ): |
|
11 | def add_s(self, s, obj, priority= 0 ): | |
12 | """ Adds a target 'string' for dispatching """ |
|
12 | """ Adds a target 'string' for dispatching """ | |
13 |
|
13 | |||
14 | chain = self.strs.get(s, CommandChainDispatcher()) |
|
14 | chain = self.strs.get(s, CommandChainDispatcher()) | |
15 | chain.add(obj,priority) |
|
15 | chain.add(obj,priority) | |
16 | self.strs[s] = chain |
|
16 | self.strs[s] = chain | |
17 |
|
17 | |||
18 | def add_re(self, regex, obj, priority= 0 ): |
|
18 | def add_re(self, regex, obj, priority= 0 ): | |
19 | """ Adds a target regexp for dispatching """ |
|
19 | """ Adds a target regexp for dispatching """ | |
20 |
|
20 | |||
21 | chain = self.regexs.get(regex, CommandChainDispatcher()) |
|
21 | chain = self.regexs.get(regex, CommandChainDispatcher()) | |
22 | chain.add(obj,priority) |
|
22 | chain.add(obj,priority) | |
23 | self.regexs[regex] = chain |
|
23 | self.regexs[regex] = chain | |
24 |
|
24 | |||
25 | def dispatch(self, key): |
|
25 | def dispatch(self, key): | |
26 | """ Get a seq of Commandchain objects that match key """ |
|
26 | """ Get a seq of Commandchain objects that match key """ | |
27 | if key in self.strs: |
|
27 | if key in self.strs: | |
28 | yield self.strs[key] |
|
28 | yield self.strs[key] | |
29 |
|
29 | |||
30 | for r, obj in self.regexs.items(): |
|
30 | for r, obj in self.regexs.items(): | |
31 | if re.match(r, key): |
|
31 | if re.match(r, key): | |
32 | yield obj |
|
32 | yield obj | |
33 | else: |
|
33 | else: | |
34 | #print "nomatch",key |
|
34 | #print "nomatch",key | |
35 | pass |
|
35 | pass | |
36 |
|
36 | |||
37 |
|
37 | |||
38 | def __repr__(self): |
|
38 | def __repr__(self): | |
39 | return "<Strdispatch %s, %s>" % (self.strs, self.regexs) |
|
39 | return "<Strdispatch %s, %s>" % (self.strs, self.regexs) | |
40 |
|
40 | |||
41 | def s_matches(self, key): |
|
41 | def s_matches(self, key): | |
42 | if key not in self.strs: |
|
42 | if key not in self.strs: | |
43 | return |
|
43 | return | |
44 | for el in self.strs[key]: |
|
44 | for el in self.strs[key]: | |
45 | yield el[1] |
|
45 | yield el[1] | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | def flat_matches(self, key): |
|
48 | def flat_matches(self, key): | |
49 | """ Yield all 'value' targets, without priority """ |
|
49 | """ Yield all 'value' targets, without priority """ | |
50 | for val in self.dispatch(key): |
|
50 | for val in self.dispatch(key): | |
51 | for el in val: |
|
51 | for el in val: | |
52 | yield el[1] # only value, no priority |
|
52 | yield el[1] # only value, no priority | |
53 | return |
|
53 | return | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | def test(): |
|
56 | def test(): | |
57 | d = StrDispatch() |
|
57 | d = StrDispatch() | |
58 | d.add_s('hei',34, priority = 4) |
|
58 | d.add_s('hei',34, priority = 4) | |
59 | d.add_s('hei',123, priority = 2) |
|
59 | d.add_s('hei',123, priority = 2) | |
60 | print list(d.dispatch('hei')) |
|
60 | print list(d.dispatch('hei')) | |
61 | d.add_re('h.i', 686) |
|
61 | d.add_re('h.i', 686) | |
62 | print list(d.flat_matches('hei')) |
|
62 | print list(d.flat_matches('hei')) | |
63 |
|
63 | |||
64 | if __name__ == '__main__': |
|
64 | if __name__ == '__main__': | |
65 | test() No newline at end of file |
|
65 | test() |
@@ -1,94 +1,94 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | """ A script/util to upgrade all files in a directory |
|
2 | """ A script/util to upgrade all files in a directory | |
3 |
|
3 | |||
4 | This is rather conservative in its approach, only copying/overwriting |
|
4 | This is rather conservative in its approach, only copying/overwriting | |
5 | new and unedited files. |
|
5 | new and unedited files. | |
6 |
|
6 | |||
7 | To be used by "upgrade" feature. |
|
7 | To be used by "upgrade" feature. | |
8 | """ |
|
8 | """ | |
9 | try: |
|
9 | try: | |
10 | from IPython.Extensions.path import path |
|
10 | from IPython.Extensions.path import path | |
11 | except ImportError: |
|
11 | except ImportError: | |
12 | try: |
|
12 | try: | |
13 | from Extensions.path import path |
|
13 | from Extensions.path import path | |
14 | except ImportError: |
|
14 | except ImportError: | |
15 | from path import path |
|
15 | from path import path | |
16 |
|
16 | |||
17 | import md5,pickle |
|
17 | import md5,pickle | |
18 |
|
18 | |||
19 | def showdiff(old,new): |
|
19 | def showdiff(old,new): | |
20 | import difflib |
|
20 | import difflib | |
21 | d = difflib.Differ() |
|
21 | d = difflib.Differ() | |
22 | lines = d.compare(old.lines(),new.lines()) |
|
22 | lines = d.compare(old.lines(),new.lines()) | |
23 | realdiff = False |
|
23 | realdiff = False | |
24 | for l in lines: |
|
24 | for l in lines: | |
25 | print l, |
|
25 | print l, | |
26 | if not realdiff and not l[0].isspace(): |
|
26 | if not realdiff and not l[0].isspace(): | |
27 | realdiff = True |
|
27 | realdiff = True | |
28 | return realdiff |
|
28 | return realdiff | |
29 |
|
29 | |||
30 | def upgrade_dir(srcdir, tgtdir): |
|
30 | def upgrade_dir(srcdir, tgtdir): | |
31 | """ Copy over all files in srcdir to tgtdir w/ native line endings |
|
31 | """ Copy over all files in srcdir to tgtdir w/ native line endings | |
32 |
|
32 | |||
33 | Creates .upgrade_report in tgtdir that stores md5sums of all files |
|
33 | Creates .upgrade_report in tgtdir that stores md5sums of all files | |
34 | to notice changed files b/w upgrades. |
|
34 | to notice changed files b/w upgrades. | |
35 | """ |
|
35 | """ | |
36 |
|
36 | |||
37 | def pr(s): |
|
37 | def pr(s): | |
38 | print s |
|
38 | print s | |
39 |
|
39 | |||
40 | def ignorable(p): |
|
40 | def ignorable(p): | |
41 | if p.lower().startswith('.svn') or p.startswith('ipythonrc'): |
|
41 | if p.lower().startswith('.svn') or p.startswith('ipythonrc'): | |
42 | return True |
|
42 | return True | |
43 | return False |
|
43 | return False | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | modded = [] |
|
46 | modded = [] | |
47 | files = [path(srcdir).relpathto(p) for p in path(srcdir).walkfiles()] |
|
47 | files = [path(srcdir).relpathto(p) for p in path(srcdir).walkfiles()] | |
48 | #print files |
|
48 | #print files | |
49 | rep = tgtdir / '.upgrade_report' |
|
49 | rep = tgtdir / '.upgrade_report' | |
50 | try: |
|
50 | try: | |
51 | rpt = pickle.load(rep.open()) |
|
51 | rpt = pickle.load(rep.open()) | |
52 | except: |
|
52 | except: | |
53 | rpt = {} |
|
53 | rpt = {} | |
54 |
|
54 | |||
55 | for f in files: |
|
55 | for f in files: | |
56 | if ignorable(f): |
|
56 | if ignorable(f): | |
57 | continue |
|
57 | continue | |
58 | src = srcdir / f |
|
58 | src = srcdir / f | |
59 | tgt = tgtdir / f |
|
59 | tgt = tgtdir / f | |
60 | if not tgt.isfile(): |
|
60 | if not tgt.isfile(): | |
61 | pr("Creating %s" % str(tgt)) |
|
61 | pr("Creating %s" % str(tgt)) | |
62 |
|
62 | |||
63 | tgt.write_text(src.text()) |
|
63 | tgt.write_text(src.text()) | |
64 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() |
|
64 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() | |
65 | else: |
|
65 | else: | |
66 | cont = tgt.text() |
|
66 | cont = tgt.text() | |
67 | sum = rpt.get(str(tgt), None) |
|
67 | sum = rpt.get(str(tgt), None) | |
68 | #print sum |
|
68 | #print sum | |
69 | if sum and md5.new(cont).hexdigest() == sum: |
|
69 | if sum and md5.new(cont).hexdigest() == sum: | |
70 | pr("Unedited, installing new %s" % tgt) |
|
70 | pr("Unedited, installing new %s" % tgt) | |
71 | tgt.write_text(src.text()) |
|
71 | tgt.write_text(src.text()) | |
72 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() |
|
72 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() | |
73 | else: |
|
73 | else: | |
74 | pr(' == Modified, skipping %s, diffs below == ' % tgt) |
|
74 | pr(' == Modified, skipping %s, diffs below == ' % tgt) | |
75 | #rpt[str(tgt)] = md5.new(tgt.bytes()).hexdigest() |
|
75 | #rpt[str(tgt)] = md5.new(tgt.bytes()).hexdigest() | |
76 | real = showdiff(tgt,src) |
|
76 | real = showdiff(tgt,src) | |
77 | pr('') # empty line |
|
77 | pr('') # empty line | |
78 | if not real: |
|
78 | if not real: | |
79 | pr("(Ok, it wasn't that different at all, upgrading checksum)") |
|
79 | pr("(Ok, it wasn't that different at all, upgrading checksum)") | |
80 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() |
|
80 | rpt[str(tgt)] = md5.new(tgt.text()).hexdigest() | |
81 | else: |
|
81 | else: | |
82 | modded.append(tgt) |
|
82 | modded.append(tgt) | |
83 |
|
83 | |||
84 | #print rpt |
|
84 | #print rpt | |
85 | pickle.dump(rpt, rep.open('w')) |
|
85 | pickle.dump(rpt, rep.open('w')) | |
86 | if modded: |
|
86 | if modded: | |
87 | print "\n\nDelete the following files manually (and rerun %upgrade)\nif you need a full upgrade:" |
|
87 | print "\n\nDelete the following files manually (and rerun %upgrade)\nif you need a full upgrade:" | |
88 | for m in modded: |
|
88 | for m in modded: | |
89 | print m |
|
89 | print m | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | import sys |
|
92 | import sys | |
93 | if __name__ == "__main__": |
|
93 | if __name__ == "__main__": | |
94 | upgrade_dir(path(sys.argv[1]), path(sys.argv[2])) |
|
94 | upgrade_dir(path(sys.argv[1]), path(sys.argv[2])) |
@@ -1,641 +1,642 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | #***************************************************************************** |
|
2 | #***************************************************************************** | |
3 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> |
|
3 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> | |
4 | # |
|
4 | # | |
5 | # Distributed under the terms of the BSD License. The full license is in |
|
5 | # Distributed under the terms of the BSD License. The full license is in | |
6 | # the file COPYING, distributed as part of this software. |
|
6 | # the file COPYING, distributed as part of this software. | |
7 | #***************************************************************************** |
|
7 | #***************************************************************************** | |
8 |
|
8 | |||
9 |
# $Id: usage.py |
|
9 | # $Id: usage.py 2010 2006-12-20 15:29:17Z vivainio $ | |
10 |
|
10 | |||
11 | from IPython import Release |
|
11 | from IPython import Release | |
12 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
12 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
13 | __license__ = Release.license |
|
13 | __license__ = Release.license | |
14 | __version__ = Release.version |
|
14 | __version__ = Release.version | |
15 |
|
15 | |||
16 | __doc__ = """ |
|
16 | __doc__ = """ | |
17 | IPython -- An enhanced Interactive Python |
|
17 | IPython -- An enhanced Interactive Python | |
18 | ========================================= |
|
18 | ========================================= | |
19 |
|
19 | |||
20 | A Python shell with automatic history (input and output), dynamic object |
|
20 | A Python shell with automatic history (input and output), dynamic object | |
21 | introspection, easier configuration, command completion, access to the system |
|
21 | introspection, easier configuration, command completion, access to the system | |
22 | shell and more. |
|
22 | shell and more. | |
23 |
|
23 | |||
24 | IPython can also be embedded in running programs. See EMBEDDING below. |
|
24 | IPython can also be embedded in running programs. See EMBEDDING below. | |
25 |
|
25 | |||
26 |
|
26 | |||
27 | USAGE |
|
27 | USAGE | |
28 | ipython [options] files |
|
28 | ipython [options] files | |
29 |
|
29 | |||
30 | If invoked with no options, it executes all the files listed in |
|
30 | If invoked with no options, it executes all the files listed in | |
31 | sequence and drops you into the interpreter while still acknowledging |
|
31 | sequence and drops you into the interpreter while still acknowledging | |
32 | any options you may have set in your ipythonrc file. This behavior is |
|
32 | any options you may have set in your ipythonrc file. This behavior is | |
33 | different from standard Python, which when called as python -i will |
|
33 | different from standard Python, which when called as python -i will | |
34 | only execute one file and will ignore your configuration setup. |
|
34 | only execute one file and will ignore your configuration setup. | |
35 |
|
35 | |||
36 | Please note that some of the configuration options are not available at |
|
36 | Please note that some of the configuration options are not available at | |
37 | the command line, simply because they are not practical here. Look into |
|
37 | the command line, simply because they are not practical here. Look into | |
38 | your ipythonrc configuration file for details on those. This file |
|
38 | your ipythonrc configuration file for details on those. This file | |
39 | typically installed in the $HOME/.ipython directory. |
|
39 | typically installed in the $HOME/.ipython directory. | |
40 |
|
40 | |||
41 | For Windows users, $HOME resolves to C:\\Documents and |
|
41 | For Windows users, $HOME resolves to C:\\Documents and | |
42 | Settings\\YourUserName in most instances, and _ipython is used instead |
|
42 | Settings\\YourUserName in most instances, and _ipython is used instead | |
43 | of .ipython, since some Win32 programs have problems with dotted names |
|
43 | of .ipython, since some Win32 programs have problems with dotted names | |
44 | in directories. |
|
44 | in directories. | |
45 |
|
45 | |||
46 | In the rest of this text, we will refer to this directory as |
|
46 | In the rest of this text, we will refer to this directory as | |
47 | IPYTHONDIR. |
|
47 | IPYTHONDIR. | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | SPECIAL THREADING OPTIONS |
|
50 | SPECIAL THREADING OPTIONS | |
51 | The following special options are ONLY valid at the beginning of the |
|
51 | The following special options are ONLY valid at the beginning of the | |
52 | command line, and not later. This is because they control the initial- |
|
52 | command line, and not later. This is because they control the initial- | |
53 | ization of ipython itself, before the normal option-handling mechanism |
|
53 | ization of ipython itself, before the normal option-handling mechanism | |
54 | is active. |
|
54 | is active. | |
55 |
|
55 | |||
56 | -gthread, -qthread, -wthread, -pylab |
|
56 | -gthread, -qthread, -wthread, -pylab | |
57 |
|
57 | |||
58 | Only ONE of these can be given, and it can only be given as the |
|
58 | Only ONE of these can be given, and it can only be given as the | |
59 | first option passed to IPython (it will have no effect in any |
|
59 | first option passed to IPython (it will have no effect in any | |
60 | other position). They provide threading support for the GTK, QT |
|
60 | other position). They provide threading support for the GTK, QT | |
61 | and WXWidgets toolkits, and for the matplotlib library. |
|
61 | and WXWidgets toolkits, and for the matplotlib library. | |
62 |
|
62 | |||
63 | With any of the first three options, IPython starts running a |
|
63 | With any of the first three options, IPython starts running a | |
64 | separate thread for the graphical toolkit's operation, so that |
|
64 | separate thread for the graphical toolkit's operation, so that | |
65 | you can open and control graphical elements from within an |
|
65 | you can open and control graphical elements from within an | |
66 | IPython command line, without blocking. All three provide |
|
66 | IPython command line, without blocking. All three provide | |
67 | essentially the same functionality, respectively for GTK, QT and |
|
67 | essentially the same functionality, respectively for GTK, QT and | |
68 | WXWidgets (via their Python interfaces). |
|
68 | WXWidgets (via their Python interfaces). | |
69 |
|
69 | |||
70 | Note that with -wthread, you can additionally use the -wxversion |
|
70 | Note that with -wthread, you can additionally use the -wxversion | |
71 | option to request a specific version of wx to be used. This |
|
71 | option to request a specific version of wx to be used. This | |
72 | requires that you have the 'wxversion' Python module installed, |
|
72 | requires that you have the 'wxversion' Python module installed, | |
73 | which is part of recent wxPython distributions. |
|
73 | which is part of recent wxPython distributions. | |
74 |
|
74 | |||
75 | If -pylab is given, IPython loads special support for the mat- |
|
75 | If -pylab is given, IPython loads special support for the mat- | |
76 | plotlib library (http://matplotlib.sourceforge.net), allowing |
|
76 | plotlib library (http://matplotlib.sourceforge.net), allowing | |
77 | interactive usage of any of its backends as defined in the |
|
77 | interactive usage of any of its backends as defined in the | |
78 | user's .matplotlibrc file. It automatically activates GTK, QT |
|
78 | user's .matplotlibrc file. It automatically activates GTK, QT | |
79 | or WX threading for IPyhton if the choice of matplotlib backend |
|
79 | or WX threading for IPyhton if the choice of matplotlib backend | |
80 | requires it. It also modifies the %run command to correctly |
|
80 | requires it. It also modifies the %run command to correctly | |
81 | execute (without blocking) any matplotlib-based script which |
|
81 | execute (without blocking) any matplotlib-based script which | |
82 | calls show() at the end. |
|
82 | calls show() at the end. | |
83 |
|
83 | |||
84 | -tk The -g/q/wthread options, and -pylab (if matplotlib is |
|
84 | -tk The -g/q/wthread options, and -pylab (if matplotlib is | |
85 | configured to use GTK, QT or WX), will normally block Tk |
|
85 | configured to use GTK, QT or WX), will normally block Tk | |
86 | graphical interfaces. This means that when GTK, QT or WX |
|
86 | graphical interfaces. This means that when GTK, QT or WX | |
87 | threading is active, any attempt to open a Tk GUI will result in |
|
87 | threading is active, any attempt to open a Tk GUI will result in | |
88 | a dead window, and possibly cause the Python interpreter to |
|
88 | a dead window, and possibly cause the Python interpreter to | |
89 | crash. An extra option, -tk, is available to address this |
|
89 | crash. An extra option, -tk, is available to address this | |
90 | issue. It can ONLY be given as a SECOND option after any of the |
|
90 | issue. It can ONLY be given as a SECOND option after any of the | |
91 | above (-gthread, -qthread, -wthread or -pylab). |
|
91 | above (-gthread, -qthread, -wthread or -pylab). | |
92 |
|
92 | |||
93 | If -tk is given, IPython will try to coordinate Tk threading |
|
93 | If -tk is given, IPython will try to coordinate Tk threading | |
94 | with GTK, QT or WX. This is however potentially unreliable, and |
|
94 | with GTK, QT or WX. This is however potentially unreliable, and | |
95 | you will have to test on your platform and Python configuration |
|
95 | you will have to test on your platform and Python configuration | |
96 | to determine whether it works for you. Debian users have |
|
96 | to determine whether it works for you. Debian users have | |
97 | reported success, apparently due to the fact that Debian builds |
|
97 | reported success, apparently due to the fact that Debian builds | |
98 | all of Tcl, Tk, Tkinter and Python with pthreads support. Under |
|
98 | all of Tcl, Tk, Tkinter and Python with pthreads support. Under | |
99 | other Linux environments (such as Fedora Core 2/3), this option |
|
99 | other Linux environments (such as Fedora Core 2/3), this option | |
100 | has caused random crashes and lockups of the Python interpreter. |
|
100 | has caused random crashes and lockups of the Python interpreter. | |
101 | Under other operating systems (Mac OSX and Windows), you'll need |
|
101 | Under other operating systems (Mac OSX and Windows), you'll need | |
102 | to try it to find out, since currently no user reports are |
|
102 | to try it to find out, since currently no user reports are | |
103 | available. |
|
103 | available. | |
104 |
|
104 | |||
105 | There is unfortunately no way for IPython to determine at run- |
|
105 | There is unfortunately no way for IPython to determine at run- | |
106 | time whether -tk will work reliably or not, so you will need to |
|
106 | time whether -tk will work reliably or not, so you will need to | |
107 | do some experiments before relying on it for regular work. |
|
107 | do some experiments before relying on it for regular work. | |
108 |
|
108 | |||
109 | A WARNING ABOUT SIGNALS AND THREADS |
|
109 | A WARNING ABOUT SIGNALS AND THREADS | |
110 |
|
110 | |||
111 | When any of the thread systems (GTK, QT or WX) are active, either |
|
111 | When any of the thread systems (GTK, QT or WX) are active, either | |
112 | directly or via -pylab with a threaded backend, it is impossible to |
|
112 | directly or via -pylab with a threaded backend, it is impossible to | |
113 | interrupt long-running Python code via Ctrl-C. IPython can not pass |
|
113 | interrupt long-running Python code via Ctrl-C. IPython can not pass | |
114 | the KeyboardInterrupt exception (or the underlying SIGINT) across |
|
114 | the KeyboardInterrupt exception (or the underlying SIGINT) across | |
115 | threads, so any long-running process started from IPython will run to |
|
115 | threads, so any long-running process started from IPython will run to | |
116 | completion, or will have to be killed via an external (OS-based) |
|
116 | completion, or will have to be killed via an external (OS-based) | |
117 | mechanism. |
|
117 | mechanism. | |
118 |
|
118 | |||
119 | To the best of my knowledge, this limitation is imposed by the Python |
|
119 | To the best of my knowledge, this limitation is imposed by the Python | |
120 | interpreter itself, and it comes from the difficulty of writing |
|
120 | interpreter itself, and it comes from the difficulty of writing | |
121 | portable signal/threaded code. If any user is an expert on this topic |
|
121 | portable signal/threaded code. If any user is an expert on this topic | |
122 | and can suggest a better solution, I would love to hear about it. In |
|
122 | and can suggest a better solution, I would love to hear about it. In | |
123 | the IPython sources, look at the Shell.py module, and in particular at |
|
123 | the IPython sources, look at the Shell.py module, and in particular at | |
124 | the runcode() method. |
|
124 | the runcode() method. | |
125 |
|
125 | |||
126 | REGULAR OPTIONS |
|
126 | REGULAR OPTIONS | |
127 | After the above threading options have been given, regular options can |
|
127 | After the above threading options have been given, regular options can | |
128 | follow in any order. All options can be abbreviated to their shortest |
|
128 | follow in any order. All options can be abbreviated to their shortest | |
129 | non-ambiguous form and are case-sensitive. One or two dashes can be |
|
129 | non-ambiguous form and are case-sensitive. One or two dashes can be | |
130 | used. Some options have an alternate short form, indicated after a |. |
|
130 | used. Some options have an alternate short form, indicated after a |. | |
131 |
|
131 | |||
132 | Most options can also be set from your ipythonrc configuration file. |
|
132 | Most options can also be set from your ipythonrc configuration file. | |
133 | See the provided examples for assistance. Options given on the comman- |
|
133 | See the provided examples for assistance. Options given on the comman- | |
134 | dline override the values set in the ipythonrc file. |
|
134 | dline override the values set in the ipythonrc file. | |
135 |
|
135 | |||
136 | All options with a [no] prepended can be specified in negated form |
|
136 | All options with a [no] prepended can be specified in negated form | |
137 | (using -nooption instead of -option) to turn the feature off. |
|
137 | (using -nooption instead of -option) to turn the feature off. | |
138 |
|
138 | |||
139 | -h, --help |
|
139 | -h, --help | |
140 | Show summary of options. |
|
140 | Show summary of options. | |
141 |
|
141 | |||
142 | -pylab This can only be given as the first option passed to IPython (it |
|
142 | -pylab This can only be given as the first option passed to IPython (it | |
143 | will have no effect in any other position). It adds special sup- |
|
143 | will have no effect in any other position). It adds special sup- | |
144 | port for the matplotlib library (http://matplotlib.source- |
|
144 | port for the matplotlib library (http://matplotlib.source- | |
145 | forge.net), allowing interactive usage of any of its backends as |
|
145 | forge.net), allowing interactive usage of any of its backends as | |
146 | defined in the user's .matplotlibrc file. It automatically |
|
146 | defined in the user's .matplotlibrc file. It automatically | |
147 | activates GTK or WX threading for IPyhton if the choice of mat- |
|
147 | activates GTK or WX threading for IPyhton if the choice of mat- | |
148 | plotlib backend requires it. It also modifies the @run command |
|
148 | plotlib backend requires it. It also modifies the @run command | |
149 | to correctly execute (without blocking) any matplotlib-based |
|
149 | to correctly execute (without blocking) any matplotlib-based | |
150 | script which calls show() at the end. |
|
150 | script which calls show() at the end. | |
151 |
|
151 | |||
152 | -autocall <val> |
|
152 | -autocall <val> | |
153 | Make IPython automatically call any callable object even if you |
|
153 | Make IPython automatically call any callable object even if you | |
154 | didn't type explicit parentheses. For example, 'str 43' becomes |
|
154 | didn't type explicit parentheses. For example, 'str 43' becomes | |
155 | 'str(43)' automatically. The value can be '0' to disable the |
|
155 | 'str(43)' automatically. The value can be '0' to disable the | |
156 | feature, '1' for 'smart' autocall, where it is not applied if |
|
156 | feature, '1' for 'smart' autocall, where it is not applied if | |
157 | there are no more arguments on the line, and '2' for 'full' |
|
157 | there are no more arguments on the line, and '2' for 'full' | |
158 | autocall, where all callable objects are automatically called |
|
158 | autocall, where all callable objects are automatically called | |
159 | (even if no arguments are present). The default is '1'. |
|
159 | (even if no arguments are present). The default is '1'. | |
160 |
|
160 | |||
161 | -[no]autoindent |
|
161 | -[no]autoindent | |
162 | Turn automatic indentation on/off. |
|
162 | Turn automatic indentation on/off. | |
163 |
|
163 | |||
164 | -[no]automagic |
|
164 | -[no]automagic | |
165 | Make magic commands automatic (without needing their first char- |
|
165 | Make magic commands automatic (without needing their first char- | |
166 | acter to be %). Type %magic at the IPython prompt for more |
|
166 | acter to be %). Type %magic at the IPython prompt for more | |
167 | information. |
|
167 | information. | |
168 |
|
168 | |||
169 | -[no]autoedit_syntax |
|
169 | -[no]autoedit_syntax | |
170 | When a syntax error occurs after editing a file, automatically |
|
170 | When a syntax error occurs after editing a file, automatically | |
171 | open the file to the trouble causing line for convenient fixing. |
|
171 | open the file to the trouble causing line for convenient fixing. | |
172 |
|
172 | |||
173 | -[no]banner |
|
173 | -[no]banner | |
174 | Print the intial information banner (default on). |
|
174 | Print the intial information banner (default on). | |
175 |
|
175 | |||
176 | -c <command> |
|
176 | -c <command> | |
177 | Execute the given command string, and set sys.argv to ['c']. |
|
177 | Execute the given command string, and set sys.argv to ['c']. | |
178 | This is similar to the -c option in the normal Python inter- |
|
178 | This is similar to the -c option in the normal Python inter- | |
179 | preter. |
|
179 | preter. | |
180 |
|
180 | |||
181 | -cache_size|cs <n> |
|
181 | -cache_size|cs <n> | |
182 | Size of the output cache (maximum number of entries to hold in |
|
182 | Size of the output cache (maximum number of entries to hold in | |
183 | memory). The default is 1000, you can change it permanently in |
|
183 | memory). The default is 1000, you can change it permanently in | |
184 | your config file. Setting it to 0 completely disables the |
|
184 | your config file. Setting it to 0 completely disables the | |
185 | caching system, and the minimum value accepted is 20 (if you |
|
185 | caching system, and the minimum value accepted is 20 (if you | |
186 | provide a value less than 20, it is reset to 0 and a warning is |
|
186 | provide a value less than 20, it is reset to 0 and a warning is | |
187 | issued). This limit is defined because otherwise you'll spend |
|
187 | issued). This limit is defined because otherwise you'll spend | |
188 | more time re-flushing a too small cache than working. |
|
188 | more time re-flushing a too small cache than working. | |
189 |
|
189 | |||
190 | -classic|cl |
|
190 | -classic|cl | |
191 | Gives IPython a similar feel to the classic Python prompt. |
|
191 | Gives IPython a similar feel to the classic Python prompt. | |
192 |
|
192 | |||
193 | -colors <scheme> |
|
193 | -colors <scheme> | |
194 | Color scheme for prompts and exception reporting. Currently |
|
194 | Color scheme for prompts and exception reporting. Currently | |
195 | implemented: NoColor, Linux, and LightBG. |
|
195 | implemented: NoColor, Linux, and LightBG. | |
196 |
|
196 | |||
197 | -[no]color_info |
|
197 | -[no]color_info | |
198 | IPython can display information about objects via a set of func- |
|
198 | IPython can display information about objects via a set of func- | |
199 | tions, and optionally can use colors for this, syntax highlight- |
|
199 | tions, and optionally can use colors for this, syntax highlight- | |
200 | ing source code and various other elements. However, because |
|
200 | ing source code and various other elements. However, because | |
201 | this information is passed through a pager (like 'less') and |
|
201 | this information is passed through a pager (like 'less') and | |
202 | many pagers get confused with color codes, this option is off by |
|
202 | many pagers get confused with color codes, this option is off by | |
203 | default. You can test it and turn it on permanently in your |
|
203 | default. You can test it and turn it on permanently in your | |
204 | ipythonrc file if it works for you. As a reference, the 'less' |
|
204 | ipythonrc file if it works for you. As a reference, the 'less' | |
205 | pager supplied with Mandrake 8.2 works ok, but that in RedHat |
|
205 | pager supplied with Mandrake 8.2 works ok, but that in RedHat | |
206 | 7.2 doesn't. |
|
206 | 7.2 doesn't. | |
207 |
|
207 | |||
208 | Test it and turn it on permanently if it works with your system. |
|
208 | Test it and turn it on permanently if it works with your system. | |
209 | The magic function @color_info allows you to toggle this inter- |
|
209 | The magic function @color_info allows you to toggle this inter- | |
210 | actively for testing. |
|
210 | actively for testing. | |
211 |
|
211 | |||
212 | -[no]confirm_exit |
|
212 | -[no]confirm_exit | |
213 | Set to confirm when you try to exit IPython with an EOF (Con- |
|
213 | Set to confirm when you try to exit IPython with an EOF (Con- | |
214 | trol-D in Unix, Control-Z/Enter in Windows). Note that using the |
|
214 | trol-D in Unix, Control-Z/Enter in Windows). Note that using the | |
215 | magic functions @Exit or @Quit you can force a direct exit, |
|
215 | magic functions @Exit or @Quit you can force a direct exit, | |
216 | bypassing any confirmation. |
|
216 | bypassing any confirmation. | |
217 |
|
217 | |||
218 | -[no]debug |
|
218 | -[no]debug | |
219 | Show information about the loading process. Very useful to pin |
|
219 | Show information about the loading process. Very useful to pin | |
220 | down problems with your configuration files or to get details |
|
220 | down problems with your configuration files or to get details | |
221 | about session restores. |
|
221 | about session restores. | |
222 |
|
222 | |||
223 | -[no]deep_reload |
|
223 | -[no]deep_reload | |
224 | IPython can use the deep_reload module which reloads changes in |
|
224 | IPython can use the deep_reload module which reloads changes in | |
225 | modules recursively (it replaces the reload() function, so you |
|
225 | modules recursively (it replaces the reload() function, so you | |
226 | don't need to change anything to use it). deep_reload() forces a |
|
226 | don't need to change anything to use it). deep_reload() forces a | |
227 | full reload of modules whose code may have changed, which the |
|
227 | full reload of modules whose code may have changed, which the | |
228 | default reload() function does not. |
|
228 | default reload() function does not. | |
229 |
|
229 | |||
230 | When deep_reload is off, IPython will use the normal reload(), |
|
230 | When deep_reload is off, IPython will use the normal reload(), | |
231 | but deep_reload will still be available as dreload(). This fea- |
|
231 | but deep_reload will still be available as dreload(). This fea- | |
232 | ture is off by default [which means that you have both normal |
|
232 | ture is off by default [which means that you have both normal | |
233 | reload() and dreload()]. |
|
233 | reload() and dreload()]. | |
234 |
|
234 | |||
235 | -editor <name> |
|
235 | -editor <name> | |
236 | Which editor to use with the @edit command. By default, IPython |
|
236 | Which editor to use with the @edit command. By default, IPython | |
237 | will honor your EDITOR environment variable (if not set, vi is |
|
237 | will honor your EDITOR environment variable (if not set, vi is | |
238 | the Unix default and notepad the Windows one). Since this editor |
|
238 | the Unix default and notepad the Windows one). Since this editor | |
239 | is invoked on the fly by IPython and is meant for editing small |
|
239 | is invoked on the fly by IPython and is meant for editing small | |
240 | code snippets, you may want to use a small, lightweight editor |
|
240 | code snippets, you may want to use a small, lightweight editor | |
241 | here (in case your default EDITOR is something like Emacs). |
|
241 | here (in case your default EDITOR is something like Emacs). | |
242 |
|
242 | |||
243 | -ipythondir <name> |
|
243 | -ipythondir <name> | |
244 | The name of your IPython configuration directory IPYTHONDIR. |
|
244 | The name of your IPython configuration directory IPYTHONDIR. | |
245 | This can also be specified through the environment variable |
|
245 | This can also be specified through the environment variable | |
246 | IPYTHONDIR. |
|
246 | IPYTHONDIR. | |
247 |
|
247 | |||
248 | -log|l Generate a log file of all input. The file is named |
|
248 | -log|l Generate a log file of all input. The file is named | |
249 | ipython_log.py in your current directory (which prevents logs |
|
249 | ipython_log.py in your current directory (which prevents logs | |
250 | from multiple IPython sessions from trampling each other). You |
|
250 | from multiple IPython sessions from trampling each other). You | |
251 | can use this to later restore a session by loading your logfile |
|
251 | can use this to later restore a session by loading your logfile | |
252 | as a file to be executed with option -logplay (see below). |
|
252 | as a file to be executed with option -logplay (see below). | |
253 |
|
253 | |||
254 | -logfile|lf |
|
254 | -logfile|lf | |
255 | Specify the name of your logfile. |
|
255 | Specify the name of your logfile. | |
256 |
|
256 | |||
257 | -logplay|lp |
|
257 | -logplay|lp | |
258 | Replay a previous log. For restoring a session as close as pos- |
|
258 | Replay a previous log. For restoring a session as close as pos- | |
259 | sible to the state you left it in, use this option (don't just |
|
259 | sible to the state you left it in, use this option (don't just | |
260 | run the logfile). With -logplay, IPython will try to reconstruct |
|
260 | run the logfile). With -logplay, IPython will try to reconstruct | |
261 | the previous working environment in full, not just execute the |
|
261 | the previous working environment in full, not just execute the | |
262 | commands in the logfile. |
|
262 | commands in the logfile. | |
263 | When a session is restored, logging is automatically turned on |
|
263 | When a session is restored, logging is automatically turned on | |
264 | again with the name of the logfile it was invoked with (it is |
|
264 | again with the name of the logfile it was invoked with (it is | |
265 | read from the log header). So once you've turned logging on for |
|
265 | read from the log header). So once you've turned logging on for | |
266 | a session, you can quit IPython and reload it as many times as |
|
266 | a session, you can quit IPython and reload it as many times as | |
267 | you want and it will continue to log its history and restore |
|
267 | you want and it will continue to log its history and restore | |
268 | from the beginning every time. |
|
268 | from the beginning every time. | |
269 |
|
269 | |||
270 | Caveats: there are limitations in this option. The history vari- |
|
270 | Caveats: there are limitations in this option. The history vari- | |
271 | ables _i*,_* and _dh don't get restored properly. In the future |
|
271 | ables _i*,_* and _dh don't get restored properly. In the future | |
272 | we will try to implement full session saving by writing and |
|
272 | we will try to implement full session saving by writing and | |
273 | retrieving a failed because of inherent limitations of Python's |
|
273 | retrieving a failed because of inherent limitations of Python's | |
274 | Pickle module, so this may have to wait. |
|
274 | Pickle module, so this may have to wait. | |
275 |
|
275 | |||
276 | -[no]messages |
|
276 | -[no]messages | |
277 | Print messages which IPython collects about its startup process |
|
277 | Print messages which IPython collects about its startup process | |
278 | (default on). |
|
278 | (default on). | |
279 |
|
279 | |||
280 | -[no]pdb |
|
280 | -[no]pdb | |
281 | Automatically call the pdb debugger after every uncaught excep- |
|
281 | Automatically call the pdb debugger after every uncaught excep- | |
282 | tion. If you are used to debugging using pdb, this puts you |
|
282 | tion. If you are used to debugging using pdb, this puts you | |
283 | automatically inside of it after any call (either in IPython or |
|
283 | automatically inside of it after any call (either in IPython or | |
284 | in code called by it) which triggers an exception which goes |
|
284 | in code called by it) which triggers an exception which goes | |
285 | uncaught. |
|
285 | uncaught. | |
286 |
|
286 | |||
287 | -[no]pprint |
|
287 | -[no]pprint | |
288 | IPython can optionally use the pprint (pretty printer) module |
|
288 | IPython can optionally use the pprint (pretty printer) module | |
289 | for displaying results. pprint tends to give a nicer display of |
|
289 | for displaying results. pprint tends to give a nicer display of | |
290 | nested data structures. If you like it, you can turn it on per- |
|
290 | nested data structures. If you like it, you can turn it on per- | |
291 | manently in your config file (default off). |
|
291 | manently in your config file (default off). | |
292 |
|
292 | |||
293 | -profile|p <name> |
|
293 | -profile|p <name> | |
294 | Assume that your config file is ipythonrc-<name> (looks in cur- |
|
294 | Assume that your config file is ipythonrc-<name> (looks in cur- | |
295 | rent dir first, then in IPYTHONDIR). This is a quick way to keep |
|
295 | rent dir first, then in IPYTHONDIR). This is a quick way to keep | |
296 | and load multiple config files for different tasks, especially |
|
296 | and load multiple config files for different tasks, especially | |
297 | if you use the include option of config files. You can keep a |
|
297 | if you use the include option of config files. You can keep a | |
298 | basic IPYTHONDIR/ipythonrc file and then have other 'profiles' |
|
298 | basic IPYTHONDIR/ipythonrc file and then have other 'profiles' | |
299 | which include this one and load extra things for particular |
|
299 | which include this one and load extra things for particular | |
300 | tasks. For example: |
|
300 | tasks. For example: | |
301 |
|
301 | |||
302 | 1) $HOME/.ipython/ipythonrc : load basic things you always want. |
|
302 | 1) $HOME/.ipython/ipythonrc : load basic things you always want. | |
303 | 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math- |
|
303 | 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math- | |
304 | related modules. |
|
304 | related modules. | |
305 | 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and |
|
305 | 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and | |
306 | plotting modules. |
|
306 | plotting modules. | |
307 |
|
307 | |||
308 | Since it is possible to create an endless loop by having circu- |
|
308 | Since it is possible to create an endless loop by having circu- | |
309 | lar file inclusions, IPython will stop if it reaches 15 recur- |
|
309 | lar file inclusions, IPython will stop if it reaches 15 recur- | |
310 | sive inclusions. |
|
310 | sive inclusions. | |
311 |
|
311 | |||
312 | -prompt_in1|pi1 <string> |
|
312 | -prompt_in1|pi1 <string> | |
313 | Specify the string used for input prompts. Note that if you are |
|
313 | Specify the string used for input prompts. Note that if you are | |
314 | using numbered prompts, the number is represented with a '\#' in |
|
314 | using numbered prompts, the number is represented with a '\#' in | |
315 | the string. Don't forget to quote strings with spaces embedded |
|
315 | the string. Don't forget to quote strings with spaces embedded | |
316 | in them. Default: 'In [\#]: '. |
|
316 | in them. Default: 'In [\#]: '. | |
317 |
|
317 | |||
318 | Most bash-like escapes can be used to customize IPython's |
|
318 | Most bash-like escapes can be used to customize IPython's | |
319 | prompts, as well as a few additional ones which are IPython-spe- |
|
319 | prompts, as well as a few additional ones which are IPython-spe- | |
320 | cific. All valid prompt escapes are described in detail in the |
|
320 | cific. All valid prompt escapes are described in detail in the | |
321 | Customization section of the IPython HTML/PDF manual. |
|
321 | Customization section of the IPython HTML/PDF manual. | |
322 |
|
322 | |||
323 | -prompt_in2|pi2 <string> |
|
323 | -prompt_in2|pi2 <string> | |
324 | Similar to the previous option, but used for the continuation |
|
324 | Similar to the previous option, but used for the continuation | |
325 | prompts. The special sequence '\D' is similar to '\#', but with |
|
325 | prompts. The special sequence '\D' is similar to '\#', but with | |
326 | all digits replaced dots (so you can have your continuation |
|
326 | all digits replaced dots (so you can have your continuation | |
327 | prompt aligned with your input prompt). Default: ' .\D.: ' |
|
327 | prompt aligned with your input prompt). Default: ' .\D.: ' | |
328 | (note three spaces at the start for alignment with 'In [\#]'). |
|
328 | (note three spaces at the start for alignment with 'In [\#]'). | |
329 |
|
329 | |||
330 | -prompt_out|po <string> |
|
330 | -prompt_out|po <string> | |
331 | String used for output prompts, also uses numbers like |
|
331 | String used for output prompts, also uses numbers like | |
332 | prompt_in1. Default: 'Out[\#]:'. |
|
332 | prompt_in1. Default: 'Out[\#]:'. | |
333 |
|
333 | |||
334 | -quick Start in bare bones mode (no config file loaded). |
|
334 | -quick Start in bare bones mode (no config file loaded). | |
335 |
|
335 | |||
336 | -rcfile <name> |
|
336 | -rcfile <name> | |
337 | Name of your IPython resource configuration file. normally |
|
337 | Name of your IPython resource configuration file. normally | |
338 | IPython loads ipythonrc (from current directory) or |
|
338 | IPython loads ipythonrc (from current directory) or | |
339 | IPYTHONDIR/ipythonrc. If the loading of your config file fails, |
|
339 | IPYTHONDIR/ipythonrc. If the loading of your config file fails, | |
340 | IPython starts with a bare bones configuration (no modules |
|
340 | IPython starts with a bare bones configuration (no modules | |
341 | loaded at all). |
|
341 | loaded at all). | |
342 |
|
342 | |||
343 | -[no]readline |
|
343 | -[no]readline | |
344 | Use the readline library, which is needed to support name com- |
|
344 | Use the readline library, which is needed to support name com- | |
345 | pletion and command history, among other things. It is enabled |
|
345 | pletion and command history, among other things. It is enabled | |
346 | by default, but may cause problems for users of X/Emacs in |
|
346 | by default, but may cause problems for users of X/Emacs in | |
347 | Python comint or shell buffers. |
|
347 | Python comint or shell buffers. | |
348 |
|
348 | |||
349 | Note that emacs 'eterm' buffers (opened with M-x term) support |
|
349 | Note that emacs 'eterm' buffers (opened with M-x term) support | |
350 | IPython's readline and syntax coloring fine, only 'emacs' (M-x |
|
350 | IPython's readline and syntax coloring fine, only 'emacs' (M-x | |
351 | shell and C-c !) buffers do not. |
|
351 | shell and C-c !) buffers do not. | |
352 |
|
352 | |||
353 | -screen_length|sl <n> |
|
353 | -screen_length|sl <n> | |
354 | Number of lines of your screen. This is used to control print- |
|
354 | Number of lines of your screen. This is used to control print- | |
355 | ing of very long strings. Strings longer than this number of |
|
355 | ing of very long strings. Strings longer than this number of | |
356 | lines will be sent through a pager instead of directly printed. |
|
356 | lines will be sent through a pager instead of directly printed. | |
357 |
|
357 | |||
358 | The default value for this is 0, which means IPython will auto- |
|
358 | The default value for this is 0, which means IPython will auto- | |
359 | detect your screen size every time it needs to print certain |
|
359 | detect your screen size every time it needs to print certain | |
360 | potentially long strings (this doesn't change the behavior of |
|
360 | potentially long strings (this doesn't change the behavior of | |
361 | the 'print' keyword, it's only triggered internally). If for |
|
361 | the 'print' keyword, it's only triggered internally). If for | |
362 | some reason this isn't working well (it needs curses support), |
|
362 | some reason this isn't working well (it needs curses support), | |
363 | specify it yourself. Otherwise don't change the default. |
|
363 | specify it yourself. Otherwise don't change the default. | |
364 |
|
364 | |||
365 | -separate_in|si <string> |
|
365 | -separate_in|si <string> | |
366 | Separator before input prompts. Default '0. |
|
366 | Separator before input prompts. Default '0. | |
367 |
|
367 | |||
368 | -separate_out|so <string> |
|
368 | -separate_out|so <string> | |
369 | Separator before output prompts. Default: 0 (nothing). |
|
369 | Separator before output prompts. Default: 0 (nothing). | |
370 |
|
370 | |||
371 | -separate_out2|so2 <string> |
|
371 | -separate_out2|so2 <string> | |
372 | Separator after output prompts. Default: 0 (nothing). |
|
372 | Separator after output prompts. Default: 0 (nothing). | |
373 |
|
373 | |||
374 | -nosep Shorthand for '-separate_in 0 -separate_out 0 -separate_out2 0'. |
|
374 | -nosep Shorthand for '-separate_in 0 -separate_out 0 -separate_out2 0'. | |
375 | Simply removes all input/output separators. |
|
375 | Simply removes all input/output separators. | |
376 |
|
376 | |||
377 | -upgrade |
|
377 | -upgrade | |
378 | Allows you to upgrade your IPYTHONDIR configuration when you |
|
378 | Allows you to upgrade your IPYTHONDIR configuration when you | |
379 | install a new version of IPython. Since new versions may |
|
379 | install a new version of IPython. Since new versions may | |
380 | include new command lines options or example files, this copies |
|
380 | include new command lines options or example files, this copies | |
381 | updated ipythonrc-type files. However, it backs up (with a .old |
|
381 | updated ipythonrc-type files. However, it backs up (with a .old | |
382 | extension) all files which it overwrites so that you can merge |
|
382 | extension) all files which it overwrites so that you can merge | |
383 | back any custimizations you might have in your personal files. |
|
383 | back any custimizations you might have in your personal files. | |
384 |
|
384 | |||
385 | -Version |
|
385 | -Version | |
386 | Print version information and exit. |
|
386 | Print version information and exit. | |
387 |
|
387 | |||
388 | -wxversion <string> |
|
388 | -wxversion <string> | |
389 | Select a specific version of wxPython (used in conjunction with |
|
389 | Select a specific version of wxPython (used in conjunction with | |
390 | -wthread). Requires the wxversion module, part of recent |
|
390 | -wthread). Requires the wxversion module, part of recent | |
391 | wxPython distributions. |
|
391 | wxPython distributions. | |
392 |
|
392 | |||
393 | -xmode <modename> |
|
393 | -xmode <modename> | |
394 | Mode for exception reporting. The valid modes are Plain, Con- |
|
394 | Mode for exception reporting. The valid modes are Plain, Con- | |
395 | text, and Verbose. |
|
395 | text, and Verbose. | |
396 |
|
396 | |||
397 | - Plain: similar to python's normal traceback printing. |
|
397 | - Plain: similar to python's normal traceback printing. | |
398 |
|
398 | |||
399 | - Context: prints 5 lines of context source code around each |
|
399 | - Context: prints 5 lines of context source code around each | |
400 | line in the traceback. |
|
400 | line in the traceback. | |
401 |
|
401 | |||
402 | - Verbose: similar to Context, but additionally prints the vari- |
|
402 | - Verbose: similar to Context, but additionally prints the vari- | |
403 | ables currently visible where the exception happened (shortening |
|
403 | ables currently visible where the exception happened (shortening | |
404 | their strings if too long). This can potentially be very slow, |
|
404 | their strings if too long). This can potentially be very slow, | |
405 | if you happen to have a huge data structure whose string repre- |
|
405 | if you happen to have a huge data structure whose string repre- | |
406 | sentation is complex to compute. Your computer may appear to |
|
406 | sentation is complex to compute. Your computer may appear to | |
407 | freeze for a while with cpu usage at 100%. If this occurs, you |
|
407 | freeze for a while with cpu usage at 100%. If this occurs, you | |
408 | can cancel the traceback with Ctrl-C (maybe hitting it more than |
|
408 | can cancel the traceback with Ctrl-C (maybe hitting it more than | |
409 | once). |
|
409 | once). | |
410 |
|
410 | |||
411 |
|
411 | |||
412 | EMBEDDING |
|
412 | EMBEDDING | |
413 | It is possible to start an IPython instance inside your own Python pro- |
|
413 | It is possible to start an IPython instance inside your own Python pro- | |
414 | grams. In the documentation example files there are some illustrations |
|
414 | grams. In the documentation example files there are some illustrations | |
415 | on how to do this. |
|
415 | on how to do this. | |
416 |
|
416 | |||
417 | This feature allows you to evalutate dynamically the state of your |
|
417 | This feature allows you to evalutate dynamically the state of your | |
418 | code, operate with your variables, analyze them, etc. Note however |
|
418 | code, operate with your variables, analyze them, etc. Note however | |
419 | that any changes you make to values while in the shell do NOT propagate |
|
419 | that any changes you make to values while in the shell do NOT propagate | |
420 | back to the running code, so it is safe to modify your values because |
|
420 | back to the running code, so it is safe to modify your values because | |
421 | you won't break your code in bizarre ways by doing so. |
|
421 | you won't break your code in bizarre ways by doing so. | |
422 | """ |
|
422 | """ | |
423 |
|
423 | |||
424 | cmd_line_usage = __doc__ |
|
424 | cmd_line_usage = __doc__ | |
425 |
|
425 | |||
426 | #--------------------------------------------------------------------------- |
|
426 | #--------------------------------------------------------------------------- | |
427 | interactive_usage = """ |
|
427 | interactive_usage = """ | |
428 | IPython -- An enhanced Interactive Python |
|
428 | IPython -- An enhanced Interactive Python | |
429 | ========================================= |
|
429 | ========================================= | |
430 |
|
430 | |||
431 | IPython offers a combination of convenient shell features, special commands |
|
431 | IPython offers a combination of convenient shell features, special commands | |
432 | and a history mechanism for both input (command history) and output (results |
|
432 | and a history mechanism for both input (command history) and output (results | |
433 | caching, similar to Mathematica). It is intended to be a fully compatible |
|
433 | caching, similar to Mathematica). It is intended to be a fully compatible | |
434 | replacement for the standard Python interpreter, while offering vastly |
|
434 | replacement for the standard Python interpreter, while offering vastly | |
435 | improved functionality and flexibility. |
|
435 | improved functionality and flexibility. | |
436 |
|
436 | |||
437 | At your system command line, type 'ipython -help' to see the command line |
|
437 | At your system command line, type 'ipython -help' to see the command line | |
438 | options available. This document only describes interactive features. |
|
438 | options available. This document only describes interactive features. | |
439 |
|
439 | |||
440 | Warning: IPython relies on the existence of a global variable called __IP which |
|
440 | Warning: IPython relies on the existence of a global variable called __IP which | |
441 | controls the shell itself. If you redefine __IP to anything, bizarre behavior |
|
441 | controls the shell itself. If you redefine __IP to anything, bizarre behavior | |
442 | will quickly occur. |
|
442 | will quickly occur. | |
443 |
|
443 | |||
444 | MAIN FEATURES |
|
444 | MAIN FEATURES | |
445 |
|
445 | |||
446 | * Access to the standard Python help. As of Python 2.1, a help system is |
|
446 | * Access to the standard Python help. As of Python 2.1, a help system is | |
447 | available with access to object docstrings and the Python manuals. Simply |
|
447 | available with access to object docstrings and the Python manuals. Simply | |
448 | type 'help' (no quotes) to access it. |
|
448 | type 'help' (no quotes) to access it. | |
449 |
|
449 | |||
450 | * Magic commands: type %magic for information on the magic subsystem. |
|
450 | * Magic commands: type %magic for information on the magic subsystem. | |
451 |
|
451 | |||
452 | * System command aliases, via the %alias command or the ipythonrc config file. |
|
452 | * System command aliases, via the %alias command or the ipythonrc config file. | |
453 |
|
453 | |||
454 | * Dynamic object information: |
|
454 | * Dynamic object information: | |
455 |
|
455 | |||
456 | Typing ?word or word? prints detailed information about an object. If |
|
456 | Typing ?word or word? prints detailed information about an object. If | |
457 | certain strings in the object are too long (docstrings, code, etc.) they get |
|
457 | certain strings in the object are too long (docstrings, code, etc.) they get | |
458 | snipped in the center for brevity. |
|
458 | snipped in the center for brevity. | |
459 |
|
459 | |||
460 | Typing ??word or word?? gives access to the full information without |
|
460 | Typing ??word or word?? gives access to the full information without | |
461 | snipping long strings. Long strings are sent to the screen through the less |
|
461 | snipping long strings. Long strings are sent to the screen through the less | |
462 | pager if longer than the screen, printed otherwise. |
|
462 | pager if longer than the screen, printed otherwise. | |
463 |
|
463 | |||
464 | The ?/?? system gives access to the full source code for any object (if |
|
464 | The ?/?? system gives access to the full source code for any object (if | |
465 | available), shows function prototypes and other useful information. |
|
465 | available), shows function prototypes and other useful information. | |
466 |
|
466 | |||
467 | If you just want to see an object's docstring, type '%pdoc object' (without |
|
467 | If you just want to see an object's docstring, type '%pdoc object' (without | |
468 | quotes, and without % if you have automagic on). |
|
468 | quotes, and without % if you have automagic on). | |
469 |
|
469 | |||
470 | Both %pdoc and ?/?? give you access to documentation even on things which are |
|
470 | Both %pdoc and ?/?? give you access to documentation even on things which are | |
471 | not explicitely defined. Try for example typing {}.get? or after import os, |
|
471 | not explicitely defined. Try for example typing {}.get? or after import os, | |
472 | type os.path.abspath??. The magic functions %pdef, %source and %file operate |
|
472 | type os.path.abspath??. The magic functions %pdef, %source and %file operate | |
473 | similarly. |
|
473 | similarly. | |
474 |
|
474 | |||
475 | * Completion in the local namespace, by typing TAB at the prompt. |
|
475 | * Completion in the local namespace, by typing TAB at the prompt. | |
476 |
|
476 | |||
477 | At any time, hitting tab will complete any available python commands or |
|
477 | At any time, hitting tab will complete any available python commands or | |
478 | variable names, and show you a list of the possible completions if there's |
|
478 | variable names, and show you a list of the possible completions if there's | |
479 | no unambiguous one. It will also complete filenames in the current directory. |
|
479 | no unambiguous one. It will also complete filenames in the current directory. | |
480 |
|
480 | |||
481 | This feature requires the readline and rlcomplete modules, so it won't work |
|
481 | This feature requires the readline and rlcomplete modules, so it won't work | |
482 | if your Python lacks readline support (such as under Windows). |
|
482 | if your Python lacks readline support (such as under Windows). | |
483 |
|
483 | |||
484 | * Search previous command history in two ways (also requires readline): |
|
484 | * Search previous command history in two ways (also requires readline): | |
485 |
|
485 | |||
486 | - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to |
|
486 | - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to | |
487 | search through only the history items that match what you've typed so |
|
487 | search through only the history items that match what you've typed so | |
488 | far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like |
|
488 | far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like | |
489 | normal arrow keys. |
|
489 | normal arrow keys. | |
490 |
|
490 | |||
491 | - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches |
|
491 | - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches | |
492 | your history for lines that match what you've typed so far, completing as |
|
492 | your history for lines that match what you've typed so far, completing as | |
493 | much as it can. |
|
493 | much as it can. | |
494 |
|
494 | |||
495 | * Persistent command history across sessions (readline required). |
|
495 | * Persistent command history across sessions (readline required). | |
496 |
|
496 | |||
497 | * Logging of input with the ability to save and restore a working session. |
|
497 | * Logging of input with the ability to save and restore a working session. | |
498 |
|
498 | |||
499 | * System escape with !. Typing !ls will run 'ls' in the current directory. |
|
499 | * System escape with !. Typing !ls will run 'ls' in the current directory. | |
500 |
|
500 | |||
501 | * The reload command does a 'deep' reload of a module: changes made to the |
|
501 | * The reload command does a 'deep' reload of a module: changes made to the | |
502 | module since you imported will actually be available without having to exit. |
|
502 | module since you imported will actually be available without having to exit. | |
503 |
|
503 | |||
504 | * Verbose and colored exception traceback printouts. See the magic xmode and |
|
504 | * Verbose and colored exception traceback printouts. See the magic xmode and | |
505 | xcolor functions for details (just type %magic). |
|
505 | xcolor functions for details (just type %magic). | |
506 |
|
506 | |||
507 | * Input caching system: |
|
507 | * Input caching system: | |
508 |
|
508 | |||
509 | IPython offers numbered prompts (In/Out) with input and output caching. All |
|
509 | IPython offers numbered prompts (In/Out) with input and output caching. All | |
510 | input is saved and can be retrieved as variables (besides the usual arrow |
|
510 | input is saved and can be retrieved as variables (besides the usual arrow | |
511 | key recall). |
|
511 | key recall). | |
512 |
|
512 | |||
513 | The following GLOBAL variables always exist (so don't overwrite them!): |
|
513 | The following GLOBAL variables always exist (so don't overwrite them!): | |
514 | _i: stores previous input. |
|
514 | _i: stores previous input. | |
515 | _ii: next previous. |
|
515 | _ii: next previous. | |
516 | _iii: next-next previous. |
|
516 | _iii: next-next previous. | |
517 | _ih : a list of all input _ih[n] is the input from line n. |
|
517 | _ih : a list of all input _ih[n] is the input from line n. | |
518 |
|
518 | |||
519 | Additionally, global variables named _i<n> are dynamically created (<n> |
|
519 | Additionally, global variables named _i<n> are dynamically created (<n> | |
520 | being the prompt counter), such that _i<n> == _ih[<n>] |
|
520 | being the prompt counter), such that _i<n> == _ih[<n>] | |
521 |
|
521 | |||
522 | For example, what you typed at prompt 14 is available as _i14 and _ih[14]. |
|
522 | For example, what you typed at prompt 14 is available as _i14 and _ih[14]. | |
523 |
|
523 | |||
524 | You can create macros which contain multiple input lines from this history, |
|
524 | You can create macros which contain multiple input lines from this history, | |
525 | for later re-execution, with the %macro function. |
|
525 | for later re-execution, with the %macro function. | |
526 |
|
526 | |||
527 | The history function %hist allows you to see any part of your input history |
|
527 | The history function %hist allows you to see any part of your input history | |
528 | by printing a range of the _i variables. Note that inputs which contain |
|
528 | by printing a range of the _i variables. Note that inputs which contain | |
529 | magic functions (%) appear in the history with a prepended comment. This is |
|
529 | magic functions (%) appear in the history with a prepended comment. This is | |
530 | because they aren't really valid Python code, so you can't exec them. |
|
530 | because they aren't really valid Python code, so you can't exec them. | |
531 |
|
531 | |||
532 | * Output caching system: |
|
532 | * Output caching system: | |
533 |
|
533 | |||
534 | For output that is returned from actions, a system similar to the input |
|
534 | For output that is returned from actions, a system similar to the input | |
535 | cache exists but using _ instead of _i. Only actions that produce a result |
|
535 | cache exists but using _ instead of _i. Only actions that produce a result | |
536 | (NOT assignments, for example) are cached. If you are familiar with |
|
536 | (NOT assignments, for example) are cached. If you are familiar with | |
537 | Mathematica, IPython's _ variables behave exactly like Mathematica's % |
|
537 | Mathematica, IPython's _ variables behave exactly like Mathematica's % | |
538 | variables. |
|
538 | variables. | |
539 |
|
539 | |||
540 | The following GLOBAL variables always exist (so don't overwrite them!): |
|
540 | The following GLOBAL variables always exist (so don't overwrite them!): | |
541 | _ (one underscore): previous output. |
|
541 | _ (one underscore): previous output. | |
542 | __ (two underscores): next previous. |
|
542 | __ (two underscores): next previous. | |
543 | ___ (three underscores): next-next previous. |
|
543 | ___ (three underscores): next-next previous. | |
544 |
|
544 | |||
545 | Global variables named _<n> are dynamically created (<n> being the prompt |
|
545 | Global variables named _<n> are dynamically created (<n> being the prompt | |
546 | counter), such that the result of output <n> is always available as _<n>. |
|
546 | counter), such that the result of output <n> is always available as _<n>. | |
547 |
|
547 | |||
548 | Finally, a global dictionary named _oh exists with entries for all lines |
|
548 | Finally, a global dictionary named _oh exists with entries for all lines | |
549 | which generated output. |
|
549 | which generated output. | |
550 |
|
550 | |||
551 | * Directory history: |
|
551 | * Directory history: | |
552 |
|
552 | |||
553 | Your history of visited directories is kept in the global list _dh, and the |
|
553 | Your history of visited directories is kept in the global list _dh, and the | |
554 | magic %cd command can be used to go to any entry in that list. |
|
554 | magic %cd command can be used to go to any entry in that list. | |
555 |
|
555 | |||
556 | * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython) |
|
556 | * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython) | |
557 |
|
557 | |||
558 | 1. Auto-parentheses |
|
558 | 1. Auto-parentheses | |
559 | Callable objects (i.e. functions, methods, etc) can be invoked like |
|
559 | Callable objects (i.e. functions, methods, etc) can be invoked like | |
560 | this (notice the commas between the arguments): |
|
560 | this (notice the commas between the arguments): | |
561 | >>> callable_ob arg1, arg2, arg3 |
|
561 | >>> callable_ob arg1, arg2, arg3 | |
562 | and the input will be translated to this: |
|
562 | and the input will be translated to this: | |
563 | --> callable_ob(arg1, arg2, arg3) |
|
563 | --> callable_ob(arg1, arg2, arg3) | |
564 | You can force auto-parentheses by using '/' as the first character |
|
564 | You can force auto-parentheses by using '/' as the first character | |
565 | of a line. For example: |
|
565 | of a line. For example: | |
566 | >>> /globals # becomes 'globals()' |
|
566 | >>> /globals # becomes 'globals()' | |
567 | Note that the '/' MUST be the first character on the line! This |
|
567 | Note that the '/' MUST be the first character on the line! This | |
568 | won't work: |
|
568 | won't work: | |
569 | >>> print /globals # syntax error |
|
569 | >>> print /globals # syntax error | |
570 |
|
570 | |||
571 | In most cases the automatic algorithm should work, so you should |
|
571 | In most cases the automatic algorithm should work, so you should | |
572 | rarely need to explicitly invoke /. One notable exception is if you |
|
572 | rarely need to explicitly invoke /. One notable exception is if you | |
573 | are trying to call a function with a list of tuples as arguments (the |
|
573 | are trying to call a function with a list of tuples as arguments (the | |
574 | parenthesis will confuse IPython): |
|
574 | parenthesis will confuse IPython): | |
575 | In [1]: zip (1,2,3),(4,5,6) # won't work |
|
575 | In [1]: zip (1,2,3),(4,5,6) # won't work | |
576 | but this will work: |
|
576 | but this will work: | |
577 | In [2]: /zip (1,2,3),(4,5,6) |
|
577 | In [2]: /zip (1,2,3),(4,5,6) | |
578 | ------> zip ((1,2,3),(4,5,6)) |
|
578 | ------> zip ((1,2,3),(4,5,6)) | |
579 | Out[2]= [(1, 4), (2, 5), (3, 6)] |
|
579 | Out[2]= [(1, 4), (2, 5), (3, 6)] | |
580 |
|
580 | |||
581 | IPython tells you that it has altered your command line by |
|
581 | IPython tells you that it has altered your command line by | |
582 | displaying the new command line preceded by -->. e.g.: |
|
582 | displaying the new command line preceded by -->. e.g.: | |
583 | In [18]: callable list |
|
583 | In [18]: callable list | |
584 | -------> callable (list) |
|
584 | -------> callable (list) | |
585 |
|
585 | |||
586 | 2. Auto-Quoting |
|
586 | 2. Auto-Quoting | |
587 | You can force auto-quoting of a function's arguments by using ',' as |
|
587 | You can force auto-quoting of a function's arguments by using ',' as | |
588 | the first character of a line. For example: |
|
588 | the first character of a line. For example: | |
589 | >>> ,my_function /home/me # becomes my_function("/home/me") |
|
589 | >>> ,my_function /home/me # becomes my_function("/home/me") | |
590 |
|
590 | |||
591 | If you use ';' instead, the whole argument is quoted as a single |
|
591 | If you use ';' instead, the whole argument is quoted as a single | |
592 | string (while ',' splits on whitespace): |
|
592 | string (while ',' splits on whitespace): | |
593 | >>> ,my_function a b c # becomes my_function("a","b","c") |
|
593 | >>> ,my_function a b c # becomes my_function("a","b","c") | |
594 | >>> ;my_function a b c # becomes my_function("a b c") |
|
594 | >>> ;my_function a b c # becomes my_function("a b c") | |
595 |
|
595 | |||
596 | Note that the ',' MUST be the first character on the line! This |
|
596 | Note that the ',' MUST be the first character on the line! This | |
597 | won't work: |
|
597 | won't work: | |
598 | >>> x = ,my_function /home/me # syntax error |
|
598 | >>> x = ,my_function /home/me # syntax error | |
599 | """ |
|
599 | """ | |
600 |
|
600 | |||
601 | quick_reference = r""" |
|
601 | quick_reference = r""" | |
602 | IPython -- An enhanced Interactive Python - Quick Reference Card |
|
602 | IPython -- An enhanced Interactive Python - Quick Reference Card | |
603 | ================================================================ |
|
603 | ================================================================ | |
604 |
|
604 | |||
605 | obj?, obj??, ?obj,??obj : Get help, or more help for object |
|
605 | obj?, obj??, ?obj,??obj : Get help, or more help for object | |
606 | ?os.p* : List names in os starting with p |
|
606 | ?os.p* : List names in os starting with p | |
607 |
|
607 | |||
608 | Example magic: |
|
608 | Example magic: | |
609 |
|
609 | |||
610 | %alias d ls -F : 'd' is now an alias for 'ls -F' |
|
610 | %alias d ls -F : 'd' is now an alias for 'ls -F' | |
611 | alias d ls -F : Works if 'alias' not a python name |
|
611 | alias d ls -F : Works if 'alias' not a python name | |
612 | alist = %alias : Get list of aliases to 'alist' |
|
612 | alist = %alias : Get list of aliases to 'alist' | |
613 |
|
613 | |||
614 | System commands: |
|
614 | System commands: | |
615 |
|
615 | |||
616 | !cp a.txt b/ : System command escape, calls os.system() |
|
616 | !cp a.txt b/ : System command escape, calls os.system() | |
617 | cp a.txt b/ : after %rehashx, most system commands work without ! |
|
617 | cp a.txt b/ : after %rehashx, most system commands work without ! | |
618 | cp ${f}.txt $bar : Variable expansion in magics and system commands |
|
618 | cp ${f}.txt $bar : Variable expansion in magics and system commands | |
619 | files = !ls /usr : Capture sytem command output |
|
619 | files = !ls /usr : Capture sytem command output | |
620 | files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc' |
|
620 | files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc' | |
621 | cd /usr/share : Obvious, also 'cd d:\home\_ipython' works |
|
621 | cd /usr/share : Obvious, also 'cd d:\home\_ipython' works | |
622 |
|
622 | |||
623 | History: |
|
623 | History: | |
624 |
|
624 | |||
625 | _i, _ii, _iii : Previous, next previous, next next previous input |
|
625 | _i, _ii, _iii : Previous, next previous, next next previous input | |
626 |
_i |
|
626 | _i4, _ih[2:5] : Input history line 4, lines 2-4 | |
|
627 | exec _i81 : Execute input history line #81 again | |||
627 | _, __, ___ : previous, next previous, next next previous output |
|
628 | _, __, ___ : previous, next previous, next next previous output | |
628 | _dh : Directory history |
|
629 | _dh : Directory history | |
629 | _oh : Output history |
|
630 | _oh : Output history | |
630 | %hist : Command history |
|
631 | %hist : Command history | |
631 |
|
632 | |||
632 | Autocall: |
|
633 | Autocall: | |
633 |
|
634 | |||
634 | f 1,2 : f(1,2) |
|
635 | f 1,2 : f(1,2) | |
635 | /f 1,2 : f(1,2) (forced autoparen) |
|
636 | /f 1,2 : f(1,2) (forced autoparen) | |
636 | ,f 1 2 : f("1","2") |
|
637 | ,f 1 2 : f("1","2") | |
637 | ;f 1 2 : f("1 2") |
|
638 | ;f 1 2 : f("1 2") | |
638 |
|
639 | |||
639 | """ |
|
640 | """ | |
640 |
|
641 | |||
641 |
|
642 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,15 +1,15 b'' | |||||
1 | import os |
|
1 | import os | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | editor = r'q:/opt/np/notepad++.exe' |
|
4 | editor = r'q:/opt/np/notepad++.exe' | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | e = os.environ |
|
7 | e = os.environ | |
8 |
|
8 | |||
9 | e['EDITOR'] = editor |
|
9 | e['EDITOR'] = editor | |
10 | e['VISUAL'] = editor |
|
10 | e['VISUAL'] = editor | |
11 |
|
11 | |||
12 |
|
12 | |||
13 |
|
13 | |||
14 |
|
14 | |||
15 |
|
15 |
@@ -1,78 +1,80 b'' | |||||
1 | #!python |
|
1 | #!python | |
2 | """Windows-specific part of the installation""" |
|
2 | """Windows-specific part of the installation""" | |
3 |
|
3 | |||
4 | import os, sys |
|
4 | import os, sys, shutil | |
5 |
|
5 | |||
6 |
def |
|
6 | def mkshortcut(target,description,link_file,*args,**kw): | |
7 | """make a shortcut if it doesn't exist, and register its creation""" |
|
7 | """make a shortcut if it doesn't exist, and register its creation""" | |
8 |
|
8 | |||
9 | if not os.path.isfile(link_file): |
|
9 | create_shortcut(target, description, link_file,*args,**kw) | |
10 | create_shortcut(target, description, link_file,*args,**kw) |
|
10 | file_created(link_file) | |
11 | file_created(link_file) |
|
|||
12 |
|
11 | |||
13 | def install(): |
|
12 | def install(): | |
14 | """Routine to be run by the win32 installer with the -install switch.""" |
|
13 | """Routine to be run by the win32 installer with the -install switch.""" | |
15 |
|
14 | |||
16 | from IPython.Release import version |
|
15 | from IPython.Release import version | |
17 |
|
16 | |||
18 | # Get some system constants |
|
17 | # Get some system constants | |
19 | prefix = sys.prefix |
|
18 | prefix = sys.prefix | |
20 | python = prefix + r'\python.exe' |
|
19 | python = prefix + r'\python.exe' | |
21 | # Lookup path to common startmenu ... |
|
20 | # Lookup path to common startmenu ... | |
22 | ip_dir = get_special_folder_path('CSIDL_COMMON_PROGRAMS') + r'\IPython' |
|
21 | ip_dir = get_special_folder_path('CSIDL_COMMON_PROGRAMS') + r'\IPython' | |
23 |
|
22 | |||
24 | # Some usability warnings at installation time. I don't want them at the |
|
23 | # Some usability warnings at installation time. I don't want them at the | |
25 | # top-level, so they don't appear if the user is uninstalling. |
|
24 | # top-level, so they don't appear if the user is uninstalling. | |
26 | try: |
|
25 | try: | |
27 | import ctypes |
|
26 | import ctypes | |
28 | except ImportError: |
|
27 | except ImportError: | |
29 | print ('To take full advantage of IPython, you need ctypes from:\n' |
|
28 | print ('To take full advantage of IPython, you need ctypes from:\n' | |
30 | 'http://sourceforge.net/projects/ctypes') |
|
29 | 'http://sourceforge.net/projects/ctypes') | |
31 |
|
30 | |||
32 | try: |
|
31 | try: | |
33 | import win32con |
|
32 | import win32con | |
34 | except ImportError: |
|
33 | except ImportError: | |
35 | print ('To take full advantage of IPython, you need pywin32 from:\n' |
|
34 | print ('To take full advantage of IPython, you need pywin32 from:\n' | |
36 | 'http://starship.python.net/crew/mhammond/win32/Downloads.html') |
|
35 | 'http://starship.python.net/crew/mhammond/win32/Downloads.html') | |
37 |
|
36 | |||
38 | try: |
|
37 | try: | |
39 | import readline |
|
38 | import readline | |
40 | except ImportError: |
|
39 | except ImportError: | |
41 | print ('To take full advantage of IPython, you need readline from:\n' |
|
40 | print ('To take full advantage of IPython, you need readline from:\n' | |
42 | 'http://sourceforge.net/projects/uncpythontools') |
|
41 | 'http://sourceforge.net/projects/uncpythontools') | |
43 |
|
42 | |||
44 | # Create IPython entry ... |
|
43 | # Create IPython entry ... | |
45 | if not os.path.isdir(ip_dir): |
|
44 | if not os.path.isdir(ip_dir): | |
46 | os.mkdir(ip_dir) |
|
45 | os.mkdir(ip_dir) | |
47 | directory_created(ip_dir) |
|
46 | directory_created(ip_dir) | |
48 |
|
47 | |||
49 | # Create program shortcuts ... |
|
48 | # Create program shortcuts ... | |
50 | f = ip_dir + r'\IPython.lnk' |
|
49 | f = ip_dir + r'\IPython.lnk' | |
51 | a = prefix + r'\scripts\ipython' |
|
50 | a = prefix + r'\scripts\ipython' | |
52 |
|
|
51 | mkshortcut(python,'IPython',f,a) | |
53 |
|
52 | |||
54 | f = ip_dir + r'\pysh.lnk' |
|
53 | f = ip_dir + r'\pysh.lnk' | |
55 |
a = prefix + r'\scripts\ipython -p |
|
54 | a = prefix + r'\scripts\ipython -p sh' | |
56 | create_shortcut_safe(python,'pysh',f,a) |
|
55 | mkshortcut(python,'IPython command prompt mode',f,a) | |
57 |
|
56 | |||
58 | # Create documentation shortcuts ... |
|
57 | # Create documentation shortcuts ... | |
59 | t = prefix + r'\share\doc\ipython-%s\manual.pdf' % version |
|
58 | t = prefix + r'\share\doc\ipython-%s\manual.pdf' % version | |
60 | f = ip_dir + r'\Manual in PDF.lnk' |
|
59 | f = ip_dir + r'\Manual in PDF.lnk' | |
61 |
|
|
60 | mkshortcut(t,r'IPython Manual - PDF-Format',f) | |
62 |
|
61 | |||
63 | t = prefix + r'\share\doc\ipython-%s\manual\manual.html' % version |
|
62 | t = prefix + r'\share\doc\ipython-%s\manual\manual.html' % version | |
64 | f = ip_dir + r'\Manual in HTML.lnk' |
|
63 | f = ip_dir + r'\Manual in HTML.lnk' | |
65 |
|
|
64 | mkshortcut(t,'IPython Manual - HTML-Format',f) | |
66 |
|
65 | |||
|
66 | # make ipython.py | |||
|
67 | shutil.copy(prefix + r'\scripts\ipython', prefix + r'\scripts\ipython.py') | |||
|
68 | ||||
67 | def remove(): |
|
69 | def remove(): | |
68 | """Routine to be run by the win32 installer with the -remove switch.""" |
|
70 | """Routine to be run by the win32 installer with the -remove switch.""" | |
69 | pass |
|
71 | pass | |
70 |
|
72 | |||
71 | # main() |
|
73 | # main() | |
72 | if len(sys.argv) > 1: |
|
74 | if len(sys.argv) > 1: | |
73 | if sys.argv[1] == '-install': |
|
75 | if sys.argv[1] == '-install': | |
74 | install() |
|
76 | install() | |
75 | elif sys.argv[1] == '-remove': |
|
77 | elif sys.argv[1] == '-remove': | |
76 | remove() |
|
78 | remove() | |
77 | else: |
|
79 | else: | |
78 | print "Script was called with option %s" % sys.argv[1] |
|
80 | print "Script was called with option %s" % sys.argv[1] |
@@ -1,100 +1,100 b'' | |||||
1 | # -*- coding: UTF-8 -*- |
|
1 | # -*- coding: UTF-8 -*- | |
2 | import sys, unittest |
|
2 | import sys, unittest | |
3 | sys.path.append ('..') |
|
3 | sys.path.append ('..') | |
4 |
|
4 | |||
5 | from IPython import wildcard |
|
5 | from IPython import wildcard | |
6 |
|
6 | |||
7 | class obj_t(object): |
|
7 | class obj_t(object): | |
8 | pass |
|
8 | pass | |
9 |
|
9 | |||
10 | root=obj_t() |
|
10 | root=obj_t() | |
11 | l=["arna","abel","ABEL","active","bob","bark","abbot"] |
|
11 | l=["arna","abel","ABEL","active","bob","bark","abbot"] | |
12 | q=["kate","loop","arne","vito","lucifer","koppel"] |
|
12 | q=["kate","loop","arne","vito","lucifer","koppel"] | |
13 | for x in l: |
|
13 | for x in l: | |
14 | o=obj_t() |
|
14 | o=obj_t() | |
15 | setattr(root,x,o) |
|
15 | setattr(root,x,o) | |
16 | for y in q: |
|
16 | for y in q: | |
17 | p=obj_t() |
|
17 | p=obj_t() | |
18 | setattr(o,y,p) |
|
18 | setattr(o,y,p) | |
19 | root._apan=obj_t() |
|
19 | root._apan=obj_t() | |
20 | root._apan.a=10 |
|
20 | root._apan.a=10 | |
21 | root._apan._a=20 |
|
21 | root._apan._a=20 | |
22 | root._apan.__a=20 |
|
22 | root._apan.__a=20 | |
23 | root.__anka=obj_t() |
|
23 | root.__anka=obj_t() | |
24 | root.__anka.a=10 |
|
24 | root.__anka.a=10 | |
25 | root.__anka._a=20 |
|
25 | root.__anka._a=20 | |
26 | root.__anka.__a=20 |
|
26 | root.__anka.__a=20 | |
27 |
|
27 | |||
28 | root._APAN=obj_t() |
|
28 | root._APAN=obj_t() | |
29 | root._APAN.a=10 |
|
29 | root._APAN.a=10 | |
30 | root._APAN._a=20 |
|
30 | root._APAN._a=20 | |
31 | root._APAN.__a=20 |
|
31 | root._APAN.__a=20 | |
32 | root.__ANKA=obj_t() |
|
32 | root.__ANKA=obj_t() | |
33 | root.__ANKA.a=10 |
|
33 | root.__ANKA.a=10 | |
34 | root.__ANKA._a=20 |
|
34 | root.__ANKA._a=20 | |
35 | root.__ANKA.__a=20 |
|
35 | root.__ANKA.__a=20 | |
36 |
|
36 | |||
37 | class Tests (unittest.TestCase): |
|
37 | class Tests (unittest.TestCase): | |
38 | def test_case(self): |
|
38 | def test_case(self): | |
39 | ns=root.__dict__ |
|
39 | ns=root.__dict__ | |
40 | tests=[ |
|
40 | tests=[ | |
41 | ("a*", ["abbot","abel","active","arna",]), |
|
41 | ("a*", ["abbot","abel","active","arna",]), | |
42 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]), |
|
42 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]), | |
43 | ("_a*", []), |
|
43 | ("_a*", []), | |
44 | ("_*anka", ["__anka",]), |
|
44 | ("_*anka", ["__anka",]), | |
45 | ("_*a*", ["__anka",]), |
|
45 | ("_*a*", ["__anka",]), | |
46 | ] |
|
46 | ] | |
47 | for pat,res in tests: |
|
47 | for pat,res in tests: | |
48 | res.sort() |
|
48 | res.sort() | |
49 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=False).keys() |
|
49 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=False).keys() | |
50 | a.sort() |
|
50 | a.sort() | |
51 | self.assertEqual(a,res) |
|
51 | self.assertEqual(a,res) | |
52 |
|
52 | |||
53 | def test_case_showall(self): |
|
53 | def test_case_showall(self): | |
54 | ns=root.__dict__ |
|
54 | ns=root.__dict__ | |
55 | tests=[ |
|
55 | tests=[ | |
56 | ("a*", ["abbot","abel","active","arna",]), |
|
56 | ("a*", ["abbot","abel","active","arna",]), | |
57 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]), |
|
57 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]), | |
58 | ("_a*", ["_apan"]), |
|
58 | ("_a*", ["_apan"]), | |
59 | ("_*anka", ["__anka",]), |
|
59 | ("_*anka", ["__anka",]), | |
60 | ("_*a*", ["__anka","_apan",]), |
|
60 | ("_*a*", ["__anka","_apan",]), | |
61 | ] |
|
61 | ] | |
62 | for pat,res in tests: |
|
62 | for pat,res in tests: | |
63 | res.sort() |
|
63 | res.sort() | |
64 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=True).keys() |
|
64 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=True).keys() | |
65 | a.sort() |
|
65 | a.sort() | |
66 | self.assertEqual(a,res) |
|
66 | self.assertEqual(a,res) | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | def test_nocase(self): |
|
69 | def test_nocase(self): | |
70 | ns=root.__dict__ |
|
70 | ns=root.__dict__ | |
71 | tests=[ |
|
71 | tests=[ | |
72 | ("a*", ["abbot","abel","ABEL","active","arna",]), |
|
72 | ("a*", ["abbot","abel","ABEL","active","arna",]), | |
73 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), |
|
73 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), | |
74 | ("_a*", []), |
|
74 | ("_a*", []), | |
75 | ("_*anka", ["__anka","__ANKA",]), |
|
75 | ("_*anka", ["__anka","__ANKA",]), | |
76 | ("_*a*", ["__anka","__ANKA",]), |
|
76 | ("_*a*", ["__anka","__ANKA",]), | |
77 | ] |
|
77 | ] | |
78 | for pat,res in tests: |
|
78 | for pat,res in tests: | |
79 | res.sort() |
|
79 | res.sort() | |
80 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=False).keys() |
|
80 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=False).keys() | |
81 | a.sort() |
|
81 | a.sort() | |
82 | self.assertEqual(a,res) |
|
82 | self.assertEqual(a,res) | |
83 |
|
83 | |||
84 | def test_nocase_showall(self): |
|
84 | def test_nocase_showall(self): | |
85 | ns=root.__dict__ |
|
85 | ns=root.__dict__ | |
86 | tests=[ |
|
86 | tests=[ | |
87 | ("a*", ["abbot","abel","ABEL","active","arna",]), |
|
87 | ("a*", ["abbot","abel","ABEL","active","arna",]), | |
88 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), |
|
88 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), | |
89 | ("_a*", ["_apan","_APAN"]), |
|
89 | ("_a*", ["_apan","_APAN"]), | |
90 | ("_*anka", ["__anka","__ANKA",]), |
|
90 | ("_*anka", ["__anka","__ANKA",]), | |
91 | ("_*a*", ["__anka","__ANKA","_apan","_APAN"]), |
|
91 | ("_*a*", ["__anka","__ANKA","_apan","_APAN"]), | |
92 | ] |
|
92 | ] | |
93 | for pat,res in tests: |
|
93 | for pat,res in tests: | |
94 | res.sort() |
|
94 | res.sort() | |
95 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=True).keys() |
|
95 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=True).keys() | |
96 | a.sort() |
|
96 | a.sort() | |
97 | self.assertEqual(a,res) |
|
97 | self.assertEqual(a,res) | |
98 |
|
98 | |||
99 | if __name__ == '__main__': |
|
99 | if __name__ == '__main__': | |
100 | unittest.main() No newline at end of file |
|
100 | unittest.main() |
@@ -1,15 +1,15 b'' | |||||
1 | from path import path |
|
1 | from path import path | |
2 | fs = path('..').walkfiles('*.py') |
|
2 | fs = path('..').walkfiles('*.py') | |
3 |
|
3 | |||
4 | for f in fs: |
|
4 | for f in fs: | |
5 | errs = '' |
|
5 | errs = '' | |
6 | cont = f.bytes() |
|
6 | cont = f.bytes() | |
7 | if '\t' in cont: |
|
7 | if '\t' in cont: | |
8 | errs+='t' |
|
8 | errs+='t' | |
9 |
|
9 | |||
10 | if '\r' in cont: |
|
10 | if '\r' in cont: | |
11 | errs+='r' |
|
11 | errs+='r' | |
12 |
|
12 | |||
13 | if errs: |
|
13 | if errs: | |
14 | print "%3s" % errs, f |
|
14 | print "%3s" % errs, f | |
15 | No newline at end of file |
|
15 |
@@ -1,28 +1,28 b'' | |||||
1 | import os,sys,shutil |
|
1 | import os,sys,shutil | |
2 |
|
2 | |||
3 |
repo = "http://ipython.scipy.org/svn/ipython/ipython/ |
|
3 | repo = "http://ipython.scipy.org/svn/ipython/ipython/branches/0.7.3" | |
4 | basename = 'ipython' |
|
4 | basename = 'ipython' | |
5 | workdir = './mkdist' |
|
5 | workdir = './mkdist' | |
6 |
|
6 | |||
7 | workdir = os.path.abspath(workdir) |
|
7 | workdir = os.path.abspath(workdir) | |
8 |
|
8 | |||
9 | print "working at",workdir |
|
9 | print "working at",workdir | |
10 | def oscmd(c): |
|
10 | def oscmd(c): | |
11 | print ">",c |
|
11 | print ">",c | |
12 | s = os.system(c) |
|
12 | s = os.system(c) | |
13 | if s: |
|
13 | if s: | |
14 | print "Error",s |
|
14 | print "Error",s | |
15 | sys.exit(s) |
|
15 | sys.exit(s) | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | assert not os.path.isdir(workdir) |
|
18 | assert not os.path.isdir(workdir) | |
19 | os.mkdir(workdir) |
|
19 | os.mkdir(workdir) | |
20 | os.chdir(workdir) |
|
20 | os.chdir(workdir) | |
21 |
|
21 | |||
22 | oscmd('svn export %s %s' % (repo,basename)) |
|
22 | oscmd('svn export %s %s' % (repo,basename)) | |
23 | ver = os.popen('svnversion ../..').read().strip() |
|
23 | ver = os.popen('svnversion ../..').read().strip() | |
24 | tarname = '%s.r%s.tgz' % (basename, ver) |
|
24 | tarname = '%s.r%s.tgz' % (basename, ver) | |
25 | oscmd('tar czvf ../%s %s' % (tarname, basename)) |
|
25 | oscmd('tar czvf ../%s %s' % (tarname, basename)) | |
26 | print "Produced: ",os.path.abspath('../' + tarname) |
|
26 | print "Produced: ",os.path.abspath('../' + tarname) | |
27 | os.chdir('/') |
|
27 | os.chdir('/') | |
28 | shutil.rmtree(workdir) |
|
28 | shutil.rmtree(workdir) |
@@ -1,13 +1,13 b'' | |||||
1 | """ Change the revision number in Release.py """ |
|
1 | """ Change the revision number in Release.py """ | |
2 |
|
2 | |||
3 | import os |
|
3 | import os | |
4 | import re |
|
4 | import re | |
5 |
|
5 | |||
6 | rev = os.popen('svnversion ..').read().strip() |
|
6 | rev = os.popen('svnversion ..').read().strip() | |
7 |
|
7 | |||
8 | print "current rev is",rev |
|
8 | print "current rev is",rev | |
9 | assert ':' not in rev |
|
9 | assert ':' not in rev | |
10 |
|
10 | |||
11 | rfile = open('../IPython/Release.py').read() |
|
11 | rfile = open('../IPython/Release.py').read() | |
12 | newcont = re.sub(r'revision\s*=.*', "revision = '%s'" % rev, rfile) |
|
12 | newcont = re.sub(r'revision\s*=.*', "revision = '%s'" % rev, rfile) | |
13 | open('../IPython/Release.py','w').write(newcont) |
|
13 | open('../IPython/Release.py','w').write(newcont) |
General Comments 0
You need to be logged in to leave comments.
Login now