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