diff options
| author | Xavier Morel <xmo@odoo.com> | 2017-05-02 12:07:30 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2017-08-20 23:25:54 +0200 |
| commit | 7dd062f83552fa8ff96224c29d60bafc001d73d3 (patch) | |
| tree | d507e27e9d5daa91981e04b5aa81a802a9854a8d /doc/_extensions | |
| parent | 3824b5dcc13678d3985ad45ac21dcf9ac9202c20 (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')
| -rw-r--r-- | doc/_extensions/github_link.py | 4 | ||||
| -rw-r--r-- | doc/_extensions/odoo_ext/translator.py | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/doc/_extensions/github_link.py b/doc/_extensions/github_link.py index d3e5d61c28e..155e4083025 100644 --- a/doc/_extensions/github_link.py +++ b/doc/_extensions/github_link.py @@ -4,6 +4,8 @@ import os.path from werkzeug import urls +from odoo.tools import pycompat + """ * adds github_link(mode) context variable: provides URL (in relevant mode) of current document on github @@ -99,7 +101,7 @@ def add_doc_link(app, pagename, templatename, context, doctree): # in Sphinx 1.3 it's possible to have mutliple source suffixes and that # may be useful in the future source_suffix = app.config.source_suffix - source_suffix = source_suffix if isinstance(source_suffix, basestring) else source_suffix[0] + source_suffix = source_suffix if isinstance(source_suffix, pycompat.string_types) else source_suffix[0] # can't use functools.partial because 3rd positional is line not mode context['github_link'] = lambda mode='edit': make_github_link( app, 'doc/%s%s' % (pagename, source_suffix), mode=mode) 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'&', ord('<'): u'<', ord('"'): u'"', @@ -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) |
