Show More
@@ -35,9 +35,13 b' warn("The top-level `frontend` package has been deprecated. "' | |||||
35 |
|
35 | |||
36 | class ShimModule(types.ModuleType): |
|
36 | class ShimModule(types.ModuleType): | |
37 |
|
37 | |||
38 |
def __ |
|
38 | def __init__(self, *args, **kwargs): | |
|
39 | self._mirror = kwargs.pop("mirror") | |||
|
40 | super(ShimModule, self).__init__(*args, **kwargs) | |||
|
41 | ||||
|
42 | def __getattr__(self, key): | |||
39 | # Use the equivalent of import_item(name), see below |
|
43 | # Use the equivalent of import_item(name), see below | |
40 | name = 'IPython.' + key |
|
44 | name = "%s.%s" % (self._mirror, key) | |
41 |
|
45 | |||
42 | # NOTE: the code below is copied *verbatim* from |
|
46 | # NOTE: the code below is copied *verbatim* from | |
43 | # importstring.import_item. For some very strange reason that makes no |
|
47 | # importstring.import_item. For some very strange reason that makes no | |
@@ -50,7 +54,7 b' class ShimModule(types.ModuleType):' | |||||
50 | # the below could be replaced simply with: |
|
54 | # the below could be replaced simply with: | |
51 | # |
|
55 | # | |
52 | # from IPython.utils.importstring import import_item |
|
56 | # from IPython.utils.importstring import import_item | |
53 |
# return import_item(' |
|
57 | # return import_item('MIRROR.' + key) | |
54 |
|
58 | |||
55 | parts = name.rsplit('.', 1) |
|
59 | parts = name.rsplit('.', 1) | |
56 | if len(parts) == 2: |
|
60 | if len(parts) == 2: | |
@@ -70,4 +74,5 b' class ShimModule(types.ModuleType):' | |||||
70 | # Unconditionally insert the shim into sys.modules so that further import calls |
|
74 | # Unconditionally insert the shim into sys.modules so that further import calls | |
71 | # trigger the custom attribute access above |
|
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