From 6708094ed6bfc61472f9660a714cbea26c3df672 Mon Sep 17 00:00:00 2001 From: IanCa Date: Wed, 29 Mar 2023 19:06:01 -0500 Subject: [PATCH] Fix sorting for hed string context --- hed/errors/error_reporter.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hed/errors/error_reporter.py b/hed/errors/error_reporter.py index cb1a959d5..836ac2c4f 100644 --- a/hed/errors/error_reporter.py +++ b/hed/errors/error_reporter.py @@ -21,7 +21,6 @@ ErrorContext.SIDECAR_KEY_NAME, ErrorContext.ROW, ErrorContext.COLUMN, - ErrorContext.HED_STRING, ErrorContext.SCHEMA_SECTION, ErrorContext.SCHEMA_TAG, ErrorContext.SCHEMA_ATTRIBUTE, @@ -32,6 +31,10 @@ ErrorContext.ROW, ] +hed_string_sort_list = [ + ErrorContext.HED_STRING +] + def _register_error_function(error_type, wrapper_func): if error_type in error_functions: raise KeyError(f"{error_type} defined more than once.") @@ -186,10 +189,13 @@ def push_error_context(self, context_type, context): """ if context is None: + from hed import HedString if context_type in int_sort_list: context = 0 + elif context_type in hed_string_sort_list: + context = HedString("") else: - context_type = "" + context = "" self.error_context.append((context_type, context)) def pop_error_context(self): @@ -446,10 +452,13 @@ def sort_issues(issues, reverse=False): Returns: list: The sorted list of issues.""" def _get_keys(d): + from hed import HedString result = [] for key in default_sort_list: if key in int_sort_list: result.append(d.get(key, -1)) + elif key in hed_string_sort_list: + result.append(d.get(key, HedString(""))) else: result.append(d.get(key, "")) return tuple(result)