rename openlp.core.utils.get_local_key to openlp.core.utils.get_locale_key

This commit is contained in:
M2j 2013-04-05 19:41:01 +02:00
parent 2598674d2a
commit 042bf4ed2d
9 changed files with 24 additions and 24 deletions

View File

@ -44,7 +44,7 @@ from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, Backgr
from openlp.core.lib.ui import critical_error_message_box, create_widget_action from openlp.core.lib.ui import critical_error_message_box, create_widget_action
from openlp.core.theme import Theme from openlp.core.theme import Theme
from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.ui import FileRenameForm, ThemeForm
from openlp.core.utils import AppLocation, delete_file, get_local_key, get_filesystem_encoding from openlp.core.utils import AppLocation, delete_file, get_locale_key, get_filesystem_encoding
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -418,7 +418,7 @@ class ThemeManager(QtGui.QWidget):
self.theme_list_widget.clear() self.theme_list_widget.clear()
files = AppLocation.get_files(self.settings_section, u'.png') files = AppLocation.get_files(self.settings_section, u'.png')
# Sort the themes by its name considering language specific # Sort the themes by its name considering language specific
files.sort(key=lambda file_name: get_local_key(unicode(file_name))) files.sort(key=lambda file_name: get_locale_key(unicode(file_name)))
# now process the file list of png files # now process the file list of png files
for name in files: for name in files:
# check to see file is in theme root directory # check to see file is in theme root directory

View File

@ -382,7 +382,7 @@ def format_time(text, local_time):
return re.sub('\%[a-zA-Z]', match_formatting, text) return re.sub('\%[a-zA-Z]', match_formatting, text)
def get_local_key(string): def get_locale_key(string):
""" """
Creates a key for case insensitive, locale aware string sorting. Creates a key for case insensitive, locale aware string sorting.
""" """
@ -403,7 +403,7 @@ def get_natural_key(string):
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_local_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 comparision of different types anymore. So make sure, that we do not compare str and int. # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str and int.
#if string[0].isdigit(): #if string[0].isdigit():
# return [''] + key # return [''] + key
@ -417,4 +417,4 @@ from actions import ActionList
__all__ = [u'AppLocation', u'ActionList', u'LanguageManager', u'get_application_version', u'check_latest_version', __all__ = [u'AppLocation', u'ActionList', u'LanguageManager', u'get_application_version', u'check_latest_version',
u'add_actions', u'get_filesystem_encoding', u'get_web_page', u'get_uno_command', u'get_uno_instance', u'add_actions', u'get_filesystem_encoding', u'get_web_page', u'get_uno_command', u'get_uno_instance',
u'delete_file', u'clean_filename', u'format_time', u'get_local_key', u'get_natural_key'] u'delete_file', u'clean_filename', u'format_time', u'get_locale_key', u'get_natural_key']

View File

@ -38,7 +38,7 @@ from openlp.core.lib import Settings, UiStrings, translate
from openlp.core.lib.db import delete_database from openlp.core.lib.db import delete_database
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import AppLocation, get_local_key from openlp.core.utils import AppLocation, get_locale_key
from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.manager import BibleFormat
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
@ -455,7 +455,7 @@ class BibleImportForm(OpenLPWizard):
""" """
self.webTranslationComboBox.clear() self.webTranslationComboBox.clear()
bibles = self.web_bible_list[index].keys() bibles = self.web_bible_list[index].keys()
bibles.sort(key=get_local_key) bibles.sort(key=get_locale_key)
self.webTranslationComboBox.addItems(bibles) self.webTranslationComboBox.addItems(bibles)
def onOsisBrowseButtonClicked(self): def onOsisBrowseButtonClicked(self):

View File

