From 0c876c23df1fc18b4d2f35c016c70e5d91a990a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?=
Date: Wed, 24 Feb 2021 16:23:31 +0100
Subject: [PATCH] [MIG] html_image_url_extractor: Migration to 13.0
[UPD] Update html_image_url_extractor.pot
[UPD] README.rst
---
html_image_url_extractor/README.rst | 20 +++++++++++--------
html_image_url_extractor/__manifest__.py | 8 ++++----
.../i18n/html_image_url_extractor.pot | 7 +++----
.../models/ir_fields_converter.py | 7 +------
.../readme/CONTRIBUTORS.rst | 10 +++++++---
.../static/description/index.html | 16 +++++++++------
.../tests/test_extractor.py | 11 ++++------
7 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/html_image_url_extractor/README.rst b/html_image_url_extractor/README.rst
index f62cbc07c..e7c8ad98e 100644
--- a/html_image_url_extractor/README.rst
+++ b/html_image_url_extractor/README.rst
@@ -14,13 +14,13 @@ Image URLs from HTML field
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
- :target: https://github.com/OCA/server-tools/tree/12.0/html_image_url_extractor
+ :target: https://github.com/OCA/server-tools/tree/13.0/html_image_url_extractor
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-html_image_url_extractor
+ :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-html_image_url_extractor
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/149/12.0
+ :target: https://runbot.odoo-community.org/runbot/149/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -70,7 +70,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -86,10 +86,14 @@ Authors
Contributors
~~~~~~~~~~~~
-* Jairo Llopis
-* Vicent Cubells
* Dennis Sluijk
-* Cristina Martin R.
+
+* `Tecnativa `_:
+
+ * Jairo Llopis
+ * Vicent Cubells
+ * Cristina Martin R
+ * Víctor Martínezz
Maintainers
~~~~~~~~~~~
@@ -104,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/server-tools `_ project on GitHub.
+This module is part of the `OCA/server-tools `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/html_image_url_extractor/__manifest__.py b/html_image_url_extractor/__manifest__.py
index 50b57ecd6..d1184fc6a 100644
--- a/html_image_url_extractor/__manifest__.py
+++ b/html_image_url_extractor/__manifest__.py
@@ -5,13 +5,13 @@
{
"name": "Image URLs from HTML field",
"summary": "Extract images found in any HTML field",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/server-tools",
- "author": "Tecnativa, " "Onestein, " "Odoo Community Association (OCA)",
+ "author": "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_image_url_extractor/i18n/html_image_url_extractor.pot b/html_image_url_extractor/i18n/html_image_url_extractor.pot
index 09488c35a..6f0e42665 100644
--- a/html_image_url_extractor/i18n/html_image_url_extractor.pot
+++ b/html_image_url_extractor/i18n/html_image_url_extractor.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * html_image_url_extractor
+# * html_image_url_extractor
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -17,4 +17,3 @@ msgstr ""
#: model:ir.model,name:html_image_url_extractor.model_ir_fields_converter
msgid "Fields Converter"
msgstr ""
-
diff --git a/html_image_url_extractor/models/ir_fields_converter.py b/html_image_url_extractor/models/ir_fields_converter.py
index f368d184a..9ad44b1ea 100644
--- a/html_image_url_extractor/models/ir_fields_converter.py
+++ b/html_image_url_extractor/models/ir_fields_converter.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017 Jairo Llopis
+# Copyright 2016-2017 Tecnativa - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
@@ -18,13 +18,10 @@ class IrFieldsConverter(models.AbstractModel):
@api.model
def imgs_from_html(self, html_content, limit=None, fail=False):
"""Extract all images in order from an HTML field in a generator.
-
:param str html_content:
HTML contents from where to extract the images.
-
:param int limit:
Only get up to this number of images.
-
:param bool fail:
If ``True``, exceptions will be raised.
"""
@@ -37,7 +34,6 @@ class IrFieldsConverter(models.AbstractModel):
else:
_logger.exception("Failure parsing this HTML:\n%s", html_content)
return
-
# Required tools
query = """
//img[@src] |
@@ -51,7 +47,6 @@ class IrFieldsConverter(models.AbstractModel):
\s*\) # End function
"""
rgx = re.compile(rgx, re.IGNORECASE | re.VERBOSE)
-
# Loop through possible image URLs
for lap, element in enumerate(doc.xpath(query)):
if limit and lap >= limit:
diff --git a/html_image_url_extractor/readme/CONTRIBUTORS.rst b/html_image_url_extractor/readme/CONTRIBUTORS.rst
index d94aa87bb..ed4a17636 100644
--- a/html_image_url_extractor/readme/CONTRIBUTORS.rst
+++ b/html_image_url_extractor/readme/CONTRIBUTORS.rst
@@ -1,4 +1,8 @@
-* Jairo Llopis
-* Vicent Cubells
* Dennis Sluijk
-* Cristina Martin R.
+
+* `Tecnativa `_:
+
+ * Jairo Llopis
+ * Vicent Cubells
+ * Cristina Martin R
+ * Víctor Martínezz
diff --git a/html_image_url_extractor/static/description/index.html b/html_image_url_extractor/static/description/index.html
index 0ad1ec457..606980c4c 100644
--- a/html_image_url_extractor/static/description/index.html
+++ b/html_image_url_extractor/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module includes a method that extracts image URLs from any chunk of HTML,
in appearing order.
It is useful for modules such as website_blog_excerpt_img: blog list shows the first
@@ -415,7 +415,7 @@ def some_method(self):
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -430,10 +430,14 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -443,7 +447,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/server-tools project on GitHub.
+
This module is part of the OCA/server-tools project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/html_image_url_extractor/tests/test_extractor.py b/html_image_url_extractor/tests/test_extractor.py
index 59cd0d6dc..e461deec5 100644
--- a/html_image_url_extractor/tests/test_extractor.py
+++ b/html_image_url_extractor/tests/test_extractor.py
@@ -1,4 +1,5 @@
-# Copyright 2016-2017 Jairo Llopis
+# Copyright 2016-2017 Tecnativa - Jairo Llopis
+# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
@@ -31,12 +32,10 @@ class ExtractorCase(TransactionCase):
"""
-
# Read all images
for n, url in enumerate(self.imgs_from_html(content)):
self.assertEqual("/path/%d" % n, url)
self.assertEqual(n, 7)
-
# Read only first image
for n, url in enumerate(self.imgs_from_html(content, 1)):
self.assertEqual("/path/%d" % n, url)
@@ -45,15 +44,13 @@ class ExtractorCase(TransactionCase):
@mute_logger("odoo.addons.html_image_url_extractor" + ".models.ir_fields_converter")
def test_empty_html(self):
"""Empty HTML handled correctly."""
- for laps, text in self.imgs_from_html(""):
- self.assertTrue(False) # You should never get here
+ self.assertTrue(enumerate(self.imgs_from_html("")))
with self.assertRaises(Exception):
list(self.imgs_from_html("", fail=True))
@mute_logger("odoo.addons.html_image_url_extractor" + ".models.ir_fields_converter")
def test_false_html(self):
"""``False`` HTML handled correctly."""
- for laps, text in self.imgs_from_html(False):
- self.assertTrue(False) # You should never get here
+ self.assertTrue(enumerate(self.imgs_from_html(False)))
with self.assertRaises(Exception):
list(self.imgs_from_html(False, fail=True))