# Path: Wammu/Locales.py
# def UnicodeConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython. There
#     is problem that in default configuration in most distros (maybe all) default
#     encoding for unicode objects is ascii. This leads to exception when converting
#     something different than ascii. And this exception is not catched inside
#     wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return unicode(str(txt), LOCALE_CHARSET)
#     except UnicodeEncodeError:
#         return unicode('???')
# 
# def HtmlStrConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython
#     html widget. There is problem that in default configuration in most distros
#     (maybe all) default encoding for unicode objects is ascii. This leads to
#     exception when converting something different than ascii. And this
#     exception is not catched inside wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return str(txt)
#     except UnicodeEncodeError:
#         return '???'
# 
# def ugettext(message):
#     if _TRANSLATION:
#         if six.PY2:
#             return _TRANSLATION.ugettext(message)
#         return _TRANSLATION.gettext(message)
#     return message


import Wammu
import Wammu.Data
import Wammu.Ringtone
import string
import re
import xml.sax.saxutils
from Wammu.Locales import UnicodeConv, HtmlStrConv, ugettext as _
                    parts[-1] += s
                elif curtype == 'u':
                    parts.append(s.lower())
                else:
                    parts.append(s)
                s = x
            else:
                parts.append(a)
        ret = ' '.join(parts)
    else:
        ret = txt
    if dohtml or doxml:
        xmlsafe = xml.sax.saxutils.escape(ret)
        if doxml:
            return xmlsafe.replace('\n', '<br />')
        else:
            return xmlsafe.replace('\n', '<br>')
    else:
        return ret.replace('\n', ' ')

def SmsToHtml(cfg, v):
    if 'SMSInfo' in v:
        text = ''
        ringno = 0
        Wammu.Ringtone.ringtones = {}
        for i in v['SMSInfo']['Entries']:
            if i['ID'] in Wammu.Data.SMSIDs['PredefinedAnimation']:
                if i['Number'] > len(Wammu.Data.PredefinedAnimations):
                    text = text + \
                        '<wxp module="Wammu.Image" class="Bitmap">' + \

# Path: Wammu/Locales.py
# def UnicodeConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython. There
#     is problem that in default configuration in most distros (maybe all) default
#     encoding for unicode objects is ascii. This leads to exception when converting
#     something different than ascii. And this exception is not catched inside
#     wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return unicode(str(txt), LOCALE_CHARSET)
#     except UnicodeEncodeError:
#         return unicode('???')
# 
# def HtmlStrConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython
#     html widget. There is problem that in default configuration in most distros
#     (maybe all) default encoding for unicode objects is ascii. This leads to
#     exception when converting something different than ascii. And this
#     exception is not catched inside wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return str(txt)
#     except UnicodeEncodeError:
#         return '???'
# 
# def ugettext(message):
#     if _TRANSLATION:
#         if six.PY2:
#             return _TRANSLATION.ugettext(message)
#         return _TRANSLATION.gettext(message)
#     return message


# Path: Wammu/MessageDisplay.py
import Wammu
import Wammu.Data
import Wammu.Ringtone
import string
import re
import xml.sax.saxutils
from Wammu.Locales import UnicodeConv, HtmlStrConv, ugettext as _

                    parts[-1] += s
                elif curtype == 'u':
                    parts.append(s.lower())
                else:
                    parts.append(s)
                s = x
            else:
                parts.append(a)
        ret = ' '.join(parts)
    else:
        ret = txt
    if dohtml or doxml:
        xmlsafe = xml.sax.saxutils.escape(ret)
        if doxml:
            return xmlsafe.replace('\n', '<br />')
        else:
            return xmlsafe.replace('\n', '<br>')
    else:
        return ret.replace('\n', ' ')

def SmsToHtml(cfg, v):
    if 'SMSInfo' in v:
        text = ''
        ringno = 0
        Wammu.Ringtone.ringtones = {}
        for i in v['SMSInfo']['Entries']:
            if i['ID'] in Wammu.Data.SMSIDs['PredefinedAnimation']:
                if i['Number'] > len(Wammu.Data.PredefinedAnimations):
                    text = text + \
                        '<wxp module="Wammu.Image" class="Bitmap">' + \

                        '<param name="tooltip" value="' + (_('Predefined animation number %d') % i['Number']) + '">' + \