Skip to content

Commit

Permalink
Refactor: citation authors new (#611)
Browse files Browse the repository at this point in the history
* Adiciona 'parent' e 'parent_id'

* Adapta os testes

* Refatora validação (substitui outro PR)

* Adapta os testes (substitui outro PR)

* Corrige obtenção de 'parent'
  • Loading branch information
Rossi-Luciano authored May 14, 2024
1 parent ca6c340 commit 998d217
Show file tree
Hide file tree
Showing 4 changed files with 970 additions and 144 deletions.
60 changes: 33 additions & 27 deletions packtools/sps/models/article_citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,36 @@ def __init__(self, xmltree):

@property
def article_citations(self):
for node in self.xmltree.xpath("./back/ref-list//ref"):
tags = [
('ref_id', get_ref_id(node)),
('label', get_label(node)),
('publication_type', get_publication_type(node)),
('source', get_source(node)),
('main_author', get_main_author(node)),
('all_authors', get_all_authors(node)),
('volume', get_volume(node)),
('issue', get_issue(node)),
('fpage', get_fpage(node)),
('lpage', get_lpage(node)),
('elocation_id', get_elocation_id(node)),
('year', get_year(node)),
('article_title', get_article_title(node)),
('citation_ids', get_citation_ids(node)),
('mixed_citation', get_mixed_citation(node))
]
d = dict()
for name, value in tags:
if value is not None and len(value) > 0:
try:
d[name] = value.text
except AttributeError:
d[name] = value
d['author_type'] = 'institutional' if get_collab(node) else 'person'
yield d
for parent in self.xmltree.xpath(". | .//sub-article"):
parent_data = {
'parent': 'sub-article' if parent.get("id") else 'article',
'parent_id': parent.get("id")
}
for node in parent.xpath("./back/ref-list//ref"):
tags = [
('ref_id', get_ref_id(node)),
('label', get_label(node)),
('publication_type', get_publication_type(node)),
('source', get_source(node)),
('main_author', get_main_author(node)),
('all_authors', get_all_authors(node)),
('volume', get_volume(node)),
('issue', get_issue(node)),
('fpage', get_fpage(node)),
('lpage', get_lpage(node)),
('elocation_id', get_elocation_id(node)),
('year', get_year(node)),
('article_title', get_article_title(node)),
('citation_ids', get_citation_ids(node)),
('mixed_citation', get_mixed_citation(node))
]
d = dict()
for name, value in tags:
if value is not None and len(value) > 0:
try:
d[name] = value.text
except AttributeError:
d[name] = value
d['author_type'] = 'institutional' if get_collab(node) else 'person'
d.update(parent_data)
yield d
Loading

0 comments on commit 998d217

Please sign in to comment.