Skip to content

Commit 28aa9ff

Browse files
committed
Fix multi-line message formatting in Kodi 19
No more line2=, line3= arguments for Dialog methods in Kodi 19
1 parent c545c09 commit 28aa9ff

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

lib/aussieaddonscommon/utils.py

+29-19
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from future.moves.html.entities import entitydefs
1414
from future.moves.urllib.parse import quote_plus, unquote_plus
15-
from future.utils import iteritems, string_types, text_type
15+
from future.utils import iteritems, text_type
1616

1717
import xbmc
1818

@@ -120,6 +120,16 @@ def log(s):
120120
ensure_ascii(s)), level=xbmc.LOGINFO)
121121

122122

123+
def append_message(msg_list, msg):
124+
"""
125+
Add message with newline to existing formatted msg
126+
:param msg_list: list - contains title and content
127+
:param msg: message to append to content
128+
"""
129+
assert len(msg_list) == 2
130+
msg_list[1] = '{0}\n{1}'.format(msg_list[1], msg)
131+
132+
123133
def format_error_summary():
124134
"""Format error summary
125135
@@ -160,11 +170,8 @@ def format_dialog_message(msg, title=None):
160170
else:
161171
content = ["%s v%s" % (get_addon_name(), get_addon_version())]
162172

163-
# Force unicode to str
164-
if isinstance(msg, string_types):
165-
msg = str(msg).split('\n')
166-
167-
return content + msg
173+
content.append(ensure_ascii(msg))
174+
return content
168175

169176

170177
def format_dialog_error(msg=None):
@@ -260,20 +267,22 @@ def is_valid_country(connection_info, message=None):
260267
if country_code:
261268
from aussieaddonscommon import countries
262269
country_name = countries.countries.get(country_code, country_code)
263-
message.append('Your country is reported as %s, but this service '
264-
'is probably geo-blocked to Australia.' %
265-
country_name)
270+
append_message(message,
271+
'Your country is reported as {0}, but this '
272+
'service is probably geo-blocked to '
273+
'Australia.'.format(country_name))
266274
xbmcgui.Dialog().ok(*message)
267275
return False
268276

269277
if blacklisted_hostname:
270-
message.append('VPN/proxy detected that has been blocked by this '
278+
append_message(message,
279+
'VPN/proxy detected that has been blocked by this '
271280
'content provider.')
272281
xbmcgui.Dialog().ok(*message)
273282
return False
274283

275284
if not is_valid_version():
276-
message.append('Invalid version number for issue report. ')
285+
append_message(message, 'Invalid version number for issue report. ')
277286
xbmcgui.Dialog().ok(*message)
278287
return False
279288

@@ -335,10 +344,9 @@ def send_report(title, trace=None, connection_info=None):
335344
report_url = issue_reporter.report_issue(title, trace, connection_info)
336345

337346
split_url = report_url.replace('/issue-reports', ' /issue-reports')
338-
dialog_message(['Thanks! Your issue has been reported to: ',
339-
split_url,
340-
'Please visit and describe the issue in order for '
341-
'us to assist.'])
347+
dialog_message('Thanks! Your issue has been reported to: {0}\n'
348+
'Please visit and describe the issue in order '
349+
'for us to assist.'.format(split_url))
342350
return report_url
343351
except Exception:
344352
traceback.print_exc()
@@ -394,14 +402,16 @@ def handle_error(message):
394402
version = get_addon_version()
395403

396404
if issue_reporter.is_not_latest_version(version, latest):
397-
message.append('Your version of this add-on (v%s) is outdated. Please '
398-
'upgrade to the latest version: '
399-
'v%s' % (version, latest))
405+
append_message(message,
406+
'Your version of this add-on (v{0}) is outdated. '
407+
'Please upgrade to the latest version: '
408+
'v{1}'.format(version, latest))
400409
xbmcgui.Dialog().ok(*message)
401410
return
402411

403412
if is_reportable:
404-
message.append('Would you like to automatically '
413+
append_message(message,
414+
'Would you like to automatically '
405415
'report this error?')
406416
if xbmcgui.Dialog().yesno(*message):
407417
issue_url = send_report(error, trace=trace,

0 commit comments

Comments
 (0)