jw-pkg/src/python/jw/pkg/lib/ec/Curl.py
Jan Lindemann 5d77955ed9
py-check.mk: Run isort with "make format"
If /usr/bin/isort is found, run it during "make format" to get a
defined way the imports are sorted. tool.isort in pyproject.toml is
updated to match the other fixers.

Commit the fallout of this change. Running the other fixers alone
doesn't change the formatting, so this should be safe.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-11 16:45:14 +02:00

50 lines
1.4 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING, Any, override
from ..FileContext import FileContext as Base
if TYPE_CHECKING:
from ..base import Result
from ..ExecContext import ExecContext
from ..Uri import Uri
from .Local import Local
class Curl(Base):
def __init__(
self,
uri: str | Uri,
*args: Any,
ec: ExecContext | None = None,
**kwargs: Any
) -> None:
def __local() -> Local:
from .Local import Local
return Local(interactive = False, *args, **kwargs)
# MyPy complains for reasons I don't understand:
# E: "__init__" of "FileContext" gets multiple values for keyword # argument
# "uri" [misc]
super().__init__(uri = uri, *args, **kwargs) # type: ignore[misc]
self.__ec = ec if ec else __local()
@override
async def _get(
self, path: str, wd: str | None, throw: bool, verbose: bool | None, title: str
) -> Result:
cmd = ['curl']
if verbose is None:
verbose = self.__ec.verbose_default
if not verbose:
cmd.append('-s')
cmd.append('--follow')
if wd is not None:
path = wd + '/' + path
if not len(path) or path[0] != '/':
path = '/' + path
cmd.append(self.uri.to_string + self._chroot(path))
return await self.__ec.run(cmd, throw = throw, verbose = verbose)