From cb2f4d33522091c49e60e7db314c04a86c57d427 Mon Sep 17 00:00:00 2001 From: Ben Arbia Sarra <123973393+Sarrabah@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:43:26 +0100 Subject: [PATCH] Docs: Update README (#25) # Goal * The aim of this PR is to update the README file with new parameters, providing more clarity and precision in the validation process. --------- Co-authored-by: Pierre Camilleri <22995923+pierrecamilleri@users.noreply.github.com> --- README.md | 13 ++++++++++--- src/frformat/options.py | 43 +++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index cf3ff68..980749c 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,21 @@ The package is published on PyPI. Install with : ## Usage ```python -from frformat import Departement +from frformat import Departement, Options, Millesime print(Departement.description()) -Departement.is_valid("Haute-Vienne") + +_options = Options( + ignore_case=True, + ignore_accents=True, + ignore_extra_whitespace=True +) +Departement(Millesime.LATEST, _options).is_valid("haute-vienne") # True -Departement.is_valid("Canyon Cosmo") +Departement(Millesime.M2023, _options).is_valid("Canyon Cosmo") # False ``` +For more details, consult the [Options](./src/frformat/options.py) data class. For better performance on big amounts of data, use in conjunction with numpy. diff --git a/src/frformat/options.py b/src/frformat/options.py index 835046a..e006436 100644 --- a/src/frformat/options.py +++ b/src/frformat/options.py @@ -5,34 +5,27 @@ @dataclass class Options: """ - The class Options is used to represent a list of options to validate a French format. - - Attributes: - ignore_case: Boolean - Indicates if case should be ignored. - When set to True, all characters in the string will be converted to lowercase. - - ignore_accents: Boolean - Indicates if accents should be ignored. - When set to True, characters with accents will be replaced with their non-accented counterparts. - Example: 'à' will be replaced by 'a'. - - replace_non_alphanumeric_with_space: Boolean - Indicates if non-alphanumeric characters should be ignored. - When set to True, punctuation marks and symbols will be replaced by a space. - - ignore_extra_whitespace: Boolean - Indicates if extra white space should be ignored. - When set to True, multiple consecutive spaces will be treated as a single space, and leading or trailing spaces will be removed. - - extra_valid_values: Frozenset of string - A collection of additional valid values. - This set includes any extra values that should be considered valid during the validation process, beyond the original set of valid values. - This allows for customized validation rules to accommodate special cases or exceptions. + The class Options is used to represent a list of options to validate a French format. """ ignore_case: bool = False + """ Indicates if case should be ignored. + When set to True, all characters in the string will be converted to lowercase.""" + ignore_accents: bool = False + """ Indicates if accents should be ignored. + When set to True, characters with accents will be replaced with their non-accented counterparts. + Example: 'à' will be replaced by 'a'.""" + replace_non_alphanumeric_with_space: bool = False + """ Indicates if non-alphanumeric characters should be ignored. + When set to True, punctuation marks and symbols will be replaced by a space.""" + ignore_extra_whitespace: bool = False - extra_valid_values: FrozenSet = frozenset() + """Indicates if extra white space should be ignored. + When set to True, multiple consecutive spaces will be treated as a single space, and leading or trailing spaces will be removed.""" + + extra_valid_values: FrozenSet[str] = frozenset() + """A collection of additional valid values. + This set includes any extra values that should be considered valid during the validation process, beyond the original set of valid values. + This allows for customized validation rules to accommodate special cases or exceptions."""