Skip to content

Commit

Permalink
Feat: footnotes validation (#702)
Browse files Browse the repository at this point in the history
* Adiciona atributos ausentes em 'corresp' e 'fn'

* Adequa os testes

* Adiciona validação para 'label', 'title' e 'bold'

* Adequa os testes

* Corrige 'BaseNoteGroups'

* Corrige teste

* Refatora módulo 'footnotes.py'

* Adapta e adiciona testes

* Refatora validação de notas

* Adequa os testes

* Adiciona 'fn_rules.json'

* Refatora validação de notas de rodapé

* Adapta os testes

* Corrige local de 'validation_rules'

* Renomeia funções
  • Loading branch information
Rossi-Luciano authored Dec 27, 2024
1 parent 617011a commit 2b526fc
Show file tree
Hide file tree
Showing 6 changed files with 648 additions and 352 deletions.
25 changes: 21 additions & 4 deletions packtools/sps/models/v2/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def __init__(self, article_or_sub_article_node, fn_parent_tag_name, NoteGroupCla

@property
def items(self):
for fn_parent_node in self.article_or_sub_article_node.xpath(f".//{self.fn_parent_tag_name}"):
if self.parent == "article":
xpath = f".//front//{self.fn_parent_tag_name} | .//body//{self.fn_parent_tag_name} | .//back//{self.fn_parent_tag_name}"
else:
xpath = f".//{self.fn_parent_tag_name}"

for fn_parent_node in self.article_or_sub_article_node.xpath(xpath):
data = self.NoteGroupClass(fn_parent_node).data
yield put_parent_context(data, self.parent_lang, self.parent_article_type, self.parent, self.parent_id)

Expand All @@ -45,6 +50,7 @@ def __init__(self, node):
self.label = self.node.findtext("label")
self.text = process_subtags(self.node)
self.bold = self.node.findtext("bold")
self.title = self.node.findtext("title")

@property
def data(self):
Expand All @@ -53,7 +59,8 @@ def data(self):
"fn_type": self.type,
"fn_label": self.label,
"fn_text": self.text,
"fn_bold": self.bold
"fn_bold": self.bold,
"fn_title": self.title
}


Expand Down Expand Up @@ -91,13 +98,23 @@ def corresp(self):
def corresp_label(self):
return process_subtags(self.fn_parent_node.find("corresp/label"))

@property
def corresp_title(self):
return process_subtags(self.fn_parent_node.find("corresp/title"))

@property
def corresp_bold(self):
return process_subtags(self.fn_parent_node.find("corresp/bold"))

@property
def data(self):
return {
**super().data,
"corresp": self.corresp,
"corresp_label": self.corresp_label
}
"corresp_label": self.corresp_label,
"corresp_title": self.corresp_title,
"corresp_bold": self.corresp_bold
}


class AuthorNotes(BaseNoteGroups):
Expand Down
Loading

0 comments on commit 2b526fc

Please sign in to comment.