-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove dependency on IPython genutils (#238)
- Loading branch information
Showing
16 changed files
with
504 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
ipython_genutils | ||
jsonschema | ||
traitlets | ||
-e git+https://github.com/jupyter/jupyter_core.git#egg=jupyter_core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
A simple utility to import something by its string name. | ||
Vendored form ipython_genutils | ||
""" | ||
|
||
# Copyright (c) IPython Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
|
||
def import_item(name): | ||
"""Import and return ``bar`` given the string ``foo.bar``. | ||
Calling ``bar = import_item("foo.bar")`` is the functional equivalent of | ||
executing the code ``from foo import bar``. | ||
Parameters | ||
---------- | ||
name : string | ||
The fully qualified name of the module/package being imported. | ||
Returns | ||
------- | ||
mod : module object | ||
The module that was imported. | ||
""" | ||
|
||
parts = name.rsplit(".", 1) | ||
if len(parts) == 2: | ||
# called with 'foo.bar....' | ||
package, obj = parts | ||
module = __import__(package, fromlist=[obj]) | ||
try: | ||
pak = getattr(module, obj) | ||
except AttributeError: | ||
raise ImportError("No module named %s" % obj) | ||
return pak | ||
else: | ||
# called with un-dotted string | ||
return __import__(parts[0]) |
Oops, something went wrong.