geonature.utils.module

Functions

iter_modules_dist()

get_module_config_path(module_code)

get_module_config(module_dist)

get_dist_from_code(module_code)

iterate_revisions(script, base_revision)

Iterate revisions without following depends_on directive.

get_script_from_config(→ alembic.script.ScriptDirectory)

get_all_current_alembic_heads(→ set)

get_script_and_base_revision_for_one_branch(...)

get_all_revisions_for_one_branch(→ set)

get_last_revision_for_one_branch(→ set)

alembic_branch_in_use(branch_name, directory, x_arg)

Is an Alembic branch in use.

is_alembic_branch_up_to_date(→ bool)

Is a specific Alembic branch fully stamped.

exists_in_t_modules(module_code)

Returns True if a module with the given code exists in the database

is_module_installed(python_module_name[, ...])

Is a GeoNature module installed.

module_db_upgrade(module_dist[, directory, sql, tag, ...])

get_module_version(module_code)

Get the module version from the module_code. We check what python package is installed.

Module Contents

geonature.utils.module.iter_modules_dist()[source]
geonature.utils.module.get_module_config_path(module_code)[source]
geonature.utils.module.get_module_config(module_dist)[source]
geonature.utils.module.get_dist_from_code(module_code)[source]
geonature.utils.module.iterate_revisions(script, base_revision)[source]

Iterate revisions without following depends_on directive. Useful to find all revisions of a given branch.

geonature.utils.module.get_script_from_config(directory: str, x_arg: []) alembic.script.ScriptDirectory[source]
geonature.utils.module.get_all_current_alembic_heads(directory: str, x_arg: []) set[source]
geonature.utils.module.get_script_and_base_revision_for_one_branch(branch_name: str, directory, x_arg)[source]
geonature.utils.module.get_all_revisions_for_one_branch(branch_name: str, directory, x_arg) set[source]
geonature.utils.module.get_last_revision_for_one_branch(branch_name: str, directory, x_arg) set[source]
geonature.utils.module.alembic_branch_in_use(branch_name: str, directory, x_arg)[source]

Is an Alembic branch in use.

Return True if at least one revision of the given branch is stamped.

Returns

bool

True if the Alembic branch has at least one revision stamped, False otherwise.

geonature.utils.module.is_alembic_branch_up_to_date(branch_name: str, directory: str = None, x_arg: list = []) bool[source]

Is a specific Alembic branch fully stamped.

Parameters

branch_namestr

The name of the Alembic branch.

directorystr

The name of the directory containing the migrations files for the branch. Value of None defaults to « migrations ».

x_arglist

Additional arguments consumed by custom env.py scripts.

Returns

bool

True if the Alembic branch has all its revisions stamped, False otherwise.

geonature.utils.module.exists_in_t_modules(module_code: str)[source]

Returns True if a module with the given code exists in the database

Parameters

module_codestr

The code of the module (for ex. : SYNTHESE, OCCHAB, etc…)

geonature.utils.module.is_module_installed(python_module_name: str, migrations_dir: str = None, alembic_branch_name: str = None, check_if_all_revisions_have_been_applied: bool = True)[source]

Is a GeoNature module installed.

We consider a module is installed if and only if: - The Python package is installed

and (

check_if_all_revisions_have_been_applied == true and

(

all its Alembic migrations are stamped or there is no Alembic migration at all for the module

)

) and the module is registered in the database

Parameters

python_module_namestr

The name of the python module. Can be found in the root file « setup.py » of the module repository. Examples:

  • « gn_module_occhab »

  • « occtax »

  • « gn_module_validation »

  • « gn_module_dashboard »

  • « gn_module_export »

  • « gn_module_monitoring »

migrations_dirstr

The name of the directory containing the migrations files for the branch. Value of None defaults to « migrations ».

alembic_branch_namestr

The name of the Alembic branch. Value of None defaults to the module code in lowercase.

check_if_all_revisions_have_been_appliedbool

Check if all revisions of the module have been applied.

Returns

bool

True if the module is installed, False otherwise.

geonature.utils.module.module_db_upgrade(module_dist, directory=None, sql=False, tag=None, x_arg=[])[source]
geonature.utils.module.get_module_version(module_code: str)[source]

Get the module version from the module_code. We check what python package is installed. If no package is found, we return None.