diff --git a/methods/methods_check_inputs.py b/methods/methods_check_inputs.py index 4586bad..e8a15c1 100644 --- a/methods/methods_check_inputs.py +++ b/methods/methods_check_inputs.py @@ -40,19 +40,20 @@ def validate_url(url: str) -> None: # raise ValueError(f"\nAre you sure about your 'Package URL' = {url} ? " +\ # "The package must be sorted in Dessia Organization (as: gitlab.com/dessia/XX)") - if not ('gitlab' in url.lower() or 'github' in url.lower()): + if not ("gitlab" in url.lower() or "github" in url.lower()): raise ValueError( f"\nAre you sure about your 'Package URL' = {url} ? It is not a Git URL\n" + "If you do not need to use Git, leave an empty cell." ) + def transform_url(url: str) -> str: """Transform the given URL to be used for Gitlab pusing.""" # Remove 'www.' if present - url = url.replace('www.', '', 1) + url = url.replace("www.", "", 1) # Replace the first '/' with ':' - return url.replace('/', ':', 1) + return url.replace("/", ":", 1) def validate_python_version(version: str) -> None: diff --git a/methods/methods_get_parameters_from_ini_file.py b/methods/methods_get_parameters_from_ini_file.py index bc49474..770eeb5 100644 --- a/methods/methods_get_parameters_from_ini_file.py +++ b/methods/methods_get_parameters_from_ini_file.py @@ -4,22 +4,24 @@ from .methods_check_inputs import ( check_pypi_package_name, + transform_url, validate_email, validate_package_name, validate_python_version, validate_required_packages, validate_url, - transform_url ) + def read_config_to_dict(file_path: str) -> dict: + """"Read a configuration file and returns its contents as a dictionary, excluding the 'DOCUMENTATION' section.""" config = configparser.ConfigParser() config.read(file_path) config_dict = {} for section in config.sections(): - if section !="DOCUMENTATION": + if section != "DOCUMENTATION": for key, value in config[section].items(): config_dict[key] = value.strip() @@ -28,7 +30,6 @@ def read_config_to_dict(file_path: str) -> dict: def get_parameters_from_ini_file(ini_file: str) -> dict: """Get the parameters from an ini file.""" - parameters = read_config_to_dict(ini_file) # %% Package name