diff --git a/html_text/__manifest__.py b/html_text/__manifest__.py
index 38af0cb63..88f39b3d7 100644
--- a/html_text/__manifest__.py
+++ b/html_text/__manifest__.py
@@ -8,18 +8,12 @@
"category": "Tools",
"website": "https://github.com/OCA/server-tools",
"author": "Grupo ESOC Ingeniería de Servicios, "
- "Tecnativa, "
- "Onestein, "
- "Odoo Community Association (OCA)",
+ "Tecnativa, "
+ "Onestein, "
+ "Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
- "external_dependencies": {
- "python": [
- "lxml",
- ],
- },
- "depends": [
- "base",
- ],
+ "external_dependencies": {"python": ["lxml",],},
+ "depends": ["base",],
}
diff --git a/html_text/models/ir_fields_converter.py b/html_text/models/ir_fields_converter.py
index f1c523280..7a07a359d 100644
--- a/html_text/models/ir_fields_converter.py
+++ b/html_text/models/ir_fields_converter.py
@@ -3,7 +3,9 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
+
from lxml import etree, html
+
from odoo import api, models
_logger = logging.getLogger(__name__)
@@ -13,8 +15,9 @@ class IrFieldsConverter(models.AbstractModel):
_inherit = "ir.fields.converter"
@api.model
- def text_from_html(self, html_content, max_words=None, max_chars=None,
- ellipsis=u"…", fail=False):
+ def text_from_html(
+ self, html_content, max_words=None, max_chars=None, ellipsis=u"…", fail=False
+ ):
"""Extract text from an HTML field in a generator.
:param str html_content:
@@ -45,8 +48,7 @@ class IrFieldsConverter(models.AbstractModel):
if fail:
raise
else:
- _logger.exception("Failure parsing this HTML:\n%s",
- html_content)
+ _logger.exception("Failure parsing this HTML:\n%s", html_content)
return ""
# Get words
@@ -63,7 +65,7 @@ class IrFieldsConverter(models.AbstractModel):
# Truncate text
suffix = suffix or max_chars and len(text) > max_chars
if max_chars:
- text = text[:max_chars - (len(ellipsis) if suffix else 0)].strip()
+ text = text[: max_chars - (len(ellipsis) if suffix else 0)].strip()
# Append ellipsis if needed
if suffix:
diff --git a/html_text/tests/test_extractor.py b/html_text/tests/test_extractor.py
index 8922f4e25..d81b88765 100644
--- a/html_text/tests/test_extractor.py
+++ b/html_text/tests/test_extractor.py
@@ -1,8 +1,8 @@
# Copyright 2016-2017 Jairo Llopis
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-from odoo.tools import mute_logger
from odoo.tests.common import TransactionCase
+from odoo.tools import mute_logger
class ExtractorCase(TransactionCase):
@@ -27,16 +27,18 @@ class ExtractorCase(TransactionCase):
self.assertEqual(
self.text_from_html(html),
- u"I'm a title I'm a paragraph ¡Pues yo soy español!")
+ u"I'm a title I'm a paragraph ¡Pues yo soy español!",
+ )
self.assertEqual(
- self.text_from_html(html, 8),
- u"I'm a title I'm a paragraph ¡Pues yo…")
+ self.text_from_html(html, 8), u"I'm a title I'm a paragraph ¡Pues yo…"
+ )
self.assertEqual(
- self.text_from_html(html, 8, 31),
- u"I'm a title I'm a paragraph ¡P…")
+ self.text_from_html(html, 8, 31), u"I'm a title I'm a paragraph ¡P…"
+ )
self.assertEqual(
self.text_from_html(html, 7, ellipsis=""),
- u"I'm a title I'm a paragraph ¡Pues")
+ u"I'm a title I'm a paragraph ¡Pues",
+ )
@mute_logger("odoo.addons.html_text.models.ir_fields_converter")
def test_empty_html(self):