[IMP] update dotfiles
parent
16dea20491
commit
f7a5b4dd71
|
@ -16,7 +16,7 @@ class IrFieldsConverter(models.AbstractModel):
|
|||
|
||||
@api.model
|
||||
def text_from_html(
|
||||
self, html_content, max_words=None, max_chars=None, ellipsis=u"…", fail=False
|
||||
self, html_content, max_words=None, max_chars=None, ellipsis="…", fail=False
|
||||
):
|
||||
"""Extract text from an HTML field in a generator.
|
||||
|
||||
|
@ -52,7 +52,7 @@ class IrFieldsConverter(models.AbstractModel):
|
|||
return ""
|
||||
|
||||
# Get words
|
||||
words = u"".join(doc.xpath("//text()")).split()
|
||||
words = "".join(doc.xpath("//text()")).split()
|
||||
|
||||
# Truncate words
|
||||
suffix = max_words and len(words) > max_words
|
||||
|
@ -60,7 +60,7 @@ class IrFieldsConverter(models.AbstractModel):
|
|||
words = words[:max_words]
|
||||
|
||||
# Get text
|
||||
text = u" ".join(words)
|
||||
text = " ".join(words)
|
||||
|
||||
# Truncate text
|
||||
suffix = suffix or max_chars and len(text) > max_chars
|
||||
|
|
|
@ -15,7 +15,7 @@ class ExtractorCase(TransactionCase):
|
|||
|
||||
def test_excerpts(self):
|
||||
"""Text gets correctly extracted."""
|
||||
html = u"""
|
||||
html = """
|
||||
<html>
|
||||
<body>
|
||||
<div class="this should not appear">
|
||||
|
@ -28,17 +28,17 @@ class ExtractorCase(TransactionCase):
|
|||
"""
|
||||
self.assertEqual(
|
||||
self.text_from_html(html),
|
||||
u"I'm a title I'm a paragraph ¡Pues yo soy español!",
|
||||
"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), "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), "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",
|
||||
"I'm a title I'm a paragraph ¡Pues",
|
||||
)
|
||||
|
||||
@mute_logger("odoo.addons.html_text.models.ir_fields_converter")
|
||||
|
|
Loading…
Reference in New Issue