@ -36,7 +36,7 @@ from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, Servic
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \ from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \
critical_error_message_box, find_and_set_in_combo_box, build_icon critical_error_message_box, find_and_set_in_combo_box, build_icon
from openlp.core.utils import get_local_key from openlp.core.utils import get_locale_key
from openlp.plugins.bibles.forms import BibleImportForm, EditBibleForm from openlp.plugins.bibles.forms import BibleImportForm, EditBibleForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, VerseReferenceList, get_reference_separator, \ from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, VerseReferenceList, get_reference_separator, \
LanguageSelection, BibleStrings LanguageSelection, BibleStrings
@ -325,7 +325,7 @@ class BibleMediaItem(MediaManagerItem):
# Get all bibles and sort the list. # Get all bibles and sort the list.
bibles = self.plugin.manager.get_bibles().keys() bibles = self.plugin.manager.get_bibles().keys()
bibles = filter(None, bibles) bibles = filter(None, bibles)
bibles.sort(key=get_local_key) bibles.sort(key=get_locale_key)
# Load the bibles into the combo boxes. # Load the bibles into the combo boxes.
self.quickVersionComboBox.addItems(bibles) self.quickVersionComboBox.addItems(bibles)
self.quickSecondComboBox.addItems(bibles) self.quickSecondComboBox.addItems(bibles)
@ -461,7 +461,7 @@ class BibleMediaItem(MediaManagerItem):
for book in book_data: for book in book_data:
data = BiblesResourcesDB.get_book_by_id(book.book_reference_id) data = BiblesResourcesDB.get_book_by_id(book.book_reference_id)
books.append(data[u'name'] + u' ') books.append(data[u'name'] + u' ')
books.sort(key=get_local_key) books.sort(key=get_locale_key)
set_case_insensitive_completer(books, self.quickSearchEdit) set_case_insensitive_completer(books, self.quickSearchEdit)
def on_import_click(self): def on_import_click(self):

View File

@ -35,7 +35,7 @@ from sqlalchemy import Column, Table, types
from sqlalchemy.orm import mapper from sqlalchemy.orm import mapper
from openlp.core.lib.db import BaseModel, init_db from openlp.core.lib.db import BaseModel, init_db
from openlp.core.utils import get_local_key from openlp.core.utils import get_locale_key
class CustomSlide(BaseModel): class CustomSlide(BaseModel):
""" """
@ -44,10 +44,10 @@ class CustomSlide(BaseModel):
# By default sort the customs by its title considering language specific # By default sort the customs by its title considering language specific
# characters. # characters.
def __lt__(self, other): def __lt__(self, other):
return get_local_key(self.title) < get_local_key(other.title) return get_locale_key(self.title) < get_locale_key(other.title)
def __eq__(self, other): def __eq__(self, other):
return get_local_key(self.title) == get_local_key(other.title) return get_locale_key(self.title) == get_locale_key(other.title)
def init_schema(url): def init_schema(url):

View File

