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

View file

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