Source code for ramble.filters

# Copyright 2022-2026 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import itertools
from typing import List, Optional, Set

ALL_PHASES: List[str] = ["*"]


[docs] class Filters: """Object containing filters for limiting various operations in Ramble""" def __init__( self, phase_filters: Optional[List[str]] = None, include_where_filters: Optional[List[List[str]]] = None, exclude_where_filters: Optional[List[List[str]]] = None, tags: Optional[List[List[str]]] = None, ) -> None: """Create a new filter instance""" self.phases: List[str] = ALL_PHASES if phase_filters is None else phase_filters self.include_where: Optional[List[str]] = None self.exclude_where: Optional[List[str]] = None self.tags: Set[str] = set() if include_where_filters: self.include_where = list(itertools.chain.from_iterable(include_where_filters)) if exclude_where_filters: self.exclude_where = list(itertools.chain.from_iterable(exclude_where_filters)) if tags: self.tags = set(itertools.chain.from_iterable(tags))