Skip to main content

Handle SPS packages like a breeze.

Project description

scielo.packtools
================

Canivete suiço para a inspeção de pacotes SPS.


Instalação
----------

Python Package Index (recomendado):

```bash
pip install packtools
```

Pip + git (versão de desenvolvimento):

```bash
pip install -e git+git://github.com/scieloorg/packtools.git#egg=packtools
```

Repositório de códigos (versão de desenvolvimento):

```bash
git clone https://github.com/scieloorg/packtools.git
cd packtools
python setup.py install
```


Configuração do Catálogo XML
----------------------------

Um Catálogo XML é um mecanismo de *lookup* que pode ser utilizado para evitar que requisições de
rede sejam realizadas para carregar DTDs externas.

Por questões de desempenho e segurança, as instâncias de `stylechecker.XML` não realizam
conexões de rede, portanto é extremamente recomendável que seja configurado um Catálogo XML,
que traduz ids públicos para uris de arquivos locais.

O `packtools` já apresenta um catálogo padrão, que para ser utilizado basta definir a
variável de ambiente `XML_CATALOG_FILES` com o caminho absoluto para
`packtools/catalogs/scielo-publishing-schema.xml`.

Mais informações em http://xmlsoft.org/catalog.html#Simple


Utilitário `stylechecker`
-------------------------

Após a instalação, o programa `stylechecker` deverá estar disponível no seu emulador de terminal.
Esse programa realiza a validação de um determinado XML no formato SPS contra a DTD, e
apresenta uma lista dos erros encontrados. Também é possível *anotar* os erros encontrados em uma
cópia do XML em validação, por meio do argumento opcional `--annotated`.

O utilitário `stylechecker` tenta carregar a DTD externa, especificada na declaração DOCTYPE do
XML. Para evitar esse comportamento, utilize a opção `--nonetwork`.

A função *ajuda* pode ser utilizada com a opção `-h`, conforme o exemplo:

```bash
$ stylechecker -h
usage: stylechecker [-h] [--annotated] [--nonetwork] [--assetsdir ASSETSDIR]
[--version]
XML [XML ...]

stylechecker cli utility

positional arguments:
XML filesystem path or URL to the XML

optional arguments:
-h, --help show this help message and exit
--annotated reproduces the XML with notes at elements that have
errors
--nonetwork prevents the retrieval of the DTD through the network
--assetsdir ASSETSDIR
lookup, at the given directory, for each asset
referenced by the XML
--version show program's version number and exit
```


Exemplo do resultado da validação:

```bash
$ stylechecker 0034-8910-rsp-48-2-0206.xml
[
{
"_xml": "0034-8910-rsp-48-2-0206.xml",
"dtd_errors": [
"Value \"foo\" for attribute ref-type of xref is not among the enumerated set"
],
"is_valid": false,
"sps_errors": [
"Element 'abstract': Unexpected attribute xml:lang.",
"Element 'article-title': Unexpected attribute xml:lang.",
"Element 'counts': Missing element or wrong value in equation-count.",
"Element 'xref', attribute ref-type: Invalid value \"foo\".",
"Element 'person-group': Missing attribute person-group-type.",
"Element 'fn': Missing attribute fn-type.",
"Element 'article': Missing SPS version at the attribute specific-use."
]
}
]
```



History
=======

0.6.3 (2015-02-02)
------------------

* stylechecker CLI utility overhaul:
* The basic output is now presented as JSON structure.
* The option *--assetsdir* lookups, in the given dir, for each asset referenced in
XML. The *--annotated* option now writes the output to a file. The
utility now takes more than one XML a time.
* *pygments*, if installed, will be used to display pretty JSON outputs.


0.6.2 (2015-01-23)
------------------

* Added method `XMLValidator.lookup_assets`.
* Added property `XMLValidator.assets`.
* Fixed minor issue that would cause //element-citation[@publication-type="report"]
to be reported as invalid.
* Fixed minor issue that would erroneously identify an element-citation element
as not being child of element ref.


0.6.1 (2014-11-28)
------------------

* Minor fix to implement changes from SciELO PS 1.1.1.


0.6 (2014-10-28)
----------------

* Python 3 support.
* Project-wide code refactoring.
* `packtools.__version__` attribute to get the package version.
* Distinction between classes of error with the attribute `StyleError.level`.


0.5 (2014-09-29)
----------------

* Basic implementation of XML style rules according to SciELO PS version 1.1.
* `stylechecker` and `packbuilder` console utilities.
* Major performance improvements on `XMLValidator` instantiation, when used
with long-running processes (9.5x).

Project details


Release history Release notifications | RSS feed

This version

0.6.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

packtools-0.6.3.tar.gz (402.8 kB view details)

Uploaded Source

Built Distribution

packtools-0.6.3-py2.py3-none-any.whl (567.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file packtools-0.6.3.tar.gz.

File metadata

  • Download URL: packtools-0.6.3.tar.gz
  • Upload date:
  • Size: 402.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for packtools-0.6.3.tar.gz
Algorithm Hash digest
SHA256 8bb179425f31e064fae2bd3d805fd3671c18fd2a6498f7051a3060aacad843f7
MD5 ae2d9f6b04b3938bfa28712333043ab9
BLAKE2b-256 7a785adeace6f75bc8c9933237f100fb48562397c694bad5556c9d291164ab20

See more details on using hashes here.

File details

Details for the file packtools-0.6.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for packtools-0.6.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f10682e0e0b8d4b4d6fe03fe6de68750515771e1143a6858fa26bb04bd667fc7
MD5 97e749b0760646dfc65ed30cb17439f9
BLAKE2b-256 aecc9bee3671636fa1f98cadf4173c24caef962a7ea3f92e7b51f28046a9de32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page