Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
43e0a537 by André Apitzsch at 2018-11-26T22:46:24Z
Replace ustr() by str()
- - - - -
2c7a3e2c by Philipp Hörist at 2018-11-27T19:11:33Z
Merge branch 'ustr' into 'master'
Replace ustr() by str()
See merge request gajim/python-nbxmpp!22
- - - - -
3 changed files:
- nbxmpp/c14n.py
- nbxmpp/simplexml.py
- nbxmpp/transports_nb.py
Changes:
=====================================
nbxmpp/c14n.py
=====================================
@@ -22,8 +22,6 @@
XML canonicalisation methods (for XEP-0116)
"""
-from .simplexml import ustr
-
def c14n(node, is_buggy):
s = "<" + node.name
if node.namespace:
@@ -34,7 +32,7 @@ def c14n(node, is_buggy):
for key in sorted_attrs:
if not is_buggy and key == 'xmlns':
continue
- val = ustr(node.attrs[key])
+ val = str(node.attrs[key])
# like XMLescape() but with whitespace and without >
s += ' %s="%s"' % (key, normalise_attr(val))
s += ">"
=====================================
nbxmpp/simplexml.py
=====================================
@@ -32,23 +32,6 @@ def XMLescape(txt):
# replace also FORM FEED and ESC, because they are not valid XML chars
return txt.replace("&", "&").replace("<", "<").replace(">",
">").replace('"', """).replace('\x0C', "").replace('\x1B', "")
-ENCODING='utf-8'
-
-def ustr(what):
- """
- Converts object "what" to unicode string using it's own __str__ method if
- accessible or unicode method otherwise
- """
- if isinstance(what, str):
- return what
- try:
- r = what.__str__()
- except AttributeError:
- r = str(what)
- if not isinstance(r, str):
- return str(r, ENCODING)
- return r
-
class Node(object):
"""
Node class describes syntax of separate XML Node. It have a constructor
that
@@ -134,7 +117,7 @@ class Node(object):
if isinstance(i, Node):
self.addChild(node=i)
else:
- self.data.append(ustr(i))
+ self.data.append(str(i))
def lookup_nsp(self, pfx=''):
ns = self.nsd.get(pfx, None)
@@ -159,7 +142,7 @@ class Node(object):
if 'xmlns' not in self.attrs:
s += ' xmlns="%s"' % self.namespace
for key in self.attrs.keys():
- val = ustr(self.attrs[key])
+ val = str(self.attrs[key])
s += ' %s="%s"' % (key, XMLescape(val))
s += ">"
@@ -218,7 +201,7 @@ class Node(object):
"""
Add some CDATA to node
"""
- self.data.append(ustr(data))
+ self.data.append(str(data))
def clearData(self):
"""
@@ -379,7 +362,7 @@ class Node(object):
"""
Set node's CDATA to provided string. Resets all previous CDATA!
"""
- self.data = [ustr(data)]
+ self.data = [str(data)]
def setName(self, val):
"""
@@ -441,9 +424,9 @@ class Node(object):
(optionally) attributes "attrs" and sets it's CDATA to string "val"
"""
try:
- self.getTag(tag, attrs).setData(ustr(val))
+ self.getTag(tag, attrs).setData(str(val))
except Exception:
- self.addChild(tag, attrs, payload = [ustr(val)])
+ self.addChild(tag, attrs, payload = [str(val)])
def has_attr(self, key):
"""
=====================================
nbxmpp/transports_nb.py
=====================================
@@ -38,7 +38,6 @@ try:
except ImportError:
from urlparse import urlparse
-from .simplexml import ustr
from .plugin import PlugIn
from .idlequeue import IdleObject
from . import proxy_connectors
@@ -544,7 +543,7 @@ class NonBlockingTCP(NonBlockingTransport, IdleObject):
if isinstance(stanza, str):
stanza = stanza.encode('utf-8')
elif not isinstance(stanza, str):
- stanza = ustr(stanza).encode('utf-8')
+ stanza = str(stanza).encode('utf-8')
return stanza
def _plug_idle(self, writable, readable):
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/397382139300c7b992934c6c3eaa2faf170bc634...2c7a3e2c565b8baab15ec22de4ae92f09cf1b465
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/397382139300c7b992934c6c3eaa2faf170bc634...2c7a3e2c565b8baab15ec22de4ae92f09cf1b465
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits