dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit 3593f50aedce5544e7a03e85421ea4b9c1752462
parent f9e7870b061130265205bcee6098328644790c6a
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Tue, 14 Apr 2020 18:45:18 +0200

Remove debugging prints and simplify source package parsing

Diffstat:
M.local/bin/zypper-wassup | 25++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/.local/bin/zypper-wassup b/.local/bin/zypper-wassup @@ -19,6 +19,15 @@ ZYPPER_PATTERN = re.compile( re.MULTILINE ) +# Using http://ftp.rpm.org/max-rpm/ch-rpm-file-format.html to make a +# few assumptions, e.g. versions can't contain hyphens. +SOURCERPM_PATTERN = re.compile( + r'\.'.join(( + '-'.join(('(?P<name>.+)', '(?P<version>[^-]+)', '(?P<release>[^-]+)')), + '(?:no)?src', + 'rpm' +))) + def execute(command): return run(command, check=True, text=True, capture_output=True).stdout @@ -34,25 +43,15 @@ def zypper_list_updates(): def source_package_name(package): - # Using http://ftp.rpm.org/max-rpm/ch-rpm-file-format.html to make - # a few assumptions, e.g. versions can't contain hyphens. - pattern = r'\.'.join(( - '-'.join(('(?P<name>.+)', '(?P<version>[^-]+)', '(?P<release>[^-]+)')), - r'(?:no)?src', - r'rpm' - )) - match = re.fullmatch(pattern, package) - if match is None: - print(pattern) - print(package) + if (match := SOURCERPM_PATTERN.fullmatch(package)) is None: + raise Exception(f'{package} does not match "{SOURCERPM_PATTERN}".') + return match.group('name') def sort_by_source_package(packages): sorted_packages = defaultdict(list) - print() - for p in packages: source_pkgs = execute( ('rpm', '--query', '--queryformat', r'%{SOURCERPM}\n', p.package)