astro.utils.path

Module Contents

Functions

get_module_dot_notation(module_path)

Given a module path, return the dot notation import string starting at astro.

get_dict_with_module_names_to_dot_notations(base_path)

Given a directory, recursively identify which modules exist within it

get_class_name(module_ref[, suffix])

Get class name to be dynamically imported. Class name are expected to be in following formats

astro.utils.path.get_module_dot_notation(module_path)

Given a module path, return the dot notation import string starting at astro.

Parameters

module_path (pathlib.Path) – Path to the module of interest

Returns

String containing the absolute dot notation path to the module

Return type

str

astro.utils.path.get_dict_with_module_names_to_dot_notations(base_path)

Given a directory, recursively identify which modules exist within it (ignoring __init__.py & base.py) and create a dictionary which has module names as keys and the values are the dot notation import paths.

An example:

├── package
    ├── module.py
    ├── subpackage
       ├── __init__.py
       └── subpackage_module.py

Running:

from pathlib import Path
from astro.utils.path import get_dict_with_module_names_to_dot_notations

values = get_dict_with_module_names_to_dot_notations(Path("package"))
print(values)

Prints:

{
    "module": "package.module",
    "subpackage_module": "package.subpackage.subpackage_module"
}
Parameters

base_path (pathlib.Path) –

Return type

dict[str, str]

astro.utils.path.get_class_name(module_ref, suffix='Location')

Get class name to be dynamically imported. Class name are expected to be in following formats example - module name: test suffix: Abc

expected class names -
  1. TESTAbc

  2. TestAbc

Parameters
  • module_ref (Any) – Module from which to get class location type implementation

  • suffix (str) – suffix for class name

Return type

str