Skip to content
Open
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
37 changes: 29 additions & 8 deletions packtools/sps/formats/pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
journal_meta,
kwd_group,
)
from packtools.sps.utils.xml_utils import node_plain_text


def xml_pubmed_article_pipe():
Expand Down Expand Up @@ -508,18 +509,38 @@ def xml_pubmed_history(xml_pubmed, xml_tree):
xml_pubmed.append(history)


def get_copyright_information(xml_tree):
copyright_statement = xml_tree.find(".//permissions/copyright-statement")
return node_plain_text(copyright_statement) or None


def xml_pubmed_copyright_information(xml_pubmed, xml_tree):
...
# TODO
# The Copyright information associated with this article.
# There is no example of using this value in the files.
"""
<CopyrightInformation>Copyright © 2023 The Authors</CopyrightInformation>
"""
copyright_information = get_copyright_information(xml_tree)
if copyright_information:
el = ET.Element("CopyrightInformation")
el.text = copyright_information
xml_pubmed.append(el)


def get_coi_statement(xml_tree):
fn_node = xml_tree.find('.//fn[@fn-type="coi-statement"]')
if fn_node is None:
return None
return node_plain_text(fn_node.find("p")) or node_plain_text(fn_node) or None


def xml_pubmed_coi_statement(xml_pubmed, xml_tree):
...
# TODO
# The Conflict of Interest statement associated with this article.
# There is no example of using this value in the files.
"""
<CoiStatement>Não há conflito de interesse entre os autores do artigo.</CoiStatement>
"""
coi_statement = get_coi_statement(xml_tree)
if coi_statement:
el = ET.Element("CoiStatement")
el.text = coi_statement
xml_pubmed.append(el)


def get_keywords(xml_tree):
Expand Down
115 changes: 115 additions & 0 deletions tests/sps/formats/test_pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
xml_pubmed_publication_type,
xml_pubmed_article_id,
xml_pubmed_history,
xml_pubmed_copyright_information,
xml_pubmed_coi_statement,
xml_pubmed_vernacular_title_pipe,
xml_pubmed_object_list,
xml_pubmed_title_reference_list,
Expand Down Expand Up @@ -1243,6 +1245,119 @@ def test_xml_pubmed_history(self):

self.assertEqual(obtained, expected)

def test_xml_pubmed_copyright_information(self):
expected = (
'<Article>'
'<CopyrightInformation>Copyright © 2023 The Authors</CopyrightInformation>'
'</Article>'
)
xml_pubmed = ET.fromstring(
'<Article/>'
)
xml_tree = ET.fromstring(
'<article xmlns:mml="http://www.w3.org/1998/Math/MathML" '
'xmlns:xlink="http://www.w3.org/1999/xlink" '
'article-type="research-article" dtd-version="1.1" specific-use="sps-1.9" xml:lang="en">'
'<front>'
'<article-meta>'
'<permissions>'
'<copyright-statement>Copyright © 2023 The Authors</copyright-statement>'
'</permissions>'
'</article-meta>'
'</front>'
'</article>'
)

xml_pubmed_copyright_information(xml_pubmed, xml_tree)

obtained = ET.tostring(xml_pubmed, encoding="utf-8").decode("utf-8")

self.assertEqual(obtained, expected)

def test_xml_pubmed_copyright_information_without_statement(self):
expected = (
'<Article/>'
)
xml_pubmed = ET.fromstring(
'<Article/>'
)
xml_tree = ET.fromstring(
'<article xmlns:mml="http://www.w3.org/1998/Math/MathML" '
'xmlns:xlink="http://www.w3.org/1999/xlink" '
'article-type="research-article" dtd-version="1.1" specific-use="sps-1.9" xml:lang="en">'
'<front>'
'<article-meta>'
'<permissions>'
'</permissions>'
'</article-meta>'
'</front>'
'</article>'
)

xml_pubmed_copyright_information(xml_pubmed, xml_tree)

obtained = ET.tostring(xml_pubmed, encoding="utf-8").decode("utf-8")

self.assertEqual(obtained, expected)

def test_xml_pubmed_coi_statement(self):
expected = (
'<Article>'
'<CoiStatement>Não há conflito de interesse entre os autores do artigo.</CoiStatement>'
'</Article>'
)
xml_pubmed = ET.fromstring(
'<Article/>'
)
xml_tree = ET.fromstring(
'<article xmlns:mml="http://www.w3.org/1998/Math/MathML" '
'xmlns:xlink="http://www.w3.org/1999/xlink" '
'article-type="research-article" dtd-version="1.1" specific-use="sps-1.9" xml:lang="pt">'
'<front>'
'<article-meta>'
'<author-notes>'
'<fn fn-type="coi-statement">'
'<label>Conflito de Interesses</label>'
'<p>Não há conflito de interesse entre os autores do artigo.</p>'
'</fn>'
'</author-notes>'
'</article-meta>'
'</front>'
'</article>'
)

xml_pubmed_coi_statement(xml_pubmed, xml_tree)

obtained = ET.tostring(xml_pubmed, encoding="utf-8").decode("utf-8")

self.assertEqual(obtained, expected)

def test_xml_pubmed_coi_statement_without_fn(self):
expected = (
'<Article/>'
)
xml_pubmed = ET.fromstring(
'<Article/>'
)
xml_tree = ET.fromstring(
'<article xmlns:mml="http://www.w3.org/1998/Math/MathML" '
'xmlns:xlink="http://www.w3.org/1999/xlink" '
'article-type="research-article" dtd-version="1.1" specific-use="sps-1.9" xml:lang="en">'
'<front>'
'<article-meta>'
'<author-notes>'
'</author-notes>'
'</article-meta>'
'</front>'
'</article>'
)

xml_pubmed_coi_statement(xml_pubmed, xml_tree)

obtained = ET.tostring(xml_pubmed, encoding="utf-8").decode("utf-8")

self.assertEqual(obtained, expected)

def test_xml_pubmed_object_list_keyword(self):
expected = (
'<Article>'
Expand Down