Skip to main content

Jazal performs certain verifications on filepaths before a function or a script uses them.

Project description

Jazal

Français

Avant qu'une application utilise le chemin d'un fichier, il peut importer de vérifier s'il a la bonne extension, s'il existe et s'il s'agit d'un dossier ou d'un fichier. À cette fin, la bibliothèque Jazal fournit la classe PathChecker et sa sous-classe ReactivePathChecker. Cette dernière permet en plus d'avertir l'utilisateur que le chemin est invalide et de le remplacer par une valeur correcte. Ces deux classes dépendent de pathlib.Path.

Jazal offre aussi la classe MissingPathArgWarner, qui produit un message explicite si l'utilisateur omet de fournir un argument chemin obligatoire. Si le chemin est donné, cette classe peut instancier PathChecker ou ReactivePathChecker de telle manière que chaque information requise ne soit donnée qu'une seule fois. Si un chemin optionnel est omis, MissingPathArgWarner peut aider à générer une valeur par défaut en fournissant l'extension attendue.

De plus, cette bibliothèque contient des fonctions qui aident à produire des valeurs par défaut pour les chemins manquants ou invalides.

Voir les scripts demo_with_files.py et demo_with_dirs.py pour savoir comment employer Jazal.

Le nom de cette bibliothèque vient de la chanson polonaise Hej, sokoły!. La répétition du mot żal [ʒal] dans les paroles a insprié le nom Jazal.

Tests unitaires de Jazal

Les tests unitaires de cette bibliothèque dépendent du cadriciel pytest. Pour lancer une suite de tests contenue dans le dossier tests, écrivez en ligne de commande une instruction correspondant au modèle suivant.

pytest <file name>.py

Exécutez le script run_all_tests.py pour lancer tous les tests.

python run_all_tests.py

Puisque plusieurs tests utilisent des chemins relatifs menant à un dossier et à un fichier réels, lancez-les depuis le dossier tests pour éviter des exceptions.

English

Before an application uses a path to a file, it may be important to verify whether it has the right extension, whether it exists and whether it points to a directory or a file. For this purpose, library Jazal provides class PathChecker and its subclass ReactivePathChecker. The latter is also able to warn the user about invalid paths and make correct ones. These two classes depend on pathlib.Path.

Jazal also offers class MissingPathArgWarner, which makes an explicit message if the user omits to provide a mandatory path argument. If the path is given, this class can instantiate PathChecker or ReactivePathChecker in such a way that each required information is given only once. If an optional path is omitted, MissingPathArgWarner can help generating a default value by providing the expected extension.

In addition, this library contains functions that help making default values for missing or invalid paths.

See scripts demo_with_files.py and demo_with_dirs.py to know how to use Jazal.

This library's name is based on the Polish song Hej, sokoły!. The repetition of the word żal [ʒal] in the lyrics inspired the name Jazal.

Jazal Unit Tests

This library's unit tests depend on framework pytest. In order to run a test suite contained in directory tests, type an instruction matching the following template in command line.

pytest <file name>.py

Execute script run_all_tests.py to perform all the tests.

python run_all_tests.py

Since several tests use relative paths to an actual directory and an actual file, run them from directory tests to prevent exceptions.

Project details


Download files

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

Source Distribution

jazal-2.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jazal-2.0.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file jazal-2.0.0.tar.gz.

File metadata

  • Download URL: jazal-2.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for jazal-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6ff63cce5fc6aedddaa509d1a3ea32ab4aff5245c6d33877b1b593cbeb210b42
MD5 12f3e6e80dad21e3e78d1a5d1973132b
BLAKE2b-256 fc10c73196cd78989723442665e1cc84b671db31b10227d6d0d019f2844fce34

See more details on using hashes here.

File details

Details for the file jazal-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: jazal-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for jazal-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f0b9c656775de272451e0d32e58567e765defe0ba518d13e762bad3a697779a
MD5 ee2f1f7c00efadb3abcb72b6f68d18d4
BLAKE2b-256 676f0cb8dfa04e9ed4816198b773230041cc953f22fabc25bce0dfe4b73baf5c

See more details on using hashes here.

Supported by

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