jw.pkg.cmds: Replace split('\n') by splitlines()

splitlines() removes empty lines, so use it and save some lines of
code.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-23 10:36:46 +01:00
commit 595995e084
2 changed files with 2 additions and 6 deletions

View file

@ -26,9 +26,7 @@ async def all_installed_packages() -> Iterable[Package]:
tag_str = '|'.join([f'%{{{tag}}}' for tag in query_tags]) + r'\n'
opts.append(tag_str)
package_list_str, stderr = await run_rpm('-qa', *opts, sudo=False)
for package_str in package_list_str.split('\n'):
if not package_str:
continue
for package_str in package_list_str.splitlines():
tags = package_str.split('|')
ret.append(Package(name=tags[0], vendor=tags[1], packager=tags[2], url=tags[3]))
return ret

View file

@ -31,9 +31,7 @@ class CmdGetAuthInfo(Cmd): # export
return
remotes, stderr = await run_cmd('git', '-C', jw_pkg_dir, 'remote', '-v')
result: dict[str, str] = {}
for line in remotes.split('\n'):
if re.match(r'^\s*$', line):
continue
for line in remotes.splitlines():
name, url, typ = re.split(r'\s+', line)
if name == 'origin' and typ in ['(pull)', '(fetch)']: # TODO: Use other remotes, too?
parsed = urlparse(url)