-
Notifications
You must be signed in to change notification settings - Fork 24
Adicionar argumentos advice_text e advice_params em build_response #1080
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
Changes from all commits
aa10696
3f58816
64b0b6b
a31aab8
31da010
83a4e62
e02d81e
1c6e91f
f5a8b4b
da86fed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |||||
| ValidationArticleAndSubArticlesSubjectsException, | ||||||
| ) | ||||||
| from packtools.sps.validation.similarity_utils import most_similar, similarity | ||||||
| from packtools.sps.validation.utils import build_response, format_response | ||||||
| from packtools.sps.validation.utils import build_response | ||||||
|
|
||||||
|
|
||||||
| class ArticleLangValidation: | ||||||
|
|
@@ -93,17 +93,23 @@ def validate_language(self): | |||||
| if article_lang: | ||||||
| xml = f'<{parent}{parent_id} xml:lang="{article_lang}">' | ||||||
| advice = f'Replace {article_lang} in {xml} with one of {language_codes_list}' | ||||||
| advice_text = 'Replace {lang} in {xml} with one of {lang_list}' | ||||||
| advice_params = {"lang": article_lang, "xml": xml, "lang_list": str(language_codes_list)} | ||||||
| else: | ||||||
| xml = f'<{parent}{parent_id}>' | ||||||
| xml2 = f'<{parent}{parent_id} xml:lang="VALUE">' | ||||||
|
|
||||||
| advice = f'Add xml:lang="VALUE" in {xml}: {xml2} and replace VALUE with one of {language_codes_list}' | ||||||
| yield format_response( | ||||||
| advice_text = 'Add xml:lang="VALUE" in {xml}: {xml2} and replace VALUE with one of {lang_list}' | ||||||
| advice_params = {"xml": xml, "xml2": xml2, "lang_list": str(language_codes_list)} | ||||||
| yield build_response( | ||||||
| title=f"{name} language", | ||||||
| parent=parent, | ||||||
| parent_id=article_id, | ||||||
| parent_article_type=article_type, | ||||||
| parent_lang=article_lang, | ||||||
| parent={ | ||||||
| "parent": parent, | ||||||
| "parent_id": article_id, | ||||||
| "parent_article_type": article_type, | ||||||
| "parent_lang": article_lang, | ||||||
| }, | ||||||
| item=parent, | ||||||
| sub_item="@xml:lang", | ||||||
| validation_type="value in list", | ||||||
|
|
@@ -113,6 +119,8 @@ def validate_language(self): | |||||
| advice=advice, | ||||||
| data=article, | ||||||
| error_level=self.params["language_error_level"], | ||||||
| advice_text=advice_text, | ||||||
| advice_params=advice_params, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -163,12 +171,16 @@ def validate_article_type(self): | |||||
| name = article_id or parent | ||||||
| xml = f'<{parent} article-type=""/>' | ||||||
| advice = None if valid else f'Complete {name} article-type {xml} with valid value {article_type_list}' | ||||||
| yield format_response( | ||||||
| advice_text = None if valid else 'Complete {name} article-type {xml} with valid value {type_list}' | ||||||
| advice_params = {} if valid else {"name": name, "xml": xml, "type_list": str(article_type_list)} | ||||||
| yield build_response( | ||||||
| title=f"{name} article-type", | ||||||
| parent=parent, | ||||||
| parent_id=article_id, | ||||||
| parent_article_type=article_type, | ||||||
| parent_lang=article_type, | ||||||
| parent={ | ||||||
| "parent": parent, | ||||||
| "parent_id": article_id, | ||||||
| "parent_article_type": article_type, | ||||||
| "parent_lang": article_type, | ||||||
| }, | ||||||
| item=parent, | ||||||
| sub_item="article-type", | ||||||
| validation_type="value in list", | ||||||
|
|
@@ -178,6 +190,8 @@ def validate_article_type(self): | |||||
| advice=advice, | ||||||
| data=article, | ||||||
| error_level=self.params["article_type_error_level"], | ||||||
| advice_text=advice_text, | ||||||
| advice_params=advice_params, | ||||||
| ) | ||||||
|
|
||||||
| def validate_article_type_vs_subject_similarity(self): | ||||||
|
|
@@ -230,16 +244,28 @@ def validate_article_type_vs_subject_similarity(self): | |||||
| title = f"article type and table of contents section" | ||||||
| choices = " | ".join(most_similar_article_type) | ||||||
| advice = None | ||||||
| advice_text = None | ||||||
| advice_params = {} | ||||||
| if not valid: | ||||||
| advice = ( | ||||||
| f"Check {xml_article_type} and {xml_subject}. Other values for article-type seems to be more suitable: {choices}. " | ||||||
| ) | ||||||
| yield format_response( | ||||||
| advice_text = ( | ||||||
| "Check {xml_article_type} and {xml_subject}. Other values for article-type seems to be more suitable: {choices}. " | ||||||
| ) | ||||||
|
Comment on lines
+253
to
+255
|
||||||
| advice_params = { | ||||||
| "xml_article_type": xml_article_type, | ||||||
| "xml_subject": xml_subject, | ||||||
| "choices": choices | ||||||
| } | ||||||
| yield build_response( | ||||||
| title=title, | ||||||
| parent="article", | ||||||
| parent_article_type=self.articles.main_article_type, | ||||||
| parent_lang=self.articles.main_lang, | ||||||
| parent_id=None, | ||||||
| parent={ | ||||||
| "parent": "article", | ||||||
| "parent_id": None, | ||||||
| "parent_article_type": self.articles.main_article_type, | ||||||
| "parent_lang": self.articles.main_lang, | ||||||
| }, | ||||||
| item="article", | ||||||
| sub_item="@article-type", | ||||||
| validation_type="similarity", | ||||||
|
|
@@ -249,6 +275,8 @@ def validate_article_type_vs_subject_similarity(self): | |||||
| advice=advice, | ||||||
| data=data, | ||||||
| error_level=self.params["article_type_and_subject_expected_similarity_error_level"], | ||||||
| advice_text=advice_text, | ||||||
| advice_params=advice_params, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -339,12 +367,18 @@ def validate(self): | |||||
| expected_jats_versions = versions.get(sps_version) or [] | ||||||
|
|
||||||
| advice = None | ||||||
| advice_text = None | ||||||
| advice_params = {} | ||||||
| if not versions: | ||||||
| advice = f'Complete SPS version <article specific-use=""/> with valid value: {list(versions.keys())}', | ||||||
|
||||||
| advice = f'Complete SPS version <article specific-use=""/> with valid value: {list(versions.keys())}', | |
| advice = f'Complete SPS version <article specific-use=""/> with valid value: {list(versions.keys())}' |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |||||||||||||||||
| ValidationLicenseException, | ||||||||||||||||||
| ValidationLicenseCodeException | ||||||||||||||||||
| ) | ||||||||||||||||||
| from packtools.sps.validation.utils import format_response | ||||||||||||||||||
| from packtools.sps.validation.utils import build_response | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class ArticleLicenseValidation: | ||||||||||||||||||
|
|
@@ -123,12 +123,14 @@ def validate_license(self, expected_value, error_level="ERROR"): | |||||||||||||||||
| is_valid = expected_license_p == obtained_license_p | ||||||||||||||||||
| expected_value_msg = expected_value.get( | ||||||||||||||||||
| lang) if is_valid else 'License data that matches the language {}'.format(lang) | ||||||||||||||||||
| yield format_response( | ||||||||||||||||||
| yield build_response( | ||||||||||||||||||
| title='Article license validation', | ||||||||||||||||||
| parent=data.get("parent"), | ||||||||||||||||||
| parent_id=data.get("parent_id"), | ||||||||||||||||||
| parent_article_type=data.get("parent_article_type"), | ||||||||||||||||||
| parent_lang=data.get("parent_lang"), | ||||||||||||||||||
| parent={ | ||||||||||||||||||
| "parent": data.get("parent"), | ||||||||||||||||||
| "parent_id": data.get("parent_id"), | ||||||||||||||||||
| "parent_article_type": data.get("parent_article_type"), | ||||||||||||||||||
| "parent_lang": data.get("parent_lang"), | ||||||||||||||||||
| }, | ||||||||||||||||||
| item="permissions", | ||||||||||||||||||
| sub_item="license", | ||||||||||||||||||
| validation_type="value", | ||||||||||||||||||
|
|
@@ -141,6 +143,11 @@ def validate_license(self, expected_value, error_level="ERROR"): | |||||||||||||||||
| f'<license-p>{expected_license_p["license_p"]}</license-p></license>', | ||||||||||||||||||
| data=obtained_license_p, | ||||||||||||||||||
| error_level=error_level, | ||||||||||||||||||
| advice_text=f'Mark license information with ' | ||||||||||||||||||
| f'<license license-type="open-access" xlink:href={{link}} ' | ||||||||||||||||||
| f'xml:lang={{lang}}>' | ||||||||||||||||||
| f'<license-p>{{license_p}}</license-p></license>', | ||||||||||||||||||
|
Comment on lines
+146
to
+149
|
||||||||||||||||||
| advice_text=f'Mark license information with ' | |
| f'<license license-type="open-access" xlink:href={{link}} ' | |
| f'xml:lang={{lang}}>' | |
| f'<license-p>{{license_p}}</license-p></license>', | |
| advice_text='Mark license information with ' | |
| '<license license-type="open-access" xlink:href={link} ' | |
| 'xml:lang={lang}>' | |
| '<license-p>{license_p}</license-p></license>', |
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.
Em
parent, o campoparent_langestá recebendoarticle_type, que não é um código de idioma. Isso tende a corromper o contexto de idioma do response (e.g., seleção de mensagem traduzida, filtros porlang). Ajuste para passar o idioma (provavelmentearticle_lang/main_langou equivalente já disponível no escopo) em vez dearticle_type.