##// END OF EJS Templates
Minor updates to release scripts, new backup one using SVN (a lot simpler).
Minor updates to release scripts, new backup one using SVN (a lot simpler).

File last commit:

r292:8dcaaddb
r314:fe5fa758
Show More
FakeModule.py
51 lines | 1.7 KiB | text/x-python | PythonLexer
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # -*- coding: utf-8 -*-
"""
Class which mimics a module.
Needed to allow pickle to correctly resolve namespaces during IPython
sessions.
fperez
- add support for PyCrust-style _getAttributeNames magic method. Closes #50....
r292 $Id: FakeModule.py 1322 2006-05-24 07:51:39Z fperez $"""
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
#*****************************************************************************
# Copyright (C) 2002-2004 Fernando Perez. <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
class FakeModule:
"""Simple class with attribute access to fake a module.
This is not meant to replace a module, but to allow inserting a fake
module in sys.modules so that systems which rely on run-time module
importing (like shelve and pickle) work correctly in interactive IPython
sessions.
Do NOT use this code for anything other than this IPython private hack."""
def __init__(self,adict):
# It seems pydoc (and perhaps others) needs any module instance to
# implement a __nonzero__ method, so we add it if missing:
if '__nonzero__' not in adict:
def __nonzero__():
return 1
adict['__nonzero__'] = __nonzero__
self.__dict__ = adict
fperez
- add support for PyCrust-style _getAttributeNames magic method. Closes #50....
r292 # modules should have a __file__ attribute
adict['__file__'] = __file__
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def __getattr__(self,key):
try:
return self.__dict__[key]
except KeyError, e:
raise AttributeError("FakeModule object has no attribute %s" % e)
def __str__(self):
return "<IPython.FakeModule instance>"
def __repr__(self):
return str(self)