Uses algorithm borrowed from networkx graph library to sort a graph in topological order. The method is only used by output plugins, as internal plumbery does not really care about the node order. Also includes a bonobo.util.python.require function that helps importing thing in a package-less context, or when there are conflict with site package names.
24 lines
595 B
Python
24 lines
595 B
Python
def require(package, requirement=None):
|
|
requirement = requirement or package
|
|
|
|
try:
|
|
return __import__(package)
|
|
except ImportError:
|
|
from colorama import Fore, Style
|
|
print(
|
|
Fore.YELLOW,
|
|
'This example requires the {!r} package. Install it using:'.
|
|
format(requirement),
|
|
Style.RESET_ALL,
|
|
sep=''
|
|
)
|
|
print()
|
|
print(
|
|
Fore.YELLOW,
|
|
' $ pip install {!s}'.format(requirement),
|
|
Style.RESET_ALL,
|
|
sep=''
|
|
)
|
|
print()
|
|
raise
|