Skip to content

Commit

Permalink
Use yarl.URL to work with addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmpr committed Jan 22, 2024
1 parent c7f3ad3 commit 5881970
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "kataloger"
version = "0.1.0"
dependencies = [
"aiohttp",
"yarl",
"xmltodict",
]
authors = [
Expand Down
4 changes: 3 additions & 1 deletion src/kataloger/data/repository.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from dataclasses import dataclass
from typing import Optional

from yarl import URL


@dataclass(frozen=True)
class Repository:
name: str
address: str
address: URL
user: Optional[str] = None
password: Optional[str] = None

Expand Down
6 changes: 4 additions & 2 deletions src/kataloger/helpers/toml_parse_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import tomllib
from pathlib import Path

from yarl import URL

from kataloger.data.artifact.library import Library
from kataloger.data.artifact.plugin import Plugin
from kataloger.data.repository import Repository
Expand Down Expand Up @@ -35,11 +37,11 @@ def parse_repositories(repositories_data: list[tuple]) -> list[Repository]:
for repository_data in repositories_data:
match repository_data:
case (str(name), str(address)):
repository = Repository(name, address)
repository = Repository(name, URL(address))
case (str(name), {"address": str(address), "user": str(user), "password": str(password)}):
repository = Repository(
name=name,
address=address,
address=URL(address),
user=user,
password=password,
)
Expand Down
2 changes: 1 addition & 1 deletion src/kataloger/helpers/update_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def get_artifact_metadata(
artifact: Artifact,
verbose: bool,
) -> Optional[MetadataRepositoryInfo]:
metadata_url = f"{repository.address}{artifact.to_path()}/maven-metadata.xml"
metadata_url = repository.address / artifact.to_path() / "maven-metadata.xml"
async with session.get(metadata_url) as response:
if response.status != 200:
return None
Expand Down

0 comments on commit 5881970

Please sign in to comment.