module documentation

Module for a simple query language

A query filter is always a list. The first item in the list is the operator (e.g. [OP_AND, ...]), while the other items depend on the operator. For logic operators (e.g. OP_AND, OP_OR), they are subfilters whose results are combined. Unary operators take exactly one other item (e.g. a subfilter for OP_NOT and a field name for OP_TRUE). Binary operators take exactly two operands, usually a field name and a value to compare against. Filters are converted to callable functions by query._CompileFilter.

Function BuildFilterParser Builds a parser for query filter strings.
Function MakeFilter Try to make a filter from arguments to a command.
Function MakeSimpleFilter Builds simple a filter.
Function ParseFilter Parses a query filter.
Function _CheckFilter CHecks if a string could be a filter.
Function _CheckGlobbing Checks if a string could be a globbing pattern.
Function _ConvertLogicOp Creates parsing action function for logic operator.
Function _ConvertRegexpValue Regular expression value for condition.
Function _MakeFilterPart Generates filter for one argument.
Constant _KNOWN_REGEXP_DELIM Undocumented
Constant _KNOWN_REGEXP_FLAGS Undocumented
def BuildFilterParser():

Builds a parser for query filter strings.

Returns
pyparsing.ParserElementUndocumented
def MakeFilter(args, force_filter, namefield=None, isnumeric=False):

Try to make a filter from arguments to a command.

If the name could be a filter it is parsed as such. If it's just a globbing pattern, e.g. "*.site", such a filter is constructed. As a last resort the names are treated just as a plain name filter.

Parameters
args:list of stringArguments to command
force_filter:boolWhether to force treatment as a full-fledged filter
namefield:stringName of field to use for simple filters (use None for a default of "name")
isnumeric:boolWhether the namefield type is numeric, as opposed to the default string type; this influences how the filter is built
Returns
listQuery filter
def MakeSimpleFilter(namefield, values):

Builds simple a filter.

Parameters
namefieldName of field containing item name
valuesList of names
def ParseFilter(text, parser=None):

Parses a query filter.

Parameters
text:stringQuery filter
parser:pyparsing.ParserElementPyparsing object
Returns
listUndocumented
def _CheckFilter(text):

CHecks if a string could be a filter.

Returns
boolUndocumented
def _CheckGlobbing(text):

Checks if a string could be a globbing pattern.

Returns
boolUndocumented
def _ConvertLogicOp(op):

Creates parsing action function for logic operator.

Parameters
op:stringOperator for data structure, e.g. OP_AND
def _ConvertRegexpValue(_, loc, toks):

Regular expression value for condition.

def _MakeFilterPart(namefield, text, isnumeric=False):

Generates filter for one argument.

_KNOWN_REGEXP_DELIM: str =

Undocumented

Value
'/#^|'
_KNOWN_REGEXP_FLAGS =

Undocumented

Value
frozenset('si')