forked from openlp/openlp
fix string in natural sort and move db
This commit is contained in:
parent
b74221daff
commit
3693cf331d
@ -523,13 +523,15 @@ def get_locale_key(string):
|
|||||||
def get_natural_key(string):
|
def get_natural_key(string):
|
||||||
"""
|
"""
|
||||||
Generate a key for locale aware natural string sorting.
|
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.
|
Returns a list of string compare keys and integers.
|
||||||
"""
|
"""
|
||||||
key = DIGITS_OR_NONDIGITS.findall(string)
|
key = DIGITS_OR_NONDIGITS.findall(string)
|
||||||
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
|
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
|
# Python 3 does not support comparison of different types anymore. So make sure, that we do not compare str
|
||||||
# and int.
|
# and int.
|
||||||
if string[0].isdigit():
|
if string and string[0].isdigit():
|
||||||
return [b''] + key
|
return [b''] + key
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ import logging
|
|||||||
from sqlalchemy import Table, Column, ForeignKey, types
|
from sqlalchemy import Table, Column, ForeignKey, types
|
||||||
from sqlalchemy.sql.expression import func, false, null, text
|
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.lib.db import get_upgrade_op
|
||||||
from openlp.core.utils.db import drop_columns
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
__version__ = 5
|
__version__ = 5
|
||||||
|
0
tests/functional/openlp_core/__init__.py
Normal file
0
tests/functional/openlp_core/__init__.py
Normal file
@ -22,17 +22,17 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.core.utils.db package.
|
Package to test the openlp.core.utils.db package.
|
||||||
"""
|
"""
|
||||||
from tempfile import mkdtemp
|
|
||||||
from unittest import TestCase
|
|
||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sqlalchemy
|
|
||||||
import time
|
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 openlp.core.lib.db import init_db, get_upgrade_op
|
||||||
|
|
||||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user