diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /toolkit/crashreporter/generate_crash_reporter_sources.py | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/crashreporter/generate_crash_reporter_sources.py')
-rw-r--r-- | toolkit/crashreporter/generate_crash_reporter_sources.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/toolkit/crashreporter/generate_crash_reporter_sources.py b/toolkit/crashreporter/generate_crash_reporter_sources.py index b8c3333557..3b75e43bce 100644 --- a/toolkit/crashreporter/generate_crash_reporter_sources.py +++ b/toolkit/crashreporter/generate_crash_reporter_sources.py @@ -18,10 +18,16 @@ template_header = ( ) +def sort_annotations(annotations): + """Return annotations in ascending alphabetical order ignoring case""" + + return sorted(annotations.items(), key=lambda annotation: str.lower(annotation[0])) + + def validate_annotations(annotations): """Ensure that the annotations have all the required fields""" - for name, data in sorted(annotations.items()): + for name, data in annotations: if "description" not in data: print("Annotation " + name + " does not have a description\n") sys.exit(1) @@ -48,7 +54,7 @@ def read_annotations(annotations_filename): try: with open(annotations_filename, "r") as annotations_file: - annotations = yaml.safe_load(annotations_file) + annotations = sort_annotations(yaml.safe_load(annotations_file)) except (IOError, ValueError) as e: print("Error parsing " + annotations_filename + ":\n" + str(e) + "\n") sys.exit(1) @@ -76,9 +82,7 @@ def extract_crash_ping_allowedlist(annotations): """Extract an array holding the names of the annotations allowed for inclusion in the crash ping.""" - return [ - name for (name, data) in sorted(annotations.items()) if data.get("ping", False) - ] + return [name for (name, data) in annotations if data.get("ping", False)] def extract_skiplist(annotations): @@ -87,7 +91,7 @@ def extract_skiplist(annotations): return [ (name, data.get("skip_if")) - for (name, data) in sorted(annotations.items()) + for (name, data) in annotations if len(data.get("skip_if", "")) > 0 ] @@ -110,7 +114,7 @@ def type_to_enum(annotation_type): def extract_types(annotations): """Extract an array holding the type of each annotation.""" - return [type_to_enum(data.get("type")) for (_, data) in sorted(annotations.items())] + return [type_to_enum(data.get("type")) for (_, data) in annotations] ############################################################################### @@ -121,10 +125,7 @@ def extract_types(annotations): def generate_strings(annotations): """Generate strings corresponding to every annotation.""" - names = [ - ' "' + data.get("altname", name) + '"' - for (name, data) in sorted(annotations.items()) - ] + names = [' "' + data.get("altname", name) + '"' for (name, data) in annotations] return ",\n".join(names) @@ -135,7 +136,7 @@ def generate_enum(annotations): enum = "" - for i, (name, _) in enumerate(sorted(annotations.items())): + for i, (name, _) in enumerate(annotations): enum += " " + name + " = " + str(i) + ",\n" enum += " Count = " + str(len(annotations)) |