Skip to content

Corrige validação para SupplementaryMaterial e testes #947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Rossi-Luciano
Copy link
Collaborator

O que esse PR faz?

Corrige validação para SupplementaryMaterial e testes.

Onde a revisão poderia começar?

NA

Como este poderia ser testado manualmente?

NA

Algum cenário de contexto que queira dar?

NA

Screenshots

NA

Quais são tickets relevantes?

Substitui o PR #915

Referências

NA

data=self.data,
)

def validate_prohibited_inline(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano este método pode ser de uma classe que seja instanciada com xml_tree

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

advice=None,
data=supp,
error_level="OK",
def __init__(self, data, xml_tree, params, node=None):
Copy link
Member

@robertatakenaka robertatakenaka Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano excluir xml_tree. Tenha uma classe para validar o elemento individualmente e outra para validar no nível do XML

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data=None,
error_level=error_level,

def validate_position(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano método de uma classe que é instanciada com xml_tree

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

advice=None,
data=supp,
error_level="OK",
def __init__(self, data, params, node=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano Em data não há dados de média ou de graphic? Deveria para evitar que você tenha que passar o node.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 27 to 30
for media in self.node.xpath(".//media"):
if media.data:
yield from MediaValidation(media.data, self.params).validate()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano não daria para fazer algo como:

if data.get("alguma chave que indica que é media"):
    yield from MediaValidation(data, self.params).validate()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
Ensures that <supplementary-material> does not occur inside <app-group> and <app>.
"""
valid = self.data.get("parent_suppl_mat") not in ["app-group", "app"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano colocar em params o item é "parent_suppl_mat_expected": ["app-group", "app"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
Verifies if the supplementary materials section is in the last position of <body> or inside <back>.
"""
article_body = self.xml_tree.find("body")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano acho que primeiro tem que saber se há pelo menos 1 material suplementar antes de seguir a validação

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -82,11 +86,11 @@ def items_by_id(self):
considera esse elemento, apesar de ele poder existir.
"""
supp_dict = {}
for node in self.xml_tree.xpath(". | sub-article"):
for node in self.xml_tree.xpath("./front | ./body | ./back | .//sub-article"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano: troque self.xml_tree.xpath("./front | ./body | ./back | .//sub-article"): por self.xml_tree.xpath(". | .//sub-article"):

node_id = node.get("id") if node.get("id") else "main_article"
supp_dict.setdefault(node_id, [])
full_text = Fulltext(node)
for supp_node in full_text.node.xpath(".//supplementary-material"):
for supp_node in full_text.node.xpath(".//supplementary-material") or []:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

troque full_text.node.xpath(".//supplementary-material") por full_text.node.xpath("./front//supplementary-material | ./body//supplementary-material | ./back//supplementary-material")

@@ -124,6 +124,10 @@ def validate_position(self):
"""
Verifies if the supplementary materials section is in the last position of <body> or inside <back>.
"""
sections = self.xml_tree.findall(".//sec")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

troque sections = self.xml_tree.findall(".//sec")... por

sections = self.xml_tree.xpath('.//sec[@sec-type="supplementary-material"]')
if not sections:
    return

Copy link
Member

@robertatakenaka robertatakenaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano corrigir

node_id = node.get("id") if node.get("id") else "main_article"
supp_dict.setdefault(node_id, [])
full_text = Fulltext(node)
for supp_node in full_text.node.xpath(".//supplementary-material"):
for supp_node in full_text.node.xpath("./front//supplementary-material | ./body//supplementary-material | ./back//supplementary-material") or []:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rossi-Luciano adicionar front-stub

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertatakenaka robertatakenaka merged commit 3248f6c into scieloorg:master Apr 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants