This release is a pre-release and may not be stable for production use.
forge-mvc-import-export
Échange CSV opt-in pour Forge : import (lire un CSV, valider chaque ligne par
champ, produire un rapport d'erreurs, insérer les lignes valides) et export
programmatique (to_csv, l'inverse de parse_csv).
Dans le style Forge : explicite, validation visible, SQL laissé à l'application.
Frontière (principe 11) : pour télécharger une entité depuis une page
web, la route d'export générée par le CRUD du cœur reste la voie officielle.
to_csv sert l'export programmatique : un script, un rapport, une
agrégation, ou des données qui ne viennent pas d'une entité CRUD.
Installation
pip install --pre forge-mvc-import-export
En développement : pip install -e ./packages/forge-mvc-import-export.
Utilisation
from forge_mvc_import_export import parse_csv, import_rows, FieldSpec, coerce_int
csv_text = open("eleves.csv", encoding="utf-8").read()
rows = parse_csv(csv_text)
specs = [
FieldSpec("nom"), # requis, chaîne
FieldSpec("classe"),
FieldSpec("age", required=False, coerce=coerce_int),
]
# `insert` reçoit une ligne validée ; le SQL reste dans le modèle de l'app.
from mvc.models.eleve_model import add_eleve
report = import_rows(rows, specs, lambda row: add_eleve(row))
print(f"{report.imported} ligne(s) importée(s)")
for err in report.errors:
print(f" ligne {err.row}, champ {err.field} : {err.message}")
Export programmatique
from forge_mvc_import_export import to_csv
rows = [{"nom": "Alice", "classe": "6A"}, {"nom": "Bob", "classe": "6B"}]
csv_text = to_csv(rows, ["nom", "classe"])
# "nom,classe\nAlice,6A\nBob,6B\n"
Comportement
- Import : par défaut « tout ou rien » au niveau validation : si une ligne est
invalide, rien n'est inséré et le rapport liste toutes les erreurs.
L'option
partial=Trueinsère les lignes valides malgré les lignes en erreur. - Convertisseurs fournis :
coerce_int,coerce_float,coerce_bool. - Le cœur de Forge et les entités ne sont pas touchés : la dépendance va de l'opt-in vers le cœur.
Périmètre
V1 : import CSV (validation, rapport d'erreurs) et export programmatique
(to_csv).
Hors périmètre V1 : Excel, JSON, mapping de colonnes avancé, modèles d'import.
Documentation complète : https://forgemvc.com/docs/forge/.
Metadata
Release files for forge-mvc-import-export 1.0.0rc9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| forge_mvc_import_export-1.0.0rc9.tar.gz | 33.2 kB | Without provenance | Details for forge_mvc_import_export-1.0.0rc9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| forge_mvc_import_export-1.0.0rc9-py3-none-any.whl | Python 3 | none | any | Details for forge_mvc_import_export-1.0.0rc9-py3-none-any.whl |
Total release size: 53.5 kB
Release files / forge_mvc_import_export-1.0.0rc9.tar.gz
| Download URL | forge_mvc_import_export-1.0.0rc9.tar.gz |
|---|---|
| Size | 33.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4483fc7256ce9aa0b1d4908b340b0939671b41d92ff642eaeefbbccc656cb8e
|
|
BLAKE2b-256 checksum How to use checksums |
520e367c29d23341336b2f5b1679e2bdf6bd40d67e41a3c6e61b2a0438c345b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / forge_mvc_import_export-1.0.0rc9-py3-none-any.whl
| Download URL | forge_mvc_import_export-1.0.0rc9-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
165dfe1f27f58c158229b486137788d7aab0362d3fe79a02ed242ea7a74af3ce
|
|
BLAKE2b-256 checksum How to use checksums |
916052dfbc9c1fc0da3c618bb876d7dbf69f5093e98145a68f0d26e193f7fd84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for forge-mvc-import-export 1.0.0rc9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.