Skip to content
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

Feat: footnotes validation #702

Merged
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