##// END OF EJS Templates
Merge pull request #1934 from minrk/cellmd...
Merge pull request #1934 from minrk/cellmd Cell/Worksheet metadata * metadata dicts are attached to cells and worksheets * restores collapsed flag to the nbformat - this change happened in the refactor, and was undocumented, and possibly accidental. But we should either document it or fix it, and this includes a fix. * adds a new field, `nbformat_minor`, used to denote minor bumps of the notebook format that expose new capabilities but don't prevent loading by older clients. * Add a warning in Javascript if loading a multiworksheet notebook (which will exist in the future) as current JS code will only save the first. closes #1915

File last commit:

r2267:928c921b
r7612:ca7d2a9c merge
Show More
ipy_which.py
76 lines | 1.9 KiB | text/x-python | PythonLexer
vivainio
crlf cleanup
r680 r""" %which magic command
%which <cmd> => search PATH for files matching PATH. Also scans aliases
"""
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 from IPython.core import ipapi
ip = ipapi.get()
vivainio
crlf cleanup
r680
import os,sys
from fnmatch import fnmatch
def which(fname):
fullpath = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
if '.' not in fullpath:
fullpath = ['.'] + fullpath
fn = fname
for p in fullpath:
for f in os.listdir(p):
head, ext = os.path.splitext(f)
if f == fn or fnmatch(head, fn):
yield os.path.join(p,f)
return
def which_alias(fname):
Brian Granger
Continuing a massive refactor of everything.
r2205 for al, tgt in ip.alias_table.items():
vivainio
crlf cleanup
r680 if not (al == fname or fnmatch(al, fname)):
continue
vivainio
improve callable alias inspection
r831 if callable(tgt):
print "Callable alias",tgt
d = tgt.__doc__
if d:
print "Docstring:\n",d
continue
vivainio
crlf cleanup
r680 trg = tgt[1]
trans = ip.expand_alias(trg)
cmd = trans.split(None,1)[0]
print al,"->",trans
for realcmd in which(cmd):
print " ==",realcmd
def which_f(self, arg):
r""" %which <cmd> => search PATH for files matching cmd. Also scans aliases.
Traverses PATH and prints all files (not just executables!) that match the
pattern on command line. Probably more useful in finding stuff
interactively than 'which', which only prints the first matching item.
Also discovers and expands aliases, so you'll see what will be executed
when you call an alias.
Example:
[~]|62> %which d
d -> ls -F --color=auto
== c:\cygwin\bin\ls.exe
c:\cygwin\bin\d.exe
[~]|64> %which diff*
diff3 -> diff3
== c:\cygwin\bin\diff3.exe
diff -> diff
== c:\cygwin\bin\diff.exe
c:\cygwin\bin\diff.exe
c:\cygwin\bin\diff3.exe
"""
which_alias(arg)
for e in which(arg):
print e
Brian Granger
Continuing a massive refactor of everything.
r2205 ip.define_magic("which",which_f)
vivainio
crlf cleanup
r680