diff --git a/bonobo/commands/__init__.py b/bonobo/commands/__init__.py index c5d4908..56d615d 100644 --- a/bonobo/commands/__init__.py +++ b/bonobo/commands/__init__.py @@ -150,25 +150,6 @@ def _override_runner(runner): bonobo.run = _run -def get_default_services(filename, services=None): - dirname = os.path.dirname(filename) - services_filename = os.path.join(dirname, DEFAULT_SERVICES_FILENAME) - if os.path.exists(services_filename): - with open(services_filename) as file: - code = compile(file.read(), services_filename, 'exec') - context = { - '__name__': '__services__', - '__file__': services_filename, - } - exec(code, context) - - return { - **context[DEFAULT_SERVICES_ATTR](), - **(services or {}), - } - return services or {} - - def set_env_var(e, override=False): __escape_decoder = codecs.getdecoder('unicode_escape') ename, evalue = e.split('=', 1) diff --git a/bonobo/util/__init__.py b/bonobo/util/__init__.py index 4ef136e..27e50b2 100644 --- a/bonobo/util/__init__.py +++ b/bonobo/util/__init__.py @@ -15,7 +15,6 @@ from bonobo.util.inspect import ( istype, ) from bonobo.util.objects import (get_name, get_attribute_or_create, ValueHolder) -from bonobo.util.python import require # Bonobo's util API __all__ = [ @@ -35,5 +34,4 @@ __all__ = [ 'ismethod', 'isoption', 'istype', - 'require', ] diff --git a/bonobo/util/python.py b/bonobo/util/python.py deleted file mode 100644 index 8648f16..0000000 --- a/bonobo/util/python.py +++ /dev/null @@ -1,31 +0,0 @@ -import inspect -import os -import runpy - - -class _RequiredModule: - def __init__(self, dct): - self.__dict__ = dct - - -class _RequiredModulesRegistry(dict): - @property - def pathname(self): - return os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.stack()[2][0]))) - - def require(self, name): - if name not in self: - bits = name.split('.') - filename = os.path.join(self.pathname, *bits[:-1], bits[-1] + '.py') - self[name] = _RequiredModule(runpy.run_path(filename, run_name=name)) - return self[name] - - -class WorkingDirectoryModulesRegistry(_RequiredModulesRegistry): - @property - def pathname(self): - return os.getcwd() - - -registry = _RequiredModulesRegistry() -require = registry.require