@@ -121,7 +121,7 @@ def update_default_source_mapping(self, default_mapping: SourceMapping, fields_m
121
121
122
122
def prepare_alternative_mapping (self , platform_dir : str ) -> dict [str , dict [str , SourceMapping ]]:
123
123
alternative_mappings = {}
124
- for name , platform_dir in self ._loader .get_platform_alternative_mappings (platform_dir ).items ():
124
+ for name , platform_dir in self ._loader .get_platform_alternative_mappings_dirs (platform_dir ).items ():
125
125
alternative_mappings [name ] = self .prepare_mapping (platform_dir )
126
126
return alternative_mappings
127
127
@@ -170,10 +170,18 @@ def prepare_log_source_signature(self, mapping: dict) -> LogSourceSignature:
170
170
171
171
def get_source_mappings_by_fields_and_log_sources (
172
172
self , field_names : list [str ], log_sources : dict [str , list [Union [int , str ]]]
173
+ ) -> list [SourceMapping ]:
174
+ return self ._get_source_mappings_by_fields_and_log_sources (field_names , log_sources , self ._source_mappings )
175
+
176
+ def _get_source_mappings_by_fields_and_log_sources (
177
+ self ,
178
+ field_names : list [str ],
179
+ log_sources : dict [str , list [Union [int , str ]]],
180
+ source_mapping : dict [str , SourceMapping ],
173
181
) -> list [SourceMapping ]:
174
182
by_log_sources_and_fields = []
175
183
by_fields = []
176
- for source_mapping in self . _source_mappings .values ():
184
+ for source_mapping in source_mapping .values ():
177
185
if source_mapping .source_id == DEFAULT_MAPPING_NAME :
178
186
continue
179
187
@@ -184,28 +192,13 @@ def get_source_mappings_by_fields_and_log_sources(
184
192
if log_source_signature and log_source_signature .is_suitable (** log_sources ):
185
193
by_log_sources_and_fields .append (source_mapping )
186
194
187
- return by_log_sources_and_fields or by_fields or [self . _source_mappings [DEFAULT_MAPPING_NAME ]]
195
+ return by_log_sources_and_fields or by_fields or [source_mapping [DEFAULT_MAPPING_NAME ]]
188
196
189
197
def get_alt_source_mappings_by_fields_and_log_sources (
190
198
self , field_names : list [str ], log_sources : dict [str , list [Union [int , str ]]], alt_mapping : str
191
199
) -> list [SourceMapping ]:
192
- by_log_sources_and_fields = []
193
- by_fields = []
194
- for source_mapping in self ._alternative_mappings .get (alt_mapping , {}).values ():
195
- if source_mapping .source_id == DEFAULT_MAPPING_NAME :
196
- continue
197
-
198
- if source_mapping .fields_mapping .is_suitable (field_names ):
199
- by_fields .append (source_mapping )
200
-
201
- log_source_signature : LogSourceSignature = source_mapping .log_source_signature
202
- if log_source_signature and log_source_signature .is_suitable (** log_sources ):
203
- by_log_sources_and_fields .append (source_mapping )
204
-
205
- return (
206
- by_log_sources_and_fields
207
- or by_fields
208
- or [self ._alternative_mappings .get (alt_mapping )[DEFAULT_MAPPING_NAME ]]
200
+ return self ._get_source_mappings_by_fields_and_log_sources (
201
+ field_names , log_sources , self ._alternative_mappings .get (alt_mapping , {})
209
202
)
210
203
211
204
def get_source_mapping (self , source_id : str ) -> Optional [SourceMapping ]:
0 commit comments