ds_resource_plugin_py_lib.libs.utils.import_string

File: import_string.py Region: ds_resource_plugin_py_lib/libs/utils

Description

Utility function to import a dotted module path and return the attribute/class designated by the last name in the path.

Example

from ds_resource_plugin_py_lib.libs.utils.import_string import import_string

# Import a symbol by dotted path.
json_loads = import_string("json.loads")
result = json_loads('{"a": 1}')

Attributes

logger

Functions

import_string(→ Any)

Import a dotted module path and return the attribute/class designated by the last name in the path.

Module Contents

ds_resource_plugin_py_lib.libs.utils.import_string.logger
ds_resource_plugin_py_lib.libs.utils.import_string.import_string(dotted_path: str) Any[source]

Import a dotted module path and return the attribute/class designated by the last name in the path. :param dotted_path: The dotted module path to import.

Returns:

The attribute/class designated by the last name in the path.

Raise ImportError if the import failed.