-
Notifications
You must be signed in to change notification settings - Fork 24
fix: corrige idioma do resumo de sub-article traduzido (#1329) #1334
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
Merged
robertatakenaka
merged 4 commits into
scieloorg:master
from
Rossi-Luciano:fix/1329-sub-article-abstract-lang
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d316f63
fix: corrige idioma do resumo de sub-article traduzido (#1329)
Rossi-Luciano e68123b
test: adiciona regressão para idioma incorreto em abstract de sub-art…
Rossi-Luciano c8ec319
Bump version to 4.17.2
Rossi-Luciano 3d52a6c
fix: restaura XMLAbstracts em sps/models, corrige categorizacao da PR…
Rossi-Luciano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,72 +1,28 @@ | ||
| from packtools.sps.models.v2.abstract import Abstract | ||
|
|
||
|
|
||
| class XMLAbstracts: | ||
| def __init__(self, xmltree): | ||
| self.xmltree = xmltree | ||
| self.lang = xmltree.find(".").get("{http://www.w3.org/XML/1998/namespace}lang") | ||
| self.tags_to_keep = None | ||
| self.tags_to_keep_with_content = None | ||
| self.tags_to_remove_with_content = None | ||
| self.tags_to_convert_to_html = None | ||
|
|
||
| def configure( | ||
| self, | ||
| tags_to_keep=None, | ||
| tags_to_keep_with_content=None, | ||
| tags_to_remove_with_content=None, | ||
| tags_to_convert_to_html=None, | ||
| ): | ||
| self.tags_to_keep = tags_to_keep | ||
| self.tags_to_keep_with_content = tags_to_keep_with_content | ||
| self.tags_to_remove_with_content = tags_to_remove_with_content | ||
| self.tags_to_convert_to_html = tags_to_convert_to_html | ||
|
|
||
| def get_abstracts(self, abstract_type=None): | ||
| if abstract_type: | ||
| xpath = f'.//abstract[@abstract-type="{abstract_type}"] | .//trans-abstract[@abstract-type="{abstract_type}"]' | ||
| else: | ||
| xpath = ".//abstract[not(@abstract-type)] | .//trans-abstract[not(@abstract-type)]" | ||
|
|
||
| for node in self.xmltree.xpath(xpath): | ||
| abstract = Abstract( | ||
| node, | ||
| node.get("{http://www.w3.org/XML/1998/namespace}lang") or self.lang, | ||
| tags_to_keep=self.tags_to_keep, | ||
| tags_to_keep_with_content=self.tags_to_keep_with_content, | ||
| tags_to_remove_with_content=self.tags_to_remove_with_content, | ||
| tags_to_convert_to_html=self.tags_to_convert_to_html, | ||
| ) | ||
| yield abstract.data | ||
|
|
||
| @property | ||
| def standard_abstracts(self): | ||
| return self.get_abstracts() | ||
|
|
||
| @property | ||
| def visual_abstracts(self): | ||
| return self.get_abstracts("graphical") | ||
|
|
||
| @property | ||
| def key_points_abstracts(self): | ||
| return self.get_abstracts("key-points") | ||
|
|
||
| @property | ||
| def summary_abstracts(self): | ||
| return self.get_abstracts("summary") | ||
|
|
||
| @property | ||
| def abstracts(self): | ||
| yield from self.standard_abstracts | ||
| yield from self.key_points_abstracts | ||
| yield from self.visual_abstracts | ||
| yield from self.summary_abstracts | ||
|
|
||
| def abstracts_by_lang_and_type(self): | ||
| langs = {} | ||
| for item in self.abstracts: | ||
| lang = item["lang"] | ||
| abstract_type = item["abstract_type"] | ||
| langs.setdefault(lang, {}) | ||
| langs[lang][abstract_type] = item | ||
| return langs | ||
| """ | ||
| XMLAbstracts moved back to packtools.sps.models.v2.abstract. | ||
|
|
||
| PR #1180 (2026-05) moved it here believing it was used only by validation | ||
| code; that premise was wrong (scms-upload's TOC builder consumes it | ||
| directly for presentation data via packtools.sps.models.v2.abstract, not | ||
| for validation). Kept as a compatibility redirect only: this module | ||
| should not gain new logic, since the class itself carries no | ||
| validation-rule/expected-value concerns and doesn't belong here. | ||
| """ | ||
| import warnings as _warnings | ||
|
|
||
|
|
||
| def __getattr__(name): | ||
| _moved = { | ||
| "XMLAbstracts": "packtools.sps.models.v2.abstract", | ||
| } | ||
| if name in _moved: | ||
| import importlib | ||
| _warnings.warn( | ||
| f"{name} has moved to {_moved[name]}. " | ||
| f"Importing from packtools.sps.validation.models.abstract is deprecated.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| mod = importlib.import_module(_moved[name]) | ||
| return getattr(mod, name) | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """Single source to the version across setup.py and the whole project. | ||
| """ | ||
| from __future__ import unicode_literals | ||
| __version__ = '4.17.0' | ||
| __version__ = '4.17.2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rossi-Luciano remover todo o conteúdo atual deste arquivo e colocar:
from packtools.sps.models.v2.abstract import Abstract, XMLAbstracts