[CLN] core: upgrade to python 3.6

& sort imports

closes odoo/documentation#2976

X-original-commit: 57784a2f90
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens 2022-11-14 16:03:12 +00:00
parent 73730b3cf5
commit 5e3d4d0414
11 changed files with 29 additions and 36 deletions

View File

@ -1,14 +1,14 @@
import re
import os import os
import re
import shutil import shutil
import sys import sys
from pathlib import Path from pathlib import Path
import docutils import docutils
import sphinx
from pygments.lexers import JsonLexer, XmlLexer from pygments.lexers import JsonLexer, XmlLexer
from sphinx.ext import graphviz from sphinx.ext import graphviz
from sphinx.util import logging from sphinx.util import logging
import sphinx
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -279,7 +279,7 @@ latex_documents = [
('legal/terms/i18n/partnership_tex_fr', ('legal/terms/i18n/partnership_tex_fr',
'odoo_partnership_agreement_fr.tex', 'Odoo Partnership Agreement (FR)', '', 'howto'), 'odoo_partnership_agreement_fr.tex', 'Odoo Partnership Agreement (FR)', '', 'howto'),
('legal/terms/i18n/terms_of_sale_fr', 'terms_of_sale_fr.tex', ('legal/terms/i18n/terms_of_sale_fr', 'terms_of_sale_fr.tex',
u'Conditions Générales de Vente Odoo', '', 'howto'), 'Conditions Générales de Vente Odoo', '', 'howto'),
('legal/terms/i18n/enterprise_tex_nl', 'odoo_enterprise_agreement_nl.tex', ('legal/terms/i18n/enterprise_tex_nl', 'odoo_enterprise_agreement_nl.tex',
'Odoo Enterprise Subscription Agreement (NL)', '', 'howto'), 'Odoo Enterprise Subscription Agreement (NL)', '', 'howto'),

View File

@ -1,7 +1,8 @@
import base64 import base64
import time
import sys
import json import json
import sys
import time
import requests import requests
account_token = "integration_token" # Use your token account_token = "integration_token" # Use your token

View File

@ -3,12 +3,11 @@ from typing import Sequence
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
from docutils.parsers.rst.states import RSTState from docutils.parsers.rst.states import RSTState
from sphinx.domains.python import PyClasslike, PyAttribute from sphinx.domains.python import PyAttribute, PyClasslike
from sphinx.ext.autodoc import AttributeDocumenter, ClassDocumenter from sphinx.ext.autodoc import AttributeDocumenter, ClassDocumenter
import odoo import odoo
nested_parse = RSTState.nested_parse nested_parse = RSTState.nested_parse
def patched_nested_parse(self, block, input_offset, node, match_titles=False, def patched_nested_parse(self, block, input_offset, node, match_titles=False,
state_machine_class=None, state_machine_kwargs=None): state_machine_class=None, state_machine_kwargs=None):

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
""" """
ReST directive for embedding Youtube and Vimeo videos. ReST directive for embedding Youtube and Vimeo videos.
There are two directives added: ``youtube`` and ``vimeo``. The only There are two directives added: ``youtube`` and ``vimeo``. The only
@ -13,7 +12,6 @@
:copyright: (c) 2012 by Danilo Bargen. :copyright: (c) 2012 by Danilo Bargen.
:license: BSD 3-clause :license: BSD 3-clause
""" """
from __future__ import absolute_import
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import Directive, directives from docutils.parsers.rst import Directive, directives

View File

@ -19,9 +19,10 @@ Notes
* explicitly imports ``odoo``, so useless for anyone else * explicitly imports ``odoo``, so useless for anyone else
""" """
import inspect
import importlib import importlib
import inspect
import os.path import os.path
import werkzeug import werkzeug
@ -60,7 +61,7 @@ def setup(app):
try: try:
obj_source_path = inspect.getsourcefile(obj) obj_source_path = inspect.getsourcefile(obj)
_, line = inspect.getsourcelines(obj) _, line = inspect.getsourcelines(obj)
except (TypeError, IOError): except (TypeError, OSError):
# obj doesn't have a module, or something # obj doesn't have a module, or something
return None return None
@ -115,4 +116,4 @@ def add_doc_link(app, pagename, templatename, context, doctree):
source_suffix = app.config.source_suffix source_suffix = app.config.source_suffix
source_suffix = next(iter(source_suffix)) source_suffix = next(iter(source_suffix))
context['github_link'] = lambda mode='edit': make_github_link( context['github_link'] = lambda mode='edit': make_github_link(
app, 'content/%s%s' % (pagename, source_suffix), mode=mode) app, f'content/{pagename}{source_suffix}', mode=mode)

View File

@ -1,5 +1,5 @@
from docutils.parsers.rst import Directive, directives
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import Directive, directives
class PlaceHolder(Directive): class PlaceHolder(Directive):

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
""" """
Defines a "raw HTML" domain with a ``div[classes]`` and a number of roles Defines a "raw HTML" domain with a ``div[classes]`` and a number of roles
rendered more or less directly to HTML. rendered more or less directly to HTML.
@ -13,12 +11,11 @@ for directives likes .. h:div::
TO REMOVE AS SOON AS WE DROP MEMENTOES TO REMOVE AS SOON AS WE DROP MEMENTOES
""" """
import sphinx
import sphinx.roles
from docutils import nodes, utils from docutils import nodes, utils
from docutils.parsers.rst import Directive, directives from docutils.parsers.rst import Directive, directives
from docutils.parsers.rst.directives.body import LineBlock from docutils.parsers.rst.directives.body import LineBlock
import sphinx
import sphinx.roles
from sphinx.domains import Domain from sphinx.domains import Domain
@ -78,7 +75,7 @@ class address(nodes.General, nodes.Element):
class Address(LineBlock): class Address(LineBlock):
def run(self): def run(self):
[node] = super(Address, self).run() [node] = super().run()
ad = address(node.rawsource, *node.children) ad = address(node.rawsource, *node.children)
return [ad] return [ad]

View File

@ -25,7 +25,7 @@ def set_missing_meta(app, pagename, templatename, context, doctree):
if context.get('meta') is None: # Pages without title (used with `include::`) have no meta if context.get('meta') is None: # Pages without title (used with `include::`) have no meta
context['meta'] = {} context['meta'] = {}
class Monkey(object): class Monkey:
""" Replace patched method of an object by a new method receiving the old one in argument. """ """ Replace patched method of an object by a new method receiving the old one in argument. """
def __init__(self, obj): def __init__(self, obj):
self.obj = obj self.obj = obj

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from pygments.style import Style from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \ from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Other, Whitespace, Generic Number, Other, Whitespace, Generic
@ -40,8 +39,9 @@ class OdooStyle(Style):
Error: 'bg:#ffe2e2 #a61717' Error: 'bg:#ffe2e2 #a61717'
} }
import types
import sys import sys
import types
modname = 'pygments.styles.odoo' modname = 'pygments.styles.odoo'
m = types.ModuleType(modname) m = types.ModuleType(modname)
m.OdooStyle = OdooStyle m.OdooStyle = OdooStyle

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from docutils import nodes from docutils import nodes
from sphinx.locale import admonitionlabels from sphinx.locale import admonitionlabels
from sphinx.writers.html5 import HTML5Translator from sphinx.writers.html5 import HTML5Translator
@ -77,16 +75,16 @@ class BootstrapTranslator(HTML5Translator):
def encode(self, text): def encode(self, text):
return str(text).translate({ return str(text).translate({
ord('&'): u'&amp;', ord('&'): '&amp;',
ord('<'): u'&lt;', ord('<'): '&lt;',
ord('"'): u'&quot;', ord('"'): '&quot;',
ord('>'): u'&gt;', ord('>'): '&gt;',
0xa0: u'&nbsp;' 0xa0: '&nbsp;'
}) })
def unknown_visit(self, node): def unknown_visit(self, node):
print("unknown node", node.__class__.__name__) print("unknown node", node.__class__.__name__)
self.body.append(u'[UNKNOWN NODE {}]'.format(node.__class__.__name__)) self.body.append(f'[UNKNOWN NODE {node.__class__.__name__}]')
raise nodes.SkipNode raise nodes.SkipNode
# NOTE: seems that when we remove/comment this, we get the titles 5 times in the global toc # NOTE: seems that when we remove/comment this, we get the titles 5 times in the global toc
@ -100,7 +98,7 @@ class BootstrapTranslator(HTML5Translator):
# close "parent" or preceding section, unless this is the opening of # close "parent" or preceding section, unless this is the opening of
# the first section # the first section
if self.section_level: if self.section_level:
self.body.append(u'</section>') self.body.append('</section>')
self.section_level += 1 self.section_level += 1
self.body.append(self.starttag(node, 'section')) self.body.append(self.starttag(node, 'section'))
@ -108,7 +106,7 @@ class BootstrapTranslator(HTML5Translator):
self.section_level -= 1 self.section_level -= 1
# close last section of document # close last section of document
if not self.section_level: if not self.section_level:
self.body.append(u'</section>') self.body.append('</section>')
# overwritten # overwritten
# Class mapping: # Class mapping:
@ -135,7 +133,7 @@ class BootstrapTranslator(HTML5Translator):
def depart_title(self, node): def depart_title(self, node):
if isinstance(node.parent, nodes.Admonition): if isinstance(node.parent, nodes.Admonition):
self.body.append(u"</p>") self.body.append("</p>")
else: else:
super().depart_title(node) super().depart_title(node)
@ -148,7 +146,7 @@ class BootstrapTranslator(HTML5Translator):
# c/p of https://github.com/pydata/pydata-sphinx-theme/pull/509/files # c/p of https://github.com/pydata/pydata-sphinx-theme/pull/509/files
self._table_row_indices.append(0) self._table_row_indices.append(0)
classes = [cls.strip(u' \t\n') classes = [cls.strip(' \t\n')
for cls in self.settings.table_style.split(',')] for cls in self.settings.table_style.split(',')]
classes.insert(0, "docutils") # compat classes.insert(0, "docutils") # compat
classes.insert(0, "table") # compat classes.insert(0, "table") # compat

View File

@ -1,6 +1,5 @@
# Adapted from https://github.com/sphinx-contrib/redirects # Adapted from https://github.com/sphinx-contrib/redirects
import os
import re import re
from pathlib import Path from pathlib import Path
@ -23,7 +22,7 @@ def generate_redirects(app):
return return
source_suffix = next(iter(app.config.source_suffix)) source_suffix = next(iter(app.config.source_suffix))
escaped_source_suffix = source_suffix.replace('.', '\.') escaped_source_suffix = source_suffix.replace('.', r'\.')
pattern = re.compile( pattern = re.compile(
r'^[ \t]*([\w\-/]+{0})[ \t]+([\w\-/]+{0})[ \t]*(?:#.*)?$'.format(escaped_source_suffix) r'^[ \t]*([\w\-/]+{0})[ \t]+([\w\-/]+{0})[ \t]*(?:#.*)?$'.format(escaped_source_suffix)
) )