forked from openlp/openlp
Fix placeholder for service name for non AscII characters
bzr-revno: 2062
This commit is contained in:
commit
20bfde8e5a
@ -38,7 +38,7 @@ import sys
|
||||
from openlp.core.lib import SettingsTab, translate, build_icon, Receiver
|
||||
from openlp.core.lib.settings import Settings
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.core.utils import get_images_filter, AppLocation
|
||||
from openlp.core.utils import get_images_filter, AppLocation, format_time
|
||||
from openlp.core.lib import SlideLimits
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -622,7 +622,7 @@ class AdvancedTab(SettingsTab):
|
||||
time = time.replace(hour = self.serviceNameTime.time().hour(),
|
||||
minute = self.serviceNameTime.time().minute())
|
||||
try:
|
||||
service_name_example = time.strftime(unicode(
|
||||
service_name_example = format_time(unicode(
|
||||
self.serviceNameEdit.text()))
|
||||
except ValueError:
|
||||
preset_is_valid = False
|
||||
|
@ -47,7 +47,8 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||
create_widget_action, find_and_set_in_combo_box
|
||||
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
|
||||
from openlp.core.ui.printserviceform import PrintServiceForm
|
||||
from openlp.core.utils import AppLocation, delete_file, split_filename
|
||||
from openlp.core.utils import AppLocation, delete_file, split_filename, \
|
||||
format_time
|
||||
from openlp.core.utils.actions import ActionList, CategoryOrder
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
@ -621,7 +622,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
'/\\?*|<>\[\]":+\nSee http://docs.python.org/library/'
|
||||
'datetime.html#strftime-strptime-behavior for more '
|
||||
'information.')).toString())
|
||||
default_filename = time.strftime(default_pattern)
|
||||
default_filename = format_time(default_pattern)
|
||||
else:
|
||||
default_filename = u''
|
||||
directory = unicode(SettingsManager.get_last_dir(
|
||||
|
@ -35,6 +35,7 @@ import os
|
||||
import re
|
||||
from subprocess import Popen, PIPE
|
||||
import sys
|
||||
import time
|
||||
import urllib2
|
||||
|
||||
from openlp.core.lib.settings import Settings
|
||||
@ -469,10 +470,24 @@ def get_uno_instance(resolver):
|
||||
return resolver.resolve(u'uno:socket,host=localhost,port=2002;' \
|
||||
+ u'urp;StarOffice.ComponentContext')
|
||||
|
||||
|
||||
def format_time(text):
|
||||
"""
|
||||
Workaround for Python built-in time formatting fuction time.strftime().
|
||||
|
||||
time.strftime() accepts only ascii characters. This function accepts
|
||||
unicode string and passes individual % placeholders to time.strftime().
|
||||
This ensures only ascii characters are passed to time.strftime().
|
||||
"""
|
||||
def match_formatting(match):
|
||||
return time.strftime(match.group())
|
||||
return re.sub('\%[a-zA-Z]', match_formatting, text)
|
||||
|
||||
|
||||
from languagemanager import LanguageManager
|
||||
from actions import ActionList
|
||||
|
||||
__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
|
||||
u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
|
||||
u'ActionList', u'get_web_page', u'get_uno_command', u'get_uno_instance',
|
||||
u'delete_file', u'clean_filename']
|
||||
u'delete_file', u'clean_filename', u'format_time']
|
||||
|
Loading…
Reference in New Issue
Block a user