Dont test if precis_i18n is available

Its listed as dependency
This commit is contained in:
Philipp Hörist 2018-11-10 19:16:17 +01:00
parent a7cc815ca4
commit 02a9615b94
1 changed files with 5 additions and 21 deletions

View File

@ -47,6 +47,8 @@ from encodings.punycode import punycode_encode
from string import Template
import nbxmpp
from nbxmpp.stringprepare import nameprep
import precis_i18n.codec # pylint: disable=unused-import
from gajim.common import caps_cache
from gajim.common import configpaths
@ -55,12 +57,6 @@ from gajim.common.i18n import _
from gajim.common.i18n import ngettext
from gajim.common.caps_cache import muc_caps_cache
try:
import precis_i18n.codec # pylint: disable=unused-import
HAS_PRECIS_I18N = True
except ImportError:
HAS_PRECIS_I18N = False
log = logging.getLogger('gajim.c.helpers')
special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats'))
@ -158,10 +154,7 @@ def parse_resource(resource):
"""
if resource:
try:
if HAS_PRECIS_I18N:
return resource.encode('Nickname').decode('utf-8')
from nbxmpp.stringprepare import resourceprep
return resourceprep.prepare(resource)
except UnicodeError:
raise InvalidFormat('Invalid character in resource.')
@ -195,7 +188,6 @@ def prep(user, server, resource):
if not server or len(server.encode('utf-8')) > 1023:
raise InvalidFormat(_('Server must be between 1 and 1023 bytes'))
try:
from nbxmpp.stringprepare import nameprep
server = nameprep.prepare(server)
except UnicodeError:
raise InvalidFormat(_('Invalid character in hostname.'))
@ -206,11 +198,7 @@ def prep(user, server, resource):
if not user or len(user.encode('utf-8')) > 1023:
raise InvalidFormat(_('Username must be between 1 and 1023 bytes'))
try:
if HAS_PRECIS_I18N:
user = user.encode('UsernameCaseMapped').decode('utf-8')
else:
from nbxmpp.stringprepare import nodeprep
user = nodeprep.prepare(user)
except UnicodeError:
raise InvalidFormat(_('Invalid character in username.'))
else:
@ -220,11 +208,7 @@ def prep(user, server, resource):
if not resource or len(resource.encode('utf-8')) > 1023:
raise InvalidFormat(_('Resource must be between 1 and 1023 bytes'))
try:
if HAS_PRECIS_I18N:
resource = resource.encode('OpaqueString').decode('utf-8')
else:
from nbxmpp.stringprepare import resourceprep
resource = resourceprep.prepare(resource)
except UnicodeError:
raise InvalidFormat(_('Invalid character in resource.'))
else: