117 def _matches_shared_conventions(self, name):
118 '''
119 True if name starts with level prefix, and all signature
120 types are in the correct order, otherwise False.
121 '''
122
123
124 signature_types = "|".join(self._signature_type_order)
125 sig_type_pattern = re.compile(
126 r"_\d*[egj]?({})\d+s?".format(signature_types))
127
128
129
130
131
132
133 def items_in_order(part):
134
135 indices = [self._signature_type_order.
index(x)
for x
in
136 sig_type_pattern.findall(part)]
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 rr = indices == sorted(indices)
158 if not rr:
159 log.error("[StructuredChainNames::items_in_order] %s NOT SORTED!", indices)
160
161 return rr
162
163 def are_signatures_in_order(name_parts):
164
165 to_check = ["".join(f"_{p}" for p in name_parts if "-" not in p)]
166
167
168 topo_parts = [p for p in name_parts if "-" in p]
169 for topo in topo_parts:
170 to_check.extend(topo.split("-"))
171 res = all(items_in_order(part) for part in to_check)
172 if not res:
173 for part in to_check:
174 if not items_in_order(part):
175 log.error("[StructuredChainNames::are_signatures_in_order] %s not in order!", part)
176 return res
177
178
179 parts = name.split("_")
180
181 result= all((len(parts) > 1,
182 parts[0] == self._trigger_level.value,
183 are_signatures_in_order(parts[1:])))
184 if not result:
185 log.error("[StructuredChainNames::_matches_shared_conventions] chain deosn't match convention: parts[0] = %s, value = %s, parts[1:] = %s, signature_types = %s",
186 parts[0], self._trigger_level.value, parts[1:], signature_types)
187
188 return result
189
190