[MIG] html_image_url_extractor: Migration to 13.0
[UPD] Update html_image_url_extractor.pot [UPD] README.rstpull/2569/head
parent
d08d3e272c
commit
0c876c23df
|
@ -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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20html_image_url_extractor%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20html_image_url_extractor%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
|
@ -86,10 +86,14 @@ Authors
|
|||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
* Dennis Sluijk <d.sluijk@onestein.nl>
|
||||
* Cristina Martin R. <cristina.martin@tecnativa.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* 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 <https://github.com/OCA/server-tools/tree/12.0/html_image_url_extractor>`_ project on GitHub.
|
||||
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/html_image_url_extractor>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -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"],
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#
|
||||
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 ""
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# 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:
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
* Dennis Sluijk <d.sluijk@onestein.nl>
|
||||
* Cristina Martin R. <cristina.martin@tecnativa.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Jairo Llopis
|
||||
* Vicent Cubells
|
||||
* Cristina Martin R
|
||||
* Víctor Martínezz
|
||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/html_image_url_extractor"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-html_image_url_extractor"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/html_image_url_extractor"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-html_image_url_extractor"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module includes a method that extracts image URLs from any chunk of HTML,
|
||||
in appearing order.</p>
|
||||
<p>It is useful for modules such as <a class="reference external" href="https://github.com/OCA/website/tree/9.0/website_blog_excerpt_img">website_blog_excerpt_img</a>: blog list shows the first
|
||||
|
@ -415,7 +415,7 @@ def some_method(self):
|
|||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20html_image_url_extractor%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20html_image_url_extractor%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -430,10 +430,14 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Jairo Llopis <<a class="reference external" href="mailto:jairo.llopis@tecnativa.com">jairo.llopis@tecnativa.com</a>></li>
|
||||
<li>Vicent Cubells <<a class="reference external" href="mailto:vicent.cubells@tecnativa.com">vicent.cubells@tecnativa.com</a>></li>
|
||||
<li>Dennis Sluijk <<a class="reference external" href="mailto:d.sluijk@onestein.nl">d.sluijk@onestein.nl</a>></li>
|
||||
<li>Cristina Martin R. <<a class="reference external" href="mailto:cristina.martin@tecnativa.com">cristina.martin@tecnativa.com</a>></li>
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Jairo Llopis</li>
|
||||
<li>Vicent Cubells</li>
|
||||
<li>Cristina Martin R</li>
|
||||
<li>Víctor Martínezz</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
@ -443,7 +447,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/html_image_url_extractor">OCA/server-tools</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/html_image_url_extractor">OCA/server-tools</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# 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):
|
|||
</section>
|
||||
</div>
|
||||
"""
|
||||
|
||||
# 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))
|
||||
|
|
Loading…
Reference in New Issue