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:
parent
f0eeb14a97
commit
d9746cd20b
8 changed files with 65 additions and 98 deletions
|
|
@ -11,11 +11,11 @@ if TYPE_CHECKING:
|
|||
import os, sys, json
|
||||
|
||||
from argparse import Namespace
|
||||
from urllib.parse import urlparse
|
||||
from enum import Enum, auto
|
||||
|
||||
from .log import *
|
||||
from .base import InputMode
|
||||
from .Uri import Uri
|
||||
|
||||
class AskpassKey(Enum):
|
||||
Username = auto()
|
||||
|
|
@ -126,7 +126,7 @@ async def copy(src_uri: str, dst_uri: str, owner: str|None=None, group: str|None
|
|||
return dst_path
|
||||
|
||||
async def get_username(args: Namespace|None=None, url: str|None=None, askpass_env: list[str]=[], ec: ExecContext|None=None) -> str: # export
|
||||
url_user = None if url is None else urlparse(url).username
|
||||
url_user = None if url is None else Uri(url).username
|
||||
if args is not None:
|
||||
if args.username is not None:
|
||||
if url_user is not None and url_user != args.username:
|
||||
|
|
@ -144,9 +144,9 @@ async def get_password(args: Namespace|None=None, url: str|None=None, askpass_en
|
|||
if ret is not None:
|
||||
return ret
|
||||
if url is not None:
|
||||
parsed = urlparse(url)
|
||||
if parsed.password is not None:
|
||||
return parsed.password
|
||||
ret = Uri(url).password
|
||||
if ret is not None:
|
||||
return ret
|
||||
return await run_askpass(askpass_env, AskpassKey.Password, ec=ec)
|
||||
|
||||
async def get_profile_env(throw: bool=True, keep: Iterable[str]|bool=False, ec: ExecContext|None=None) -> dict[str, str]: # export
|
||||
|
|
|
|||
Loading…
Reference in a new issue