diff --git a/packtools/catalogs/htmlgenerator/v2.0/article-meta-related-article.xsl b/packtools/catalogs/htmlgenerator/v2.0/article-meta-related-article.xsl index 463e8cc8e..d2773829f 100644 --- a/packtools/catalogs/htmlgenerator/v2.0/article-meta-related-article.xsl +++ b/packtools/catalogs/htmlgenerator/v2.0/article-meta-related-article.xsl @@ -45,6 +45,7 @@ do site. --> + This addendum adds information to the following document This erratum corrects This retraction retracts This document comments diff --git a/packtools/catalogs/htmlgenerator/v2.0/config-labels.xml b/packtools/catalogs/htmlgenerator/v2.0/config-labels.xml index 96107acb7..3d6790e0e 100644 --- a/packtools/catalogs/htmlgenerator/v2.0/config-labels.xml +++ b/packtools/catalogs/htmlgenerator/v2.0/config-labels.xml @@ -493,4 +493,11 @@ Este documento tem um adendo Este documento tiene una addenda + + This addendum adds information to the following document + This addendum adds information to the following document + Este adendo adiciona informação ao documento + Esta addenda agrega información al documento + + \ No newline at end of file diff --git a/packtools/file_utils_mimetype.py b/packtools/file_utils_mimetype.py index 428a1785c..a67cf9e1c 100644 --- a/packtools/file_utils_mimetype.py +++ b/packtools/file_utils_mimetype.py @@ -1,5 +1,5 @@ import os -import magic +import mimetypes def is_valid_file(file_path, check_mimetype=False): @@ -14,5 +14,4 @@ def is_valid_file(file_path, check_mimetype=False): def get_mimetype(file_path): - with open(file_path, 'rb') as fin: - return magic.from_buffer(fin.read(2048), mime=True) + return mimetypes.guess_type(file_path, strict=True) diff --git a/packtools/sps/models/article_ids.py b/packtools/sps/models/article_ids.py index 5a83bed3f..1c47cd945 100644 --- a/packtools/sps/models/article_ids.py +++ b/packtools/sps/models/article_ids.py @@ -64,16 +64,28 @@ def v2(self, value): node = self._get_node( './/article-id[@specific-use="scielo-v2"]' ) + if node is not None and node.text: + raise AttributeError( + "can't set attribute ArticleIds.v2. It is already set: %s" % + node.text + ) + if not value: + raise ValueError( + "can't set attribute ArticleIds.v2. " + "Given value %s is not valid" % value) if node is None: node = etree.Element("article-id") node.set("pub-id-type", "publisher-id") node.set("specific-use", "scielo-v2") self.am.insert(1, node) - if node is not None: - node.text = value + node.text = value @v3.setter def v3(self, value): + if not value: + raise ValueError( + "can't set attribute ArticleIds.v3. " + "Given value %s is not valid" % value) node = self._get_node( './/article-id[@specific-use="scielo-v3"]' ) @@ -87,6 +99,10 @@ def v3(self, value): @aop_pid.setter def aop_pid(self, value): + if not value: + raise ValueError( + "can't set attribute ArticleIds.aop_pid. " + "Given value %s is not valid" % value) node = self._get_node( './/article-id[@specific-use="previous-pid" and ' '@pub-id-type="publisher-id"]' @@ -110,4 +126,3 @@ def _get_node_text(self, xpath): return self._get_node(xpath).text except AttributeError: return None - diff --git a/packtools/sps/models/funding_group.py b/packtools/sps/models/funding_group.py index 2975f9f6f..8488b3710 100644 --- a/packtools/sps/models/funding_group.py +++ b/packtools/sps/models/funding_group.py @@ -1,7 +1,5 @@ import logging -from packtools.sps.utils import xml_utils - logger = logging.getLogger(__name__) @@ -23,8 +21,8 @@ class FundingGroup: Arrangement containing a dictionary that correlates funding-source and award-id or values of one of the attributes. """ - def __init__(self, xml): - self._xmltree = xml_utils.get_xml_tree(xml) + def __init__(self, xmltree): + self._xmltree = xmltree @property def award_groups(self): diff --git a/tests/fixtures/htmlgenerator/related-article/addendum.pt.html b/tests/fixtures/htmlgenerator/related-article/addendum.pt.html new file mode 100644 index 000000000..85cc776ce --- /dev/null +++ b/tests/fixtures/htmlgenerator/related-article/addendum.pt.html @@ -0,0 +1,78 @@ + + + + + + + + + + + +
+
+ +
+
Este adendo adiciona informação ao documento: +
+ +
+

+Adendo +

+ +
+
+ +
+

+

No artigo Educação Bilíngue para alunos surdos: notas sobre a construção da linguagem argumentativa no aprendizado de Ciências, com número de DOI: http://dx.doi.org/10.1590/1678-460X202257175, publicado no periódico D.E.L.T.A., 38-1, 2022:202257175, deve-se considerar a adição da informação:

+

+

Artigo em Libras: https://youtu.be/frfspa_XnoE

+

+

A adição da informação se faz necessária por mais de um motivo: (1) trata-se de um número temático sobre educação inclusiva e não seria realmente inclusiva se não incluíssemos ao menos um texto acessível aos surdos; e (2) temos autores surdos no grupo que atuou na escrita do número temático e esse texto é especificamente de um dos grupos de estudos surdos.

+
+
+

Datas de Publicação

+
    +
  • +Publicação nesta coleção
    22 Abr 2022
  • +
  • +Data do Fascículo
    2022
  • +
+
+
+
+
+ +
+ + + diff --git a/tests/fixtures/htmlgenerator/related-article/addendum.xml b/tests/fixtures/htmlgenerator/related-article/addendum.xml new file mode 100644 index 000000000..75992e9c0 --- /dev/null +++ b/tests/fixtures/htmlgenerator/related-article/addendum.xml @@ -0,0 +1,60 @@ + + +
+ + + delta + + DELTA: Documentação de Estudos em Lingüística Teórica e Aplicada + DELTA + + 0102-4450 + 1678-460X + + Pontifícia Universidade Católica de São Paulo - PUC-SP + + + + s8JQvV57hfnwnMSFWS38G8S + S0102-44502022000101000 + 10.1590/1678-460X202257175video + 01000 + + + Adendo + + + + Adendo + + + 22 + 04 + 2022 + + + 2022 + + 38 + 1 + 202257175video + + + Este é um artigo publicado em acesso aberto sob uma licença Creative Commons + + + 10.1590/1678-460X202257175 + + + + + + + + + +

No artigo Educação Bilíngue para alunos surdos: notas sobre a construção da linguagem argumentativa no aprendizado de Ciências, com número de DOI: http://dx.doi.org/10.1590/1678-460X202257175, publicado no periódico D.E.L.T.A., 38-1, 2022:202257175, deve-se considerar a adição da informação:

+

Artigo em Libras: https://youtu.be/frfspa_XnoE

+

A adição da informação se faz necessária por mais de um motivo: (1) trata-se de um número temático sobre educação inclusiva e não seria realmente inclusiva se não incluíssemos ao menos um texto acessível aos surdos; e (2) temos autores surdos no grupo que atuou na escrita do número temático e esse texto é especificamente de um dos grupos de estudos surdos.

+ +
\ No newline at end of file diff --git a/tests/sps/test_article_ids.py b/tests/sps/test_article_ids.py index ae7a4f94a..d53b95c3a 100644 --- a/tests/sps/test_article_ids.py +++ b/tests/sps/test_article_ids.py @@ -75,7 +75,7 @@ def test_absent_other(self): def test_absent_doi(self): article_id = ArticleIds(_get_xmltree()) self.assertIsNone(article_id.doi) - + def test_update_v3(self): self.article_id.v3 = "novo_v3" self.assertEqual("novo_v3", self.article_id.v3) @@ -95,3 +95,44 @@ def test_update_doi_raises_AttributeError(self): def test_update_other_raises_AttributeError(self): with self.assertRaises(AttributeError): self.article_id.other = "xxxx" + + def test_update_v3_raises_ValueError(self): + with self.assertRaises(ValueError): + self.article_id.v3 = "" + + def test_update_aop_pid_raises_ValueError(self): + with self.assertRaises(ValueError): + self.article_id.aop_pid = "" + + +class TestArticleIdsOriginalXMLHasNoArticleId(TestCase): + """ + Estes testes são para explicitar a saída de + parse_issue usando o contéudo de + """ + def setUp(self): + self.article_id = ArticleIds(_get_xmltree('')) + + def test_update_v2(self): + self.article_id.v2 = "novo_v2" + self.assertEqual("novo_v2", self.article_id.v2) + + def test_update_v3(self): + self.article_id.v3 = "novo_v3" + self.assertEqual("novo_v3", self.article_id.v3) + + def test_update_aop_pid(self): + self.article_id.aop_pid = "novo_aop_pid" + self.assertEqual("novo_aop_pid", self.article_id.aop_pid) + + def test_update_v2_raises_ValueError(self): + with self.assertRaises(ValueError): + self.article_id.v2 = "" + + def test_update_v3_raises_ValueError(self): + with self.assertRaises(ValueError): + self.article_id.v3 = "" + + def test_update_aop_pid_raises_ValueError(self): + with self.assertRaises(ValueError): + self.article_id.aop_pid = "" diff --git a/tests/test_funding_group.py b/tests/test_funding_group.py index d9f75e157..24a340ced 100644 --- a/tests/test_funding_group.py +++ b/tests/test_funding_group.py @@ -1,12 +1,12 @@ # coding: utf-8 from __future__ import unicode_literals import unittest - try: from unittest import mock except: import mock +from lxml import etree from packtools.sps.models.funding_group import FundingGroup @@ -30,7 +30,7 @@ def setUp(self): """ ) - self.funding_group = FundingGroup(xml) + self.funding_group = FundingGroup(etree.fromstring(xml)) def test_funding_sources(self): expected = ['CNPQ', 'FAPESP'] @@ -60,7 +60,7 @@ def setUp(self): """ ) - self.funding_group = FundingGroup(xml) + self.funding_group = FundingGroup(etree.fromstring(xml)) def test_funding_sources(self): expected = ['CNPq'] @@ -90,7 +90,7 @@ def setUp(self): """ ) - self.funding_group = FundingGroup(xml) + self.funding_group = FundingGroup(etree.fromstring(xml)) def test_funding_sources(self): expected = ['CNPq', 'FAPESP'] @@ -124,7 +124,7 @@ def setUp(self): """ ) - self.funding_group = FundingGroup(xml) + self.funding_group = FundingGroup(etree.fromstring(xml)) def test_funding_sources(self): expected = ['Coordenação de Aperfeiçoamento de Pessoal de Nível Superior',