diff --git a/openlp/core/utils/db.py b/openlp/core/common/db.py similarity index 100% rename from openlp/core/utils/db.py rename to openlp/core/common/db.py diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 086c69c79..a29e0693c 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -523,13 +523,15 @@ def get_locale_key(string): def get_natural_key(string): """ Generate a key for locale aware natural string sorting. + + :param string: string to be sorted by Returns a list of string compare keys and integers. """ key = DIGITS_OR_NONDIGITS.findall(string) key = [int(part) if part.isdigit() else get_locale_key(part) for part in key] # Python 3 does not support comparison of different types anymore. So make sure, that we do not compare str # and int. - if string[0].isdigit(): + if string and string[0].isdigit(): return [b''] + key return key diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index 09f7ce92a..19a67caa4 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -28,8 +28,8 @@ import logging from sqlalchemy import Table, Column, ForeignKey, types from sqlalchemy.sql.expression import func, false, null, text +from openlp.core.common.db import drop_columns from openlp.core.lib.db import get_upgrade_op -from openlp.core.utils.db import drop_columns log = logging.getLogger(__name__) __version__ = 5 diff --git a/tests/functional/openlp_core/__init__.py b/tests/functional/openlp_core/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core/test_db.py similarity index 98% rename from tests/functional/openlp_core_utils/test_db.py rename to tests/functional/openlp_core/test_db.py index f2c3d264a..4eb6959c2 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core/test_db.py @@ -22,17 +22,17 @@ """ Package to test the openlp.core.utils.db package. """ -from tempfile import mkdtemp -from unittest import TestCase import gc import os import shutil -import sqlalchemy import time +from tempfile import mkdtemp +from unittest import TestCase -from openlp.core.utils.db import drop_column, drop_columns +import sqlalchemy + +from openlp.core.common.db import drop_column, drop_columns from openlp.core.lib.db import init_db, get_upgrade_op - from tests.utils.constants import TEST_RESOURCES_PATH