lib + cmds.projects: Use lib.Uri

Remove the feeble attempts at unifying URI handling, and use class
Uri from lib.Uri instead.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-27 09:37:28 +02:00
commit d9746cd20b
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
8 changed files with 65 additions and 98 deletions

View file

@ -3,26 +3,22 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from urllib.parse import urlparse
from ..FileContext import FileContext as Base
from ..base import Result
if TYPE_CHECKING:
from ..ExecContext import ExecContext
from ..Uri import Uri
class Curl(Base):
def __init__(self, uri: str, *args, ec: ExecContext|None=None, **kwargs) -> None:
def __init__(self, uri: str|Uri, *args, ec: ExecContext|None=None, **kwargs) -> None:
super().__init__(uri=uri, *args, **kwargs)
self.__ec: ExecContext|None = ec
if ec is None:
from .Local import Local
self.__ec = Local(interactive=False, *args, **kwargs)
p = urlparse(uri)
self.__base_url = f'{p.scheme}://{p.hostname}'
if p.port is not None:
self.__base_url += f':{p.port}'
async def _get(
self,
@ -42,5 +38,5 @@ class Curl(Base):
path = wd + '/' + path
if not len(path) or path[0] != '/':
path = '/' + path
cmd.append(self.__base_url + path)
cmd.append(self.url.to_string + self._chroot(path))
return await self.__ec.run(cmd, throw=throw, verbose=verbose)