CategorizedWildcard¶
- 
class lsst.daf.butler.registry.wildcards.CategorizedWildcard(strings: List[str], patterns: List[re.Pattern], items: List[Tuple[str, Any]])¶
- Bases: - object- The results of preprocessing a wildcard expression to separate match patterns from strings. - The - fromExpressionmethod should almost always be used to construct instances, as the regular constructor performs no checking of inputs (and that can lead to confusing error messages downstream).- Methods Summary - fromExpression(expression, *, allowAny, …)- Categorize a wildcard expression. - makeWhereExpression(column)- Transform the wildcard into a SQLAlchemy boolean expression suitable for use in a WHERE clause. - Methods Documentation - 
classmethod fromExpression(expression: Any, *, allowAny: bool = True, allowPatterns: bool = True, coerceUnrecognized: Optional[Callable[[Any], Union[Tuple[str, Any], str]]] = None, coerceItemValue: Optional[Callable[[Any], Any]] = None, defaultItemValue: Optional[Any] = None) → Union[lsst.daf.butler.registry.wildcards.CategorizedWildcard, ellipsis]¶
- Categorize a wildcard expression. - Parameters: - expression
- The expression to categorize. May be any of:
- str;
- re.Pattern(only if- allowPatternsis- True);
- objects recognized by coerceUnrecognized(if provided);
- two-element tuples of (str, value) where value is recognized bycoerceItemValue(if provided);
- a non-str, non-mapping iterable containing any of the above;
- the special value (only ifallowAnyisTrue), which matches anything;
- a mapping from strto a value are recognized bycoerceItemValue(if provided);
- a CategorizedWildcardinstance (passed through unchanged if it meets the requirements specified by keyword arguments).
 
 
- allowAny: `bool`, optional
- If - False(- Trueis default) raise- TypeErrorif- is encountered.
- allowPatterns: `bool`, optional
- If - False(- Trueis default) raise- TypeErrorif a- re.Patternis encountered, or if- expressionis a- CategorizedWildcardwith- patternsnot empty.
- coerceUnrecognized: `Callable`, optional
- A callback that takes a single argument of arbitrary type and returns either a - str- appended to- strings- or a- tupleof (- str,- Any) to be appended to- items. This will be called on objects of unrecognized type, with the return value added to- strings. Exceptions will be reraised as- TypeError(and chained).
- coerceItemValue: `Callable`, optional
- If provided, - expressionmay be a mapping from- strto any type that can be passed to this function; the result of that call will be stored instead as the value in- self.items.
- defaultItemValue: `Any`, optional
- If provided, combine this value with any string values encountered (including any returned by - coerceUnrecognized) to form a- tupleand add it to- items, guaranteeing that- stringswill be empty. Patterns are never added to- items.
 - Returns: - categorized : CategorizedWildcardor....
- The struct describing the wildcard. - ...is passed through unchanged.
 - Raises: - TypeError
- Raised if an unsupported type is found in the expression. 
 
 - 
makeWhereExpression(column: sqlalchemy.sql.elements.ColumnElement) → Optional[sqlalchemy.sql.elements.ColumnElement]¶
- Transform the wildcard into a SQLAlchemy boolean expression suitable for use in a WHERE clause. - Parameters: - column : sqlalchemy.sql.ColumnElement
- A string column in a table or query that should be compared to the wildcard expression. 
 - Returns: 
- column : 
 
- 
classmethod