Show More
@@ -34,10 +34,14 b' warn("The top-level `frontend` package has been deprecated. "' | |||
|
34 | 34 | #----------------------------------------------------------------------------- |
|
35 | 35 | |
|
36 | 36 | class ShimModule(types.ModuleType): |
|
37 | ||
|
38 | def __init__(self, *args, **kwargs): | |
|
39 | self._mirror = kwargs.pop("mirror") | |
|
40 | super(ShimModule, self).__init__(*args, **kwargs) | |
|
37 | 41 | |
|
38 |
def __getattr |
|
|
42 | def __getattr__(self, key): | |
|
39 | 43 | # Use the equivalent of import_item(name), see below |
|
40 | name = 'IPython.' + key | |
|
44 | name = "%s.%s" % (self._mirror, key) | |
|
41 | 45 | |
|
42 | 46 | # NOTE: the code below is copied *verbatim* from |
|
43 | 47 | # importstring.import_item. For some very strange reason that makes no |
@@ -50,7 +54,7 b' class ShimModule(types.ModuleType):' | |||
|
50 | 54 | # the below could be replaced simply with: |
|
51 | 55 | # |
|
52 | 56 | # from IPython.utils.importstring import import_item |
|
53 |
# return import_item(' |
|
|
57 | # return import_item('MIRROR.' + key) | |
|
54 | 58 | |
|
55 | 59 | parts = name.rsplit('.', 1) |
|
56 | 60 | if len(parts) == 2: |
@@ -70,4 +74,5 b' class ShimModule(types.ModuleType):' | |||
|
70 | 74 | # Unconditionally insert the shim into sys.modules so that further import calls |
|
71 | 75 | # trigger the custom attribute access above |
|
72 | 76 | |
|
73 |
sys.modules['IPython.frontend'] = ShimModule(' |
|
|
77 | sys.modules['IPython.frontend.html.notebook'] = ShimModule('notebook', mirror='IPython.html') | |
|
78 | sys.modules['IPython.frontend'] = ShimModule('frontend', mirror='IPython') |
General Comments 0
You need to be logged in to leave comments.
Login now