Streamline None checking in initialize_search

This commit is contained in:
Saba 2021-11-28 11:59:45 -05:00
parent da52433d89
commit bf8ae31e6a

View file

@ -127,23 +127,23 @@ def initialize_search(config: FullConfig, regenerate, verbose):
search_config = SearchConfig() search_config = SearchConfig()
# Initialize Org Notes Search # Initialize Org Notes Search
search_config.notes = TextSearchConfig(config.content_type.org, verbose) if config.content_type.org else None if config.content_type.org:
if search_config.notes: search_config.notes = TextSearchConfig(config.content_type.org, verbose)
model.notes_search = asymmetric.setup(search_config.notes, regenerate=regenerate) model.notes_search = asymmetric.setup(search_config.notes, regenerate=regenerate)
# Initialize Org Music Search # Initialize Org Music Search
search_config.music = TextSearchConfig(config.content_type.music, verbose) if config.content_type.music else None if config.content_type.music:
if search_config.music: search_config.music = TextSearchConfig(config.content_type.music, verbose)
model.music_search = asymmetric.setup(search_config.music, regenerate=regenerate) model.music_search = asymmetric.setup(search_config.music, regenerate=regenerate)
# Initialize Ledger Search # Initialize Ledger Search
search_config.ledger = TextSearchConfig(config.content_type.org, verbose) if config.content_type.ledger else None if config.content_type.ledger:
if search_config.ledger: search_config.ledger = TextSearchConfig(config.content_type.org, verbose)
model.ledger_search = symmetric_ledger.setup(search_config.ledger, regenerate=regenerate) model.ledger_search = symmetric_ledger.setup(search_config.ledger, regenerate=regenerate)
# Initialize Image Search # Initialize Image Search
search_config.image = ImageSearchConfig(config.content_type.image, verbose) if config.content_type.image else None if config.content_type.image:
if search_config.image: search_config.image = ImageSearchConfig(config.content_type.image, verbose)
model.image_search = image_search.setup(search_config.image, regenerate=regenerate) model.image_search = image_search.setup(search_config.image, regenerate=regenerate)
return model, search_config return model, search_config