diff --git a/anonyfiles_cli/handlers/anonymize_handler.py b/anonyfiles_cli/handlers/anonymize_handler.py index 9a05079..2c46244 100644 --- a/anonyfiles_cli/handlers/anonymize_handler.py +++ b/anonyfiles_cli/handlers/anonymize_handler.py @@ -48,8 +48,26 @@ def process( append_timestamp: bool, force: bool, ): - """ - Traite l'anonymisation d'un fichier en orchestrant les différentes étapes. + """Launch anonymization for ``input_file``. + + Args: + input_file (Path): File to anonymize. + config_path (Optional[Path]): Path to a configuration file. + output (Optional[Path]): Destination for anonymized output. + log_entities (Optional[Path]): CSV file for detected entities. + mapping_output (Optional[Path]): CSV mapping between originals and replacements. + bundle_output (Optional[Path]): Path for the bundle archive. + output_dir (Path): Base output directory for generated files. + dry_run (bool): If ``True`` run without writing files. + csv_no_header (bool): Indicates CSV input has no header row. + has_header_opt (Optional[str]): Explicit CSV header flag ("true"/"false"). + exclude_entities (Optional[List[str]]): Entities to exclude from anonymization. + custom_replacements_json (Optional[str]): JSON with custom replacement rules. + append_timestamp (bool): Append run timestamp to file names. + force (bool): Overwrite existing files without confirmation. + + Returns: + bool: ``True`` on success, ``False`` otherwise. """ run_id = timestamp() self.console.console.print(f"📂 Anonymisation du fichier : [bold cyan]{input_file.name}[/bold cyan]") diff --git a/anonyfiles_cli/handlers/batch_handler.py b/anonyfiles_cli/handlers/batch_handler.py index 02a9731..ec92b9b 100644 --- a/anonyfiles_cli/handlers/batch_handler.py +++ b/anonyfiles_cli/handlers/batch_handler.py @@ -35,12 +35,23 @@ def process_directory( config: Optional[Path], dry_run: bool, recursive: bool, - # Passer les options CSV si le batch doit les gérer uniformément - csv_no_header: bool, + csv_no_header: bool, # Passer les options CSV si le batch doit les gérer uniformément has_header_opt: Optional[str], ): - """ - Traite un répertoire de fichiers en lot. + """Run anonymization on all files within ``input_dir``. + + Args: + input_dir (Path): Directory containing files to anonymize. + pattern (str): Glob pattern used to select files. + output_dir (Optional[Path]): Directory for anonymized files. + config (Optional[Path]): Configuration file applied to all files. + dry_run (bool): If ``True`` simulate anonymization without writing files. + recursive (bool): Search ``input_dir`` recursively. + csv_no_header (bool): Indicates CSV inputs have no header row. + has_header_opt (Optional[str]): Explicit CSV header flag ("true"/"false"). + + Returns: + None """ if not input_dir.exists() or not input_dir.is_dir(): self.console.console.print( diff --git a/anonyfiles_cli/handlers/deanonymize_handler.py b/anonyfiles_cli/handlers/deanonymize_handler.py index 8f8a058..1d26367 100644 --- a/anonyfiles_cli/handlers/deanonymize_handler.py +++ b/anonyfiles_cli/handlers/deanonymize_handler.py @@ -22,15 +22,27 @@ class DeanonymizeHandler: def __init__(self, console: ConsoleDisplay): self.console = console - def process(self, - input_file: Path, - mapping_csv: Path, - output: Optional[Path], - report: Optional[Path], - dry_run: bool, - permissive: bool): - """ - Traite la désanonymisation d'un fichier en orchestrant les différentes étapes. + def process( + self, + input_file: Path, + mapping_csv: Path, + output: Optional[Path], + report: Optional[Path], + dry_run: bool, + permissive: bool, + ): + """Restore anonymized text using ``mapping_csv``. + + Args: + input_file (Path): Text file containing anonymized data. + mapping_csv (Path): CSV mapping produced during anonymization. + output (Optional[Path]): Destination file for restored text. + report (Optional[Path]): JSON report output path. + dry_run (bool): If ``True`` simulate the process without writing files. + permissive (bool): Disable strict validation of mapping coverage. + + Returns: + bool: ``True`` on success, ``False`` otherwise. """ run_id = timestamp() # Générez le run_id ici pour la désanonymisation aussi self.console.console.print(f"🔁 Désanonymisation du fichier : [bold cyan]{input_file.name}[/bold cyan]") diff --git a/anonyfiles_cli/handlers/validation_handler.py b/anonyfiles_cli/handlers/validation_handler.py index f854274..8acfb61 100644 --- a/anonyfiles_cli/handlers/validation_handler.py +++ b/anonyfiles_cli/handlers/validation_handler.py @@ -17,9 +17,17 @@ def validate_anonymize_inputs(cls, custom_replacements_json: Optional[str], csv_no_header: bool, has_header_opt: Optional[str]): - """ - Valide les entrées communes à la commande d'anonymisation. - Lève ConfigurationError en cas de problème. + """Validate inputs for anonymization. + + Args: + input_file (Path): File provided to the command. + output (Optional[Path]): Optional destination file for anonymized output. + custom_replacements_json (Optional[str]): JSON string containing custom replacement rules. + csv_no_header (bool): Indicates CSV input has no header row. + has_header_opt (Optional[str]): Explicit CSV header flag ("true"/"false"). + + Raises: + ConfigurationError: If an option is invalid or files are missing. """ cls._validate_file_extension(input_file) cls._validate_csv_options(input_file, csv_no_header, has_header_opt) @@ -29,8 +37,14 @@ def validate_anonymize_inputs(cls, def validate_deanonymize_inputs(cls, input_file: Path, mapping_csv: Path): - """ - Valide les entrées communes à la commande de désanonymisation. + """Validate inputs for deanonymization. + + Args: + input_file (Path): Anonymized file to restore. + mapping_csv (Path): Mapping file generated during anonymization. + + Raises: + ConfigurationError: If the files are missing or invalid. """ if not input_file.exists() or not input_file.is_file(): raise ConfigurationError(f"Le fichier d'entrée '{input_file}' est introuvable ou n'est pas un fichier.")