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

Adiciona validação de existência de name ou collab e corrige a validação de collab-list #741

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
19 changes: 19 additions & 0 deletions packtools/sps/utils/xml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,22 @@ def put_parent_context(data, lang, article_type, parent, parent_id):
}
)
return data


def get_parent_data(node):
return {
"parent": node.tag,
"parent_id": node.get("id"),
"parent_lang": node.get("{http://www.w3.org/XML/1998/namespace}lang"),
"parent_article_type": node.get("article-type"),
"xpath": "sub-article" if node.tag == "sub-article" else "front | body | back"
}


def get_parents(xmltree):
main = xmltree.xpath(".")[0]
yield get_parent_data(main)
for node in xmltree.xpath("./sub-article"):
yield get_parent_data(node)
for sub_node in node.xpath("./sub-article"):
yield get_parent_data(sub_node)
Loading