Code Duplication    Length = 19-19 lines in 2 locations

ColleXions.py 1 location

@@ 228-246 (lines=19) @@
225
    return combined
226
227
# --- NEW HELPER FUNCTION ---
228
def get_all_special_collection_names(config):
229
    """Returns a set of all collection names defined in special_collections config."""
230
    all_special_titles = set()
231
    special_configs = config.get('special_collections', [])
232
    if not isinstance(special_configs, list):
233
        logging.warning("'special_collections' in config is not a list. Cannot identify all special titles.")
234
        return all_special_titles # Return empty set
235
236
    for special in special_configs:
237
        # Check structure before accessing keys
238
        if isinstance(special, dict) and 'collection_names' in special and isinstance(special['collection_names'], list):
239
             # Add all valid string names from this special entry
240
             all_special_titles.update(name for name in special['collection_names'] if isinstance(name, str))
241
        else:
242
            logging.warning(f"Skipping invalid entry when getting all special names: {special}")
243
244
    if all_special_titles:
245
        logging.info(f"Identified {len(all_special_titles)} unique titles defined across all special_collections entries.")
246
    return all_special_titles
247
# --- END NEW HELPER FUNCTION ---
248
249

collexions.py 1 location

@@ 228-246 (lines=19) @@
225
    return combined
226
227
# --- NEW HELPER FUNCTION ---
228
def get_all_special_collection_names(config):
229
    """Returns a set of all collection names defined in special_collections config."""
230
    all_special_titles = set()
231
    special_configs = config.get('special_collections', [])
232
    if not isinstance(special_configs, list):
233
        logging.warning("'special_collections' in config is not a list. Cannot identify all special titles.")
234
        return all_special_titles # Return empty set
235
236
    for special in special_configs:
237
        # Check structure before accessing keys
238
        if isinstance(special, dict) and 'collection_names' in special and isinstance(special['collection_names'], list):
239
             # Add all valid string names from this special entry
240
             all_special_titles.update(name for name in special['collection_names'] if isinstance(name, str))
241
        else:
242
            logging.warning(f"Skipping invalid entry when getting all special names: {special}")
243
244
    if all_special_titles:
245
        logging.info(f"Identified {len(all_special_titles)} unique titles defined across all special_collections entries.")
246
    return all_special_titles
247
# --- END NEW HELPER FUNCTION ---
248
249