Metadata-Version: 2.4
Name: dilicom-parser
Version: 0.2.5
Summary: Bibliothèque souveraine pour parser les fichiers Dilicom déposés sur le serveur SFTP de Dilicom avec connecteur SFTP intégré.
Author-email: Rémi Verschuur <rverschuur@audit-io.fr>
License: # MIT License
        
        Copyright (c) 2026 Audit IO
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/remiv1/dilicom-parser
Project-URL: Repository, https://github.com/remiv1/dilicom-parser
Project-URL: Changelog, https://github.com/remiv1/dilicom-parser/blob/main/CHANGELOG.md
Project-URL: Documentation, https://remiv1.github.io/dilicom-parser/
Keywords: dilicom,livres,édition,ONIX,SFTP,EDI,distribution
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Natural Language :: French
Requires-Python: <3.15,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: paramiko
Requires-Dist: python-dotenv
Dynamic: license-file

# Package de gestion des fichiers Dilicom sur serveur SFTP

![PyPi version](https://img.shields.io/pypi/v/dilicom-parser)
![Licence](https://img.shields.io/badge/license-MIT-blue)
![Python version](https://img.shields.io/pypi/pyversions/dilicom-parser)
![Pandas version](https://img.shields.io/badge/pandas-%3E%3D3.0.2-green)
![Paramiko version](https://img.shields.io/badge/paramiko-%3E%3D4.0.0-green)
![python-dotenv version](https://img.shields.io/badge/python--dotenv-%3E%3D1.2.2-green)

**dilicom-parser** est une bibliothèque Python souveraine dédiée à la lecture, au parsing, à la validation et à la transformation des fichiers Dilicom (distributeurs, commandes, etc.).
Elle fournit des modèles de données stricts, des parseurs robustes et des outils d’audit pour garantir une intégration fiable et reproductible.

## 🚀 Objectifs

- Offrir une **implémentation Python propre et moderne** des structures Dilicom.
- Fournir des **dataclasses typées** pour chaque bloc Dilicom.
- Faciliter l’intégration dans des pipelines d’audit, d’ETL ou de synchronisation.
- Proposer une base souveraine et open-source pour les acteurs du livre.

## ✨ Fonctionnalités

- 📦 Modèles de données Dilicom (Bloc 1, Bloc 2, Bloc 3…)
- 🧩 Parseur robuste basé sur l’ordre contractuel des champs
- 🔍 Validation des types et des valeurs
- 📊 Conversion DataFrame → objets Python
- 🧪 Tests unitaires inclus

## 📄 Exemple d’utilisation

Créer le fichier .env avec les variables d’environnement nécessaires :

```ini
#.env

# Variables pour les dossier d’entrée et de sortie des fichiers
DILICOM_IN_DIR=/path/to/dilicom/files
DILICOM_OUT_DIR=/path/to/output

# Optionnel, variables pour la connexion FTP si nécessaire
DILICOM_HOST=ftp.example.com
DILICOM_PORT=11234
DILICOM_USER=username
DILICOM_SECRET=password
```

Ensuite, utiliser le parser dans votre code Python :

```python
from dotenv import load_dotenv

load_dotenv('path/to/.env')

parser = DistributorParser()
data = parser.parse_file("distributeur.txt")

for line in data.lines:
    print(line.bloc1.rs1)   # Raison sociale principale du distributeur
    print(line.bloc1.ville)  # Ville du distributeur
```

### Dans un notebook Jupyter

```python
from src.dilicom_parser.classifier import FilesClassifier
from pathlib import Path
import ipynbname
path = ipynbname.path()

files_directory = Path(path).parent / "dilicom"
file_list = list(files_directory.glob(pattern="*"))
classifier = FilesClassifier(file_list=file_list)

classifier.classify()

print("Classification terminée. Résultats :")
from pprint import pprint
pprint(classifier.count_by_type())

```

```console
Classification terminée. Résultats :
{'distributor': 9, 'eancom': 5, 'gencod': 4}
```
