summaryrefslogtreecommitdiff
path: root/doc/_extensions/odoo_ext/translator.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-05-02 12:07:30 +0200
committerOlivier Dony <odo@openerp.com>2017-08-20 23:25:54 +0200
commit7dd062f83552fa8ff96224c29d60bafc001d73d3 (patch)
treed507e27e9d5daa91981e04b5aa81a802a9854a8d /doc/_extensions/odoo_ext/translator.py
parent3824b5dcc13678d3985ad45ac21dcf9ac9202c20 (diff)
[FIX] P3: text model types
* remove references to basestring & unicode (use relevant pycompat helpers) * remove some str calls (either entirely or replaced by relevant helper, either text or native) * use better API to avoid unnecessary conversions * remove some XML declarations in views
Diffstat (limited to 'doc/_extensions/odoo_ext/translator.py')
-rw-r--r--doc/_extensions/odoo_ext/translator.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/_extensions/odoo_ext/translator.py b/doc/_extensions/odoo_ext/translator.py
index 3a1928364eb..443458f33c7 100644
--- a/doc/_extensions/odoo_ext/translator.py
+++ b/doc/_extensions/odoo_ext/translator.py
@@ -11,6 +11,8 @@ from docutils import nodes
from sphinx import addnodes, util
from sphinx.locale import admonitionlabels
+from odoo.tools import pycompat
+
def _parents(node):
while node.parent:
@@ -62,7 +64,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
self.param_separator = ','
def encode(self, text):
- return unicode(text).translate({
+ return pycompat.text_type(text).translate({
ord('&'): u'&amp;',
ord('<'): u'&lt;',
ord('"'): u'&quot;',
@@ -71,7 +73,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
})
def starttag(self, node, tagname, **attributes):
- tagname = unicode(tagname).lower()
+ tagname = pycompat.text_type(tagname).lower()
# extract generic attributes
attrs = {name.lower(): value for name, value in attributes.items()}
@@ -105,8 +107,8 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
)
# only "space characters" SPACE, CHARACTER TABULATION, LINE FEED,
# FORM FEED and CARRIAGE RETURN should be collapsed, not al White_Space
- def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]')):
- return self.encode(whitespace.sub(u' ', unicode(value)))
+ def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]+')):
+ return self.encode(whitespace.sub(u' ', pycompat.text_type(value)))
def astext(self):
return u''.join(self.body)