Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
do site.
-->
<xsl:choose>
<xsl:when test="$article/@article-type='addendum'">This addendum adds information to the following document</xsl:when>
<xsl:when test=".='corrected-article'">This erratum corrects</xsl:when>
<xsl:when test=".='retracted-article'">This retraction retracts</xsl:when>
<xsl:when test=".='commentary-article'">This document comments</xsl:when>
Expand Down
7 changes: 7 additions & 0 deletions packtools/catalogs/htmlgenerator/v2.0/config-labels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,11 @@
<name lang="pt">Este documento tem um adendo</name>
<name lang="es">Este documento tiene una addenda</name>
</term>
<term>
<name>This addendum adds information to the following document</name>
<name lang="en">This addendum adds information to the following document</name>
<name lang="pt">Este adendo adiciona informação ao documento</name>
<name lang="es">Esta addenda agrega información al documento</name>
</term>

</labels>
5 changes: 2 additions & 3 deletions packtools/file_utils_mimetype.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import magic
import mimetypes


def is_valid_file(file_path, check_mimetype=False):
Expand All @@ -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)
21 changes: 18 additions & 3 deletions packtools/sps/models/article_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
)
Expand All @@ -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"]'
Expand All @@ -110,4 +126,3 @@ def _get_node_text(self, xpath):
return self._get_node(xpath).text
except AttributeError:
return None

6 changes: 2 additions & 4 deletions packtools/sps/models/funding_group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import logging

from packtools.sps.utils import xml_utils


logger = logging.getLogger(__name__)

Expand All @@ -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):
Expand Down
78 changes: 78 additions & 0 deletions tests/fixtures/htmlgenerator/related-article/addendum.pt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<link rel="stylesheet" href="/Users/roberta.takenaka/github.com/scieloorg/packtools2/packtools/packtools/catalogs/htmlgenerator/static/scielo-article-standalone.css">
<link rel="stylesheet" href="/Users/roberta.takenaka/github.com/scieloorg/packtools2/packtools/packtools/catalogs/htmlgenerator/static/scielo-bundle-print.css" media="print">
<link rel="alternate" type="application/rss+xml" title="SciELO" href="">
</head>
<body class="journal article">
<a name="top"></a><div id="standalonearticle">
<section class="articleCtt"><div class="container"><div class="articleTxt">
<div class="articleBadge-editionMeta-doi-copyLink">
<span class="_articleBadge">Adendo</span><span class="_separator"> • </span><span class="_editionMeta">DELTA 38
(1)
<span class="_separator"> • </span>2022</span><span class="_separator"> • </span><span class="group-doi"><a href="https://doi.org/10.1590/1678-460X2022571ddddd75video" class="_doi" target="_blank">https://doi.org/10.1590/1678-460X2022571ddddd75video</a>

