Skip to content

Commit

Permalink
Merge pull request #24 from Dessia-tech/ruff_check
Browse files Browse the repository at this point in the history
Ruff: Format/Lint
  • Loading branch information
sbendjebla authored Oct 11, 2024
2 parents 7d17d62 + 5e0e74f commit 4908fd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions methods/methods_check_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions methods/methods_get_parameters_from_ini_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down

0 comments on commit 4908fd5

Please sign in to comment.