Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dependency on IPython genutils #238

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/requirements.txt
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
40 changes: 40 additions & 0 deletions nbformat/_imports.py
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])
Loading