@ -36,7 +36,7 @@ from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, Servic
StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \ StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
create_thumb, translate, validate_thumb create_thumb, translate, validate_thumb
from openlp.core.lib.ui import create_widget_action, critical_error_message_box from openlp.core.lib.ui import create_widget_action, critical_error_message_box
from openlp.core.utils import AppLocation, delete_file, get_local_key, get_images_filter from openlp.core.utils import AppLocation, delete_file, get_locale_key, get_images_filter
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
@ -255,7 +255,7 @@ class ImageMediaItem(MediaManagerItem):
The ID of the group that will be added recursively The ID of the group that will be added recursively
""" """
image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id) image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
image_groups.sort(key=lambda group_object: get_local_key(group_object.group_name)) image_groups.sort(key=lambda group_object: get_locale_key(group_object.group_name))
folder_icon = build_icon(u':/images/image_group.png') folder_icon = build_icon(u':/images/image_group.png')
for image_group in image_groups: for image_group in image_groups:
group = QtGui.QTreeWidgetItem() group = QtGui.QTreeWidgetItem()
@ -286,7 +286,7 @@ class ImageMediaItem(MediaManagerItem):
combobox.clear() combobox.clear()
combobox.top_level_group_added = False combobox.top_level_group_added = False
image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id) image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
image_groups.sort(key=lambda group_object: get_local_key(group_object.group_name)) image_groups.sort(key=lambda group_object: get_locale_key(group_object.group_name))
for image_group in image_groups: for image_group in image_groups:
combobox.addItem(prefix + image_group.group_name, image_group.id) combobox.addItem(prefix + image_group.group_name, image_group.id)
self.fill_groups_combobox(combobox, image_group.id, prefix + ' ') self.fill_groups_combobox(combobox, image_group.id, prefix + ' ')
@ -338,7 +338,7 @@ class ImageMediaItem(MediaManagerItem):
self.expand_group(open_group.id) self.expand_group(open_group.id)
# Sort the images by its filename considering language specific # Sort the images by its filename considering language specific
# characters. # characters.
images.sort(key=lambda image_object: get_local_key(os.path.split(unicode(image_object.filename))[1])) images.sort(key=lambda image_object: get_locale_key(os.path.split(unicode(image_object.filename))[1]))
for imageFile in images: for imageFile in images:
log.debug(u'Loading image: %s', imageFile.filename) log.debug(u'Loading image: %s', imageFile.filename)
filename = os.path.split(imageFile.filename)[1] filename = os.path.split(imageFile.filename)[1]
@ -525,9 +525,9 @@ class ImageMediaItem(MediaManagerItem):
group_items.append(item) group_items.append(item)
if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames): if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames):
image_items.append(item) image_items.append(item)
group_items.sort(key=lambda item: get_local_key(item.text(0))) group_items.sort(key=lambda item: get_locale_key(item.text(0)))
target_group.addChildren(group_items) target_group.addChildren(group_items)
image_items.sort(key=lambda item: get_local_key(item.text(0))) image_items.sort(key=lambda item: get_locale_key(item.text(0)))
target_group.addChildren(image_items) target_group.addChildren(image_items)
def generate_slide_data(self, service_item, item=None, xmlVersion=False, def generate_slide_data(self, service_item, item=None, xmlVersion=False,

View File

@ -37,7 +37,7 @@ from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Regist
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.ui import DisplayController, Display, DisplayControllerType from openlp.core.ui import DisplayController, Display, DisplayControllerType
from openlp.core.ui.media import get_media_players, set_media_players from openlp.core.ui.media import get_media_players, set_media_players
from openlp.core.utils import AppLocation, get_local_key from openlp.core.utils import AppLocation, get_locale_key
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -261,7 +261,7 @@ class MediaMediaItem(MediaManagerItem):
def load_list(self, media, target_group=None): def load_list(self, media, target_group=None):
# Sort the media by its filename considering language specific # Sort the media by its filename considering language specific
# characters. # characters.
media.sort(key=lambda filename: get_local_key(os.path.split(unicode(filename))[1])) media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
for track in media: for track in media:
track_info = QtCore.QFileInfo(track) track_info = QtCore.QFileInfo(track)
if not os.path.exists(track): if not os.path.exists(track):
@ -287,7 +287,7 @@ class MediaMediaItem(MediaManagerItem):
def getList(self, type=MediaType.Audio): def getList(self, type=MediaType.Audio):
media = Settings().value(self.settings_section + u'/media files') media = Settings().value(self.settings_section + u'/media files')
media.sort(key=lambda filename: get_local_key(os.path.split(unicode(filename))[1])) media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
ext = [] ext = []
if type == MediaType.Audio: if type == MediaType.Audio:
ext = self.media_controller.audio_extensions_list ext = self.media_controller.audio_extensions_list

View File

@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
build_icon, check_item_selected, create_thumb, translate, validate_thumb build_icon, check_item_selected, create_thumb, translate, validate_thumb
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.utils import get_local_key from openlp.core.utils import get_locale_key
from openlp.plugins.presentations.lib import MessageListener from openlp.plugins.presentations.lib import MessageListener
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -153,7 +153,7 @@ class PresentationMediaItem(MediaManagerItem):
if not initialLoad: if not initialLoad:
self.main_window.display_progress_bar(len(files)) self.main_window.display_progress_bar(len(files))
# Sort the presentations by its filename considering language specific characters. # Sort the presentations by its filename considering language specific characters.
files.sort(key=lambda filename: get_local_key(os.path.split(unicode(filename))[1])) files.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
for file in files: for file in files:
if not initialLoad: if not initialLoad:
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()