-
Notifications
You must be signed in to change notification settings - Fork 23
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: xml validation #660
base: master
Are you sure you want to change the base?
Feat: xml validation #660
Conversation
Havia problema da leitura das listas por conta da utilização de "-" e "." na composição dos nomes
packtools/xml_validation.py
Outdated
def get_data(filename, key, sps_version=None): | ||
sps_version = sps_version or "default" | ||
# Reads contents with UTF-8 encoding and returns str. | ||
content = files(f'packtools.sps.sps_versions.{sps_version}').joinpath(f"{filename}.json").read_text() |
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.
def get_data(filename, key, sps_version=None):
sps_version = sps_version or "default"
# Reads contents with UTF-8 encoding and returns str.
content = (
files(f"packtools.sps.sps_versions")
.joinpath(f"{sps_version}")
.joinpath(f"{filename}.json")
.read_text()
)
x = " ".join(content.split())
fixed = x.replace(", ]", "]").replace(", }", "}")
data = json.loads(fixed)
return data[key]
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.
OK, @robertatakenaka
@@ -0,0 +1,41 @@ | |||
{ |
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 move todos os json de volta para sps-1.9 e sps-1.10
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.
OK, @robertatakenaka
parent_id=None, | ||
parent_article_type=self.xmltree.get("article-type"), | ||
parent_lang=self.xmltree.get("{http://www.w3.org/XML/1998/namespace}lang"), | ||
item="journal-meta", |
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.
item="journal-id"
sub-item="@journal-id-type='publisher-id'"
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.
OK, @robertatakenaka
@@ -359,7 +364,7 @@ def validate(self, expected_values): | |||
nlm_ta = JournalIdValidation(self.xmltree) | |||
|
|||
resp_journal_meta = list(issn.validate_issn(expected_values['issns'])) + \ | |||
acronym.acronym_validation(expected_values['acronym']) + \ | |||
list(acronym.acronym_validation(expected_values['acronym'])) + \ |
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 trocar este trecho por yield ou yield from. Talvez até eliminaria este método
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.
OK, @robertatakenaka
packtools/xml_validation.py
Outdated
sps_version = sps_version.replace("-", "_") | ||
sps_version = sps_version.replace(".", "_") |
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;
sps_version = sps_version.replace("-", "_")
sps_version = sps_version.replace(".", "_")
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.
OK, @robertatakenaka
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 verificar os comentários
O que esse PR faz?
Este Pull Request adiciona funcionalidades para a validação de arquivos XML e a geração de relatórios em formato CSV. Especificamente, ele inclui:
get_xml_tree
: Lê o conteúdo de um arquivo XML e retorna sua árvore XML.get_data
: Recupera dados de arquivos JSON, utilizados como referência para validações.create_report
: Cria um relatório de validação em CSV a partir de um arquivo XML.save_csv
: Salva os resultados da validação em um arquivo CSV.validate_xml_content
: Executa várias validações em um arquivo XML, agrupando-as por categorias como atributos do artigo, idiomas, tipos de artigo, etc.Essas adições facilitam a verificação e análise de arquivos XML de acordo com critérios pré-definidos, melhorando a qualidade e conformidade dos dados processados.
Onde a revisão poderia começar?
Por commit.
Como este poderia ser testado manualmente?
Execução:
Execute o script com o seguintes comando:
python3 packtools/xml_validation.py -i packtools/xml_validation/xmls/ -o packtools/xml_validation/reports/
Verificação:
Verifique os arquivos CSV gerados na pasta de saída para garantir que os resultados das validações estão corretos e completos.
Exemplo do CSV gerado:
Screenshots
NA
Quais são tickets relevantes?
NA
Referências
NA