##// END OF EJS Templates
ipy_exportdb now tolerates new style aliases'
vivainio -
Show More
@@ -1,73 +1,76 b''
1 1 import IPython.ipapi
2 2 ip = IPython.ipapi.get()
3 3
4 4 import os,pprint
5 5
6 6 def export(filename = None):
7 7
8 8 lines = ['import IPython.ipapi', 'ip = IPython.ipapi.get()','']
9 9
10 10 vars = ip.db.keys('autorestore/*')
11 11 vars.sort()
12 12 varstomove = []
13 13 get = ip.db.get
14 14
15 15 macros = []
16 16 variables = []
17 17
18 18 for var in vars:
19 19 k = os.path.basename(var)
20 20 v = get(var)
21 21
22 22 if k.startswith('_'):
23 23 continue
24 24 if isinstance(v, IPython.macro.Macro):
25 25 macros.append((k,v))
26 26 if type(v) in [int, str, float]:
27 27 variables.append((k,v))
28 28
29 29
30 30
31 31 if macros:
32 32 lines.extend(['# === Macros ===' ,''])
33 33 for k,v in macros:
34 34 lines.append("ip.defmacro('%s'," % k)
35 35 for line in v.value.splitlines():
36 36 lines.append(' ' + repr(line+'\n'))
37 37 lines.extend([')', ''])
38 38
39 39 if variables:
40 40 lines.extend(['','# === Variables ===',''])
41 41 for k,v in variables:
42 42 varstomove.append(k)
43 43 lines.append('%s = %s' % (k,repr(v)))
44 44
45 45 lines.append('ip.to_user_ns("%s")' % (' '.join(varstomove)))
46 46
47 47 bkms = ip.db.get('bookmarks',{})
48 48
49 49 if bkms:
50 50 lines.extend(['','# === Bookmarks ===',''])
51 51 lines.append("ip.db['bookmarks'] = %s " % pprint.pformat(bkms, indent = 2) )
52 52
53 53 aliases = ip.db.get('stored_aliases', {} )
54 54
55 55 if aliases:
56 56 lines.extend(['','# === Alias definitions ===',''])
57 57 for k,v in aliases.items():
58 lines.append("ip.defalias('%s', %s)" % (k, repr(v[1])))
58 try:
59 lines.append("ip.defalias('%s', %s)" % (k, repr(v[1])))
60 except (AttributeError, TypeError):
61 pass
59 62
60 63 env = ip.db.get('stored_env')
61 64 if env:
62 65 lines.extend(['','# === Stored env vars ===',''])
63 66 lines.append("ip.db['stored_env'] = %s " % pprint.pformat(env, indent = 2) )
64 67
65 68
66 69
67 70 out = '\n'.join(lines)
68 71
69 72 if filename:
70 73 open(filename,'w').write(out)
71 74 else:
72 75 print out
73 76
@@ -1,83 +1,83 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project.
3 3
4 $Id: Release.py 2677 2007-08-27 18:22:15Z vivainio $"""
4 $Id: Release.py 2681 2007-08-28 17:51:38Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 8 #
9 9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 10 # <n8gray@caltech.edu>
11 11 #
12 12 # Distributed under the terms of the BSD License. The full license is in
13 13 # the file COPYING, distributed as part of this software.
14 14 #*****************************************************************************
15 15
16 16 # Name of the package for release purposes. This is the name which labels
17 17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 18 name = 'ipython'
19 19
20 20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 21 # the new substring. We have to avoid using either dashes or underscores,
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 23 # bdist_deb does not accept underscores (a Debian convention).
24 24
25 revision = '2676'
25 revision = '2680M'
26 26
27 27 version = '0.8.2.svn.r' + revision.rstrip('M')
28 28
29 29 description = "An enhanced interactive Python shell."
30 30
31 31 long_description = \
32 32 """
33 33 IPython provides a replacement for the interactive Python interpreter with
34 34 extra functionality.
35 35
36 36 Main features:
37 37
38 38 * Comprehensive object introspection.
39 39
40 40 * Input history, persistent across sessions.
41 41
42 42 * Caching of output results during a session with automatically generated
43 43 references.
44 44
45 45 * Readline based name completion.
46 46
47 47 * Extensible system of 'magic' commands for controlling the environment and
48 48 performing many tasks related either to IPython or the operating system.
49 49
50 50 * Configuration system with easy switching between different setups (simpler
51 51 than changing $PYTHONSTARTUP environment variables every time).
52 52
53 53 * Session logging and reloading.
54 54
55 55 * Extensible syntax processing for special purpose situations.
56 56
57 57 * Access to the system shell with user-extensible alias system.
58 58
59 59 * Easily embeddable in other Python programs.
60 60
61 61 * Integrated access to the pdb debugger and the Python profiler.
62 62
63 63 The latest development version is always available at the IPython subversion
64 64 repository_.
65 65
66 66 .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev
67 67 """
68 68
69 69 license = 'BSD'
70 70
71 71 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
72 72 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
73 73 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
74 74 'Ville' : ('Ville Vainio','vivainio@gmail.com')
75 75 }
76 76
77 77 url = 'http://ipython.scipy.org'
78 78
79 79 download_url = 'http://ipython.scipy.org/dist'
80 80
81 81 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
82 82
83 83 keywords = ['Interactive','Interpreter','Shell']
General Comments 0
You need to be logged in to leave comments. Login now