<a class="copyLink" data-clipboard-text="https://doi.org/10.1590/1678-460X2022571ddddd75video"><span class="sci-ico-link"></span>copiar</a></span>
</div>
<div class="panel article-correction-title">
<div class="panel-heading">Este adendo adiciona informação ao documento:
</div>
<div class="panel-body"><ul><li><a target="_blank" href="https://doi.org/10.1590/1678-460X202257175">10.1590/1678-460X202257175</a></li></ul></div>
</div>
<h1 class="article-title">
<span class="sci-ico-openAccess showTooltip" data-toggle="tooltip" data-original-title="by 4.0 "></span>Adendo<a id="shorten" href="#" class="short-link"><span class="sci-ico-link"></span></a>
</h1>
<div class="articleMeta"></div>
<div class="contribGroup"></div>
<div class="row">
<ul class="col-md-2 hidden-sm articleMenu"></ul>
<article id="articleText" class="col-md-10 col-md-offset-2 col-sm-12 col-sm-offset-0"><div class="articleSection" data-anchor="Text">
<p></p>
<p>No artigo <b>Educação Bilíngue para alunos surdos: notas sobre a construção da linguagem argumentativa no aprendizado de Ciências</b>, 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:</p>
<p></p>
<p>Artigo em Libras: <a href="https://youtu.be/frfspa_XnoE" target="_blank">https://youtu.be/frfspa_XnoE</a> </p>
<p></p>
<p>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.</p>
</div>
<div class="articleSection" data-anchor="Datas de Publicação ">
<h1 class="articleSectionTitle">Datas de Publicação </h1>
<div class="row"><div class="col-md-12 col-sm-12"><ul class="articleTimeline">
<li>
<strong>Publicação nesta coleção</strong><br>22 Abr 2022</li>
<li>
<strong>Data do Fascículo</strong><br>2022</li>
</ul></div></div>
</div>
<section class="documentLicense"><div class="container-license"><div class="row">
<div class="col-sm-3 col-md-2"><a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" title=""><img src="https://licensebuttons.net/l/by/4.0//88x31.png" alt="Creative Common - by 4.0 "></a></div>
<div class="col-sm-9 col-md-10"><a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" title="">Este é um artigo publicado em acesso aberto sob uma licença Creative Commons</a></div>
</div></div></section></article>
</div>
</div></div></section><div class="modal fade ModalDefault" id="ModalArticles" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><h4 class="modal-title">Como citar</h4>
</div>
<div class="modal-body">
<p id="citation"></p>
<input id="citationCut" type="text" value=""><a class="copyLink" data-clipboard-target="#citationCut"><span class="glyphBtn copyIcon"></span>copiar</a>
</div>
</div></div></div>
<script type="text/javascript">
function currentDate() {
var today = new Date();
var months = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
today.setTime(today.getTime());
return today.getDate() + " " + months[today.getMonth()] + " " + today.getFullYear();
}
var citation = 'Adendo. DELTA: Documentação de Estudos em Lingüística Teórica e Aplicada [online]. 2022, v. 38, n. 1 [Acessado CURRENTDATE], 202257175video. Disponível em: &lt;https://doi.org/10.1590/1678-460X2022571ddddd75video&gt;. Epub 22 Abr 2022. ISSN 1678-460X. https://doi.org/10.1590/1678-460X2022571ddddd75video.'.replace('CURRENTDATE', currentDate());
document.getElementById('citation').innerHTML = citation;
document.getElementById('citationCut').value = citation.replace('&lt;', '<').replace('&gt;', ">");
</script>
</div>
<script src="/Users/roberta.takenaka/github.com/scieloorg/packtools2/packtools/packtools/catalogs/htmlgenerator/static/scielo-article-standalone-min.js"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions tests/fixtures/htmlgenerator/related-article/addendum.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1 20151215//EN" "https://jats.nlm.nih.gov/publishing/1.1/JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="addendum" dtd-version="1.1" specific-use="sps-1.9" xml:lang="pt">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">delta</journal-id>
<journal-title-group>
<journal-title>DELTA: Documentação de Estudos em Lingüística Teórica e Aplicada</journal-title>
<abbrev-journal-title abbrev-type="publisher">DELTA</abbrev-journal-title>
</journal-title-group>
<issn pub-type="ppub">0102-4450</issn>
<issn pub-type="epub">1678-460X</issn>
<publisher>
<publisher-name>Pontifícia Universidade Católica de São Paulo - PUC-SP</publisher-name>
</publisher>
</journal-meta>
<article-meta>
<article-id specific-use="scielo-v3" pub-id-type="publisher-id">s8JQvV57hfnwnMSFWS38G8S</article-id>
<article-id specific-use="scielo-v2" pub-id-type="publisher-id">S0102-44502022000101000</article-id>
<article-id pub-id-type="doi">10.1590/1678-460X202257175video</article-id>
<article-id pub-id-type="other">01000</article-id>
<article-categories>
<subj-group subj-group-type="heading">
<subject>Adendo</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>Adendo</article-title>
</title-group>
<pub-date date-type="pub" publication-format="electronic">
<day>22</day>
<month>04</month>
<year>2022</year>
</pub-date>
<pub-date date-type="collection" publication-format="electronic">
<year>2022</year>
</pub-date>
<volume>38</volume>
<issue>1</issue>
<elocation-id>202257175video</elocation-id>
<permissions>
<license license-type="open-access" xlink:href="https://creativecommons.org/licenses/by/4.0/" xml:lang="pt">
<license-p>Este é um artigo publicado em acesso aberto sob uma licença Creative Commons</license-p>
</license>
</permissions>
<related-article ext-link-type="doi" id="A01" related-article-type="retracted-article" xlink:href="10.1590/1678-460X202257175">10.1590/1678-460X202257175</related-article>
<counts>
<fig-count count="0"/>
<table-count count="0"/>
<equation-count count="0"/>
<ref-count count="0"/>
</counts>
</article-meta>
</front>
<body>
<p>No artigo <bold>Educação Bilíngue para alunos surdos: notas sobre a construção da linguagem argumentativa no aprendizado de Ciências</bold>, 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:</p>
<p>Artigo em Libras: <ext-link ext-link-type="uri" xlink:href="https://youtu.be/frfspa_XnoE">https://youtu.be/frfspa_XnoE</ext-link> </p>
<p>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.</p>
</body>
</article>
43 changes: 42 additions & 1 deletion tests/sps/test_article_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 <issue></issue>
"""
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 = ""
10 changes: 5 additions & 5 deletions tests/test_funding_group.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -30,7 +30,7 @@ def setUp(self):
</article>
"""
)
self.funding_group = FundingGroup(xml)
self.funding_group = FundingGroup(etree.fromstring(xml))

def test_funding_sources(self):
expected = ['CNPQ', 'FAPESP']
Expand Down Expand Up @@ -60,7 +60,7 @@ def setUp(self):
</article>
"""
)
self.funding_group = FundingGroup(xml)
self.funding_group = FundingGroup(etree.fromstring(xml))

def test_funding_sources(self):
expected = ['CNPq']
Expand Down Expand Up @@ -90,7 +90,7 @@ def setUp(self):
</article>
"""
)
self.funding_group = FundingGroup(xml)
self.funding_group = FundingGroup(etree.fromstring(xml))

def test_funding_sources(self):
expected = ['CNPq', 'FAPESP']
Expand Down Expand Up @@ -124,7 +124,7 @@ def setUp(self):
</article>
"""
)
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',
Expand Down