diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-04-14 18:45:18 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-04-14 18:46:14 +0200 |
| commit | 3593f50aedce5544e7a03e85421ea4b9c1752462 (patch) | |
| tree | e0414af031aa0af0ac20b89d1322bcd729f115d0 | |
| parent | f9e7870b061130265205bcee6098328644790c6a (diff) | |
| download | dotfiles-3593f50aedce5544e7a03e85421ea4b9c1752462.tar.xz | |
Remove debugging prints and simplify source package parsing
| -rwxr-xr-x | .local/bin/zypper-wassup | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/.local/bin/zypper-wassup b/.local/bin/zypper-wassup index 10e4826..6486367 100755 --- 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) |
