From 248d7f5678437ef0f25b0783e90fda510eae213f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 10 Nov 2021 19:53:05 +0100 Subject: [PATCH] data_migrations -> migrations --- .../0021_migrate_to_bullseye.py | 0 .../0022_php73_to_php74_pools.py | 0 .../0023_postgresql_11_to_13.py | 0 src/{data_migrations => migrations}/__init__.py | 0 src/tools.py | 10 +++++----- tests/add_missing_keys.py | 4 ++-- tests/test_i18n_keys.py | 4 ++-- tox.ini | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename src/{data_migrations => migrations}/0021_migrate_to_bullseye.py (100%) rename src/{data_migrations => migrations}/0022_php73_to_php74_pools.py (100%) rename src/{data_migrations => migrations}/0023_postgresql_11_to_13.py (100%) rename src/{data_migrations => migrations}/__init__.py (100%) diff --git a/src/data_migrations/0021_migrate_to_bullseye.py b/src/migrations/0021_migrate_to_bullseye.py similarity index 100% rename from src/data_migrations/0021_migrate_to_bullseye.py rename to src/migrations/0021_migrate_to_bullseye.py diff --git a/src/data_migrations/0022_php73_to_php74_pools.py b/src/migrations/0022_php73_to_php74_pools.py similarity index 100% rename from src/data_migrations/0022_php73_to_php74_pools.py rename to src/migrations/0022_php73_to_php74_pools.py diff --git a/src/data_migrations/0023_postgresql_11_to_13.py b/src/migrations/0023_postgresql_11_to_13.py similarity index 100% rename from src/data_migrations/0023_postgresql_11_to_13.py rename to src/migrations/0023_postgresql_11_to_13.py diff --git a/src/data_migrations/__init__.py b/src/migrations/__init__.py similarity index 100% rename from src/data_migrations/__init__.py rename to src/migrations/__init__.py diff --git a/src/tools.py b/src/tools.py index a92e478de..f9de32cfe 100644 --- a/src/tools.py +++ b/src/tools.py @@ -933,12 +933,12 @@ def _get_migrations_list(): migrations = [] try: - from . import data_migrations + from . import migrations except ImportError: # not data migrations present, return empty list return migrations - migrations_path = data_migrations.__path__[0] + migrations_path = migrations.__path__[0] if not os.path.exists(migrations_path): logger.warn(m18n.n("migrations_cant_reach_migration_file", migrations_path)) @@ -973,11 +973,11 @@ def _get_migration_by_name(migration_name): """ try: - from . import data_migrations + from . import migrations except ImportError: raise AssertionError("Unable to find migration with name %s" % migration_name) - migrations_path = data_migrations.__path__[0] + migrations_path = migrations.__path__[0] migrations_found = [ x for x in os.listdir(migrations_path) @@ -1001,7 +1001,7 @@ def _load_migration(migration_file): # this is python builtin method to import a module using a name, we # use that to import the migration as a python object so we'll be # able to run it in the next loop - module = import_module("yunohost.data_migrations.{}".format(migration_id)) + module = import_module("yunohost.migrations.{}".format(migration_id)) return module.MyMigration(migration_id) except Exception as e: import traceback diff --git a/tests/add_missing_keys.py b/tests/add_missing_keys.py index 1bf335418..e1ecbf56e 100644 --- a/tests/add_missing_keys.py +++ b/tests/add_missing_keys.py @@ -26,7 +26,7 @@ def find_expected_string_keys(): python_files = glob.glob("src/*.py") python_files.extend(glob.glob("src/utils/*.py")) - python_files.extend(glob.glob("src/data_migrations/*.py")) + python_files.extend(glob.glob("src/migrations/*.py")) python_files.extend(glob.glob("src/authenticators/*.py")) python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.append("bin/yunohost") @@ -63,7 +63,7 @@ def find_expected_string_keys(): ] # For each migration, expect to find "migration_description_" - for path in glob.glob("src/data_migrations/*.py"): + for path in glob.glob("src/migrations/*.py"): if "__init__" in path: continue yield "migration_description_" + os.path.basename(path)[:-3] diff --git a/tests/test_i18n_keys.py b/tests/test_i18n_keys.py index d0ae75bfc..b25d35923 100644 --- a/tests/test_i18n_keys.py +++ b/tests/test_i18n_keys.py @@ -27,7 +27,7 @@ def find_expected_string_keys(): python_files = glob.glob("src/*.py") python_files.extend(glob.glob("src/utils/*.py")) - python_files.extend(glob.glob("src/data_migrations/*.py")) + python_files.extend(glob.glob("src/migrations/*.py")) python_files.extend(glob.glob("src/authenticators/*.py")) python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.append("bin/yunohost") @@ -64,7 +64,7 @@ def find_expected_string_keys(): ] # For each migration, expect to find "migration_description_" - for path in glob.glob("src/data_migrations/*.py"): + for path in glob.glob("src/migrations/*.py"): if "__init__" in path: continue yield "migration_description_" + os.path.basename(path)[:-3] diff --git a/tox.ini b/tox.ini index e5cffb696..3e3fcbf2e 100644 --- a/tox.ini +++ b/tox.ini @@ -12,4 +12,4 @@ commands = py39-invalidcode: flake8 src data --exclude src/tests,src/vendor --select F,E722,W605 py39-black-check: black --check --diff src doc data tests py39-black-run: black src doc data tests - py39-mypy: mypy --ignore-missing-import --install-types --non-interactive --follow-imports silent src/ --exclude (acme_tiny|data_migrations) + py39-mypy: mypy --ignore-missing-import --install-types --non-interactive --follow-imports silent src/ --exclude (acme_tiny|migrations)