openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #17176
[Merge] lp:~trb143/openlp/bug-1051615 into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/bug-1051615 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #1051615 in OpenLP: "Service file name no longer formats correctly"
https://bugs.launchpad.net/openlp/+bug/1051615
For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-1051615/+merge/124577
Pass the time object to the formatting code instead of using the machine time.
The object may have been adjusted by the calling code!
--
https://code.launchpad.net/~trb143/openlp/bug-1051615/+merge/124577
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bug-1051615 into lp:openlp.
=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py 2012-09-14 23:55:55 +0000
+++ openlp/core/ui/advancedtab.py 2012-09-16 15:46:19 +0000
@@ -612,18 +612,18 @@
def generateServiceNameExample(self):
preset_is_valid = True
if self.serviceNameDay.currentIndex() == 7:
- time = datetime.now()
+ local_time = datetime.now()
else:
now = datetime.now()
day_delta = self.serviceNameDay.currentIndex() - now.weekday()
if day_delta < 0:
day_delta += 7
time = now + timedelta(days=day_delta)
- time = time.replace(hour = self.serviceNameTime.time().hour(),
+ local_time = time.replace(hour = self.serviceNameTime.time().hour(),
minute = self.serviceNameTime.time().minute())
try:
service_name_example = format_time(unicode(
- self.serviceNameEdit.text()))
+ self.serviceNameEdit.text()), local_time)
except ValueError:
preset_is_valid = False
service_name_example = translate('OpenLP.AdvancedTab',
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2012-09-14 23:55:55 +0000
+++ openlp/core/ui/servicemanager.py 2012-09-16 15:46:19 +0000
@@ -603,7 +603,7 @@
service_day = Settings().value(
u'advanced/default service day', 7).toInt()[0]
if service_day == 7:
- time = datetime.now()
+ local_time = datetime.now()
else:
service_hour = Settings().value(
u'advanced/default service hour', 11).toInt()[0]
@@ -614,7 +614,7 @@
if day_delta < 0:
day_delta += 7
time = now + timedelta(days=day_delta)
- time = time.replace(hour=service_hour, minute=service_minute)
+ local_time = time.replace(hour=service_hour, minute=service_minute)
default_pattern = unicode(Settings().value(
u'advanced/default service name',
translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M',
@@ -622,7 +622,7 @@
'/\\?*|<>\[\]":+\nSee http://docs.python.org/library/'
'datetime.html#strftime-strptime-behavior for more '
'information.')).toString())
- default_filename = format_time(default_pattern)
+ default_filename = format_time(default_pattern, local_time)
else:
default_filename = u''
directory = unicode(SettingsManager.get_last_dir(
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2012-09-14 23:55:55 +0000
+++ openlp/core/utils/__init__.py 2012-09-16 15:46:19 +0000
@@ -35,7 +35,6 @@
import re
from subprocess import Popen, PIPE
import sys
-import time
import urllib2
from openlp.core.lib.settings import Settings
@@ -471,16 +470,21 @@
+ u'urp;StarOffice.ComponentContext')
-def format_time(text):
+def format_time(text, local_time):
"""
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().
+
+ ``text``
+ The text to be processed.
+ ``local_time``
+ The time to be used to add to the string. This is a time object
"""
def match_formatting(match):
- return time.strftime(match.group())
+ return local_time.strftime(match.group())
return re.sub('\%[a-zA-Z]', match_formatting, text)
Follow ups