Bugzilla – Attachment 872112 Details for
Bug 1219107
Migrate away from update-alternatives (phase 1)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
Python script, V1
script_v1.py (text/x-python), 1.86 KB, created by
Martin Schreiner
on 2024-01-23 21:48:12 UTC
(
hide
)
Description:
Python script, V1
Filename:
MIME Type:
Creator:
Martin Schreiner
Created:
2024-01-23 21:48:12 UTC
Size:
1.86 KB
patch
obsolete
>#!/usr/bin/env python3 > >import sys >import os >import re >import hashlib >from glob import glob > > >def find_alternatives(filenames): > output = {} > > for filename in filenames: > relative_filename = os.path.split(filename)[-1] > > with open(filename) as filehandle: > lines = filehandle.readlines() > for line in lines: > matches = re.findall( > r"(--install|--slave)\s+(\S+)\s+([\w\d\.\-\_\$]+)", line > ) > if len(matches) > 0: > regex_result = matches[0] > key = regex_result[2] > > try: > output[relative_filename].add(key) > except KeyError: > output[relative_filename] = set([key]) > > return output > > >def calculate_entries_hash(entries): > hasher = hashlib.md5() > > for entry in entries: > hasher.update(entry.encode()) > > return hasher.hexdigest() > > >def main(): > if len(sys.argv) != 2: > print("Usage: <directory>") > sys.exit(1) > > directory = sys.argv[1] > if not os.path.isabs(directory): > print("Please specify an absolute directory path.") > sys.exit(1) > > print(f"Target directory: {directory}") > > glob_pattern = f"{directory}/**.spec" > matching_filenames = glob(glob_pattern) > print(f"Found {len(matching_filenames)} matching filenames.") > > # for filename in matching_filenames: > # print(f"Found matching file: {filename}") > > print("-" * 25) > alternatives = find_alternatives(matching_filenames) > > for spec, entries in alternatives.items(): > print(f"Spec file: {spec}") > print(f" Amount of alternatives: {len(entries)}") > print(f" Hash: {calculate_entries_hash(entries)}") > for entry in entries: > print(f" Alternative: {entry}") > > >if __name__ == "__main__": > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 1219107
:
872111
| 872112