2222import os
2323import re
2424from datetime import datetime , timezone
25- from enum import Enum
25+ from enum import Enum , auto
2626from functools import lru_cache
2727from typing import Any , Callable , List , Optional , Tuple , Union , Sequence , cast
2828
4646
4747
4848class ValidationProblem (Enum ):
49- UnitWithoutDocumentation = 1
50- InvalidEnum = 2
51- OpenEnumWithNewItem = 3
52- MissingRequiredGroup = 4
53- MissingRequiredField = 5
54- MissingRequiredAttribute = 6
55- InvalidType = 7
56- InvalidDatetime = 8
57- IsNotPosInt = 9
58- ExpectedGroup = 10
59- MissingDocumentation = 11
60- MissingUnit = 12
61- ChoiceValidationError = 13
62- UnitWithoutField = 14
63- AttributeForNonExistingField = 15
64- BrokenLink = 16
65- FailedNamefitting = 17
66- NXdataMissingSignalData = 18
67- NXdataMissingAxisData = 19
68- NXdataAxisMismatch = 20
69- KeyToBeRemoved = 21
70- InvalidConceptForNonVariadic = 22
71- ReservedSuffixWithoutField = 23
72- ReservedPrefixInWrongContext = 24
49+ UnitWithoutDocumentation = auto ()
50+ InvalidEnum = auto ()
51+ OpenEnumWithNewItem = auto ()
52+ MissingRequiredGroup = auto ()
53+ MissingRequiredField = auto ()
54+ MissingRequiredAttribute = auto ()
55+ InvalidType = auto ()
56+ InvalidDatetime = auto ()
57+ IsNotPosInt = auto ()
58+ ExpectedGroup = auto ()
59+ ExpectedField = auto ()
60+ MissingDocumentation = auto ()
61+ MissingUnit = auto ()
62+ ChoiceValidationError = auto ()
63+ UnitWithoutField = auto ()
64+ AttributeForNonExistingField = auto ()
65+ BrokenLink = auto ()
66+ FailedNamefitting = auto ()
67+ NXdataMissingSignalData = auto ()
68+ NXdataMissingAxisData = auto ()
69+ NXdataAxisMismatch = auto ()
70+ KeyToBeRemoved = auto ()
71+ InvalidConceptForNonVariadic = auto ()
72+ ReservedSuffixWithoutField = auto ()
73+ ReservedPrefixInWrongContext = auto ()
74+ InvalidNexusTypeForNamedConcept = auto ()
7375
7476
7577class Collector :
@@ -96,9 +98,9 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar
9698 f"The value at { path } does not match with the enumerated items from the open enumeration: { value } ."
9799 )
98100 elif log_type == ValidationProblem .MissingRequiredGroup :
99- logger .warning (f"The required group, { path } , hasn't been supplied." )
101+ logger .error (f"The required group, { path } , hasn't been supplied." )
100102 elif log_type == ValidationProblem .MissingRequiredField :
101- logger .warning (
103+ logger .error (
102104 f"The data entry corresponding to { path } is required "
103105 "and hasn't been supplied by the reader." ,
104106 )
@@ -118,9 +120,9 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar
118120 f"The value at { path } should be a positive int, but is { value } ."
119121 )
120122 elif log_type == ValidationProblem .ExpectedGroup :
121- logger .warning (
122- f"Expected a group at { path } but found a field or attribute."
123- )
123+ logger .error ( f"Expected a group at { path } but found a field or attribute." )
124+ elif log_type == ValidationProblem . ExpectedField :
125+ logger . error ( f"Expected a field at { path } but found a group." )
124126 elif log_type == ValidationProblem .MissingDocumentation :
125127 if "@" in path .rsplit ("/" )[- 1 ]:
126128 logger .warning (f"Attribute { path } written without documentation." )
@@ -140,7 +142,7 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar
140142 "but the field does not exist."
141143 )
142144 elif log_type == ValidationProblem .BrokenLink :
143- logger .warning (f"Broken link at { path } to { value } " )
145+ logger .warning (f"Broken link at { path } to { value } . " )
144146 elif log_type == ValidationProblem .FailedNamefitting :
145147 logger .warning (f"Found no namefit of { path } in { value } ." )
146148 elif log_type == ValidationProblem .NXdataMissingSignalData :
@@ -152,7 +154,7 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar
152154 f"Length of axis { path } does not match to { value } in dimension { args [0 ]} "
153155 )
154156 elif log_type == ValidationProblem .KeyToBeRemoved :
155- logger .warning (f"The attribute { path } will not be written." )
157+ logger .warning (f"The { value } { path } will not be written." )
156158 elif log_type == ValidationProblem .InvalidConceptForNonVariadic :
157159 value = cast (Any , value )
158160 log_text = f"Given { value .type } name '{ path } ' conflicts with the non-variadic name '{ value } '"
@@ -169,6 +171,12 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar
169171 if value != "<unknown>" :
170172 log_text += f" It is only valid in the context of { value } ."
171173 logger .error (log_text )
174+ elif log_type == ValidationProblem .InvalidNexusTypeForNamedConcept :
175+ value = cast (Any , value )
176+ logger .error (
177+ f"The type ('{ args [0 ] if args else '<unknown>' } ') of the given concept '{ path } ' "
178+ f"conflicts with another existing concept of the same name, which is of type '{ value .type } '."
179+ )
172180
173181 def collect_and_log (
174182 self ,
0 commit comments