##// END OF EJS Templates
Update copyright/author statements....
Update copyright/author statements. - Updated copyright statements to use the new form: # Copyright (C) 2008-2009 The IPython Development Team I left the old notices in place (just updating the year in some cases), because as far as I know, old copyright statements are not meant to be retroactively modified. - Also, on most files, replaced __author__ marks with an 'Authors' section in the module docstring. This reduces top-level code in the module, while ensuring that the Author(s) get properly acknowledged in auto-generated API docs (sphinx doesn't read __author__ marks, but it will include the module docstring). I only left a few in place for very old files that we ship externally, and for those by Laurent: he had his authorship mark both in the docstring and in __author__ variables, so I think out of courtesy it would be better to ask him about it on the list. All the others were I found regular __author__ variables, I moved them to the main docstring.

File last commit:

r809:4dc30e0b
r1875:bba7e571
Show More
ipy_exportdb.py
76 lines | 2.0 KiB | text/x-python | PythonLexer
vivainio
crlf cleanup
r680 import IPython.ipapi
ip = IPython.ipapi.get()
import os,pprint
def export(filename = None):
lines = ['import IPython.ipapi', 'ip = IPython.ipapi.get()','']
vars = ip.db.keys('autorestore/*')
vars.sort()
varstomove = []
get = ip.db.get
macros = []
variables = []
for var in vars:
k = os.path.basename(var)
v = get(var)
if k.startswith('_'):
continue
if isinstance(v, IPython.macro.Macro):
macros.append((k,v))
if type(v) in [int, str, float]:
variables.append((k,v))
if macros:
lines.extend(['# === Macros ===' ,''])
for k,v in macros:
lines.append("ip.defmacro('%s'," % k)
for line in v.value.splitlines():
lines.append(' ' + repr(line+'\n'))
lines.extend([')', ''])
if variables:
lines.extend(['','# === Variables ===',''])
for k,v in variables:
varstomove.append(k)
lines.append('%s = %s' % (k,repr(v)))
lines.append('ip.to_user_ns("%s")' % (' '.join(varstomove)))
bkms = ip.db.get('bookmarks',{})
if bkms:
lines.extend(['','# === Bookmarks ===',''])
lines.append("ip.db['bookmarks'] = %s " % pprint.pformat(bkms, indent = 2) )
aliases = ip.db.get('stored_aliases', {} )
if aliases:
lines.extend(['','# === Alias definitions ===',''])
for k,v in aliases.items():
vivainio
ipy_exportdb now tolerates new style aliases'
r809 try:
lines.append("ip.defalias('%s', %s)" % (k, repr(v[1])))
except (AttributeError, TypeError):
pass
vivainio
crlf cleanup
r680
env = ip.db.get('stored_env')
if env:
lines.extend(['','# === Stored env vars ===',''])
lines.append("ip.db['stored_env'] = %s " % pprint.pformat(env, indent = 2) )
out = '\n'.join(lines)
if filename:
open(filename,'w').write(out)
else:
print out