Shorten subprocess calls by using its helper functions
This commit is contained in:
parent
21c05e0db9
commit
c1c937f66e
1 changed files with 5 additions and 8 deletions
13
leafdrop
13
leafdrop
|
|
@ -35,8 +35,7 @@ def refresh_cache() -> None:
|
|||
"--refresh",
|
||||
]
|
||||
|
||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE)
|
||||
ret.check_returncode()
|
||||
subprocess.check_call(cmd, stdout=subprocess.DEVNULL)
|
||||
|
||||
|
||||
def clean_cache() -> None:
|
||||
|
|
@ -57,11 +56,10 @@ def get_b2s_mapping() -> dict[str, str]:
|
|||
"--queryformat", "%{name} %{source_name}",
|
||||
]
|
||||
|
||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE)
|
||||
ret.check_returncode()
|
||||
ret = subprocess.check_output(cmd, text=True)
|
||||
|
||||
mapping = {}
|
||||
for line in ret.stdout.decode().strip().splitlines():
|
||||
for line in ret.strip().splitlines():
|
||||
name, source_name = line.split(" ")
|
||||
mapping[name] = source_name
|
||||
|
||||
|
|
@ -114,10 +112,9 @@ def get_requires(package: str) -> tuple[list[str], list[str]]:
|
|||
"--whatrequires", package
|
||||
]
|
||||
|
||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE)
|
||||
ret.check_returncode()
|
||||
ret = subprocess.check_output(cmd, text=True)
|
||||
|
||||
deps: list[str] = ret.stdout.decode().strip().splitlines()
|
||||
deps: list[str] = ret.strip().splitlines()
|
||||
|
||||
requires: list[str] = []
|
||||
build_requires: list[str] = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue