'Import a Python module or Java class using a file system path.
When importing a Python file, the path must end with \'.py\' and the
actual file must also exist. When importing Java classes, the path
must end with \'.java\' or \'.class\'. The class file must exist in both
cases and in the former case also the source file must exist.
If `instantiate_with_args` is not None, imported classes are
instantiated with the specified arguments automatically.'

def import_class_or_module_by_path(self, path, instantiate_with_args=None):

    try:
        (imported, source) = self._by_path_importer.import_(path)
        self._log_import_succeeded(imported, imported.__name__, source)
        return self._instantiate_if_needed(imported, instantiate_with_args)
    except DataError as err:
        self._raise_import_failed(path, err)
