Filtering and Search

Filtering utilities for cards and packs.

This module provides centralized filtering logic for searching and filtering card/pack collections.

simulchip.filters.filter_packs(packs, filter_text='', owned_packs=None, show_owned_only=False)[source]

Filter packs based on search text and ownership.

Parameters:
  • packs (List[Dict[str, Any]]) – List of pack data dictionaries

  • filter_text (str) – Text to search for in pack fields

  • owned_packs (Optional[set]) – Set of owned pack codes

  • show_owned_only (bool) – If True, only show owned packs

Return type:

List[PackModel]

Returns:

List of filtered PackModel objects

simulchip.filters.filter_packs_raw(packs, filter_text='')[source]

Filter pack dictionaries based on search text (for CLI usage).

Parameters:
  • packs (List[Dict[str, Any]]) – List of pack data dictionaries

  • filter_text (str) – Text to search for in pack fields

Return type:

List[Dict[str, Any]]

Returns:

List of filtered pack dictionaries

simulchip.filters.filter_cards(cards, filter_text='', expected_cards=None, show_expected_only=False)[source]

Filter cards based on search text and expected quantities.

Parameters:
  • cards (List[Dict[str, Any]]) – List of card data dictionaries

  • filter_text (str) – Text to search for in card fields

  • expected_cards (Optional[Dict[str, int]]) – Dictionary of card codes to expected quantities

  • show_expected_only (bool) – If True, only show cards with expected quantities

Return type:

List[CardModel]

Returns:

List of filtered CardModel objects

simulchip.filters.filter_cards_raw(cards, filter_text='', manager=None, show_expected_only=False)[source]

Filter card dictionaries based on search text and expected quantities (for CLI usage).

Parameters:
  • cards (List[Dict[str, Any]]) – List of card data dictionaries

  • filter_text (str) – Text to search for in card fields

  • manager (Optional[Any]) – CollectionManager instance for expected card logic

  • show_expected_only (bool) – If True, only show cards with expected quantities

Return type:

List[Dict[str, Any]]

Returns:

List of filtered card dictionaries

simulchip.filters.create_pack_filter(owned_packs=None, show_owned_only=False)[source]

Create a pack filter function for use in filtering operations.

Parameters:
  • owned_packs (Optional[set]) – Set of owned pack codes

  • show_owned_only (bool) – If True, only show owned packs

Return type:

Callable[[PackModel], bool]

Returns:

Filter function that returns True if pack should be included

simulchip.filters.create_card_filter(expected_cards=None, show_expected_only=False)[source]

Create a card filter function for use in filtering operations.

Parameters:
  • expected_cards (Optional[Dict[str, int]]) – Dictionary of card codes to expected quantities

  • show_expected_only (bool) – If True, only show cards with expected quantities

Return type:

Callable[[CardModel], bool]

Returns:

Filter function that returns True if card should be included

simulchip.filters.filter_items_generic(items, filter_text)[source]

Filter items generically based on filter text.

Parameters:
  • items (List[Any]) – List of items to filter

  • filter_text (str) – Text to search for

Return type:

List[Any]

Returns:

List of filtered items