Package gavo :: Package svcs :: Module pql
[frames] | no frames]

Module pql

source code

Code to support PQL syntax (as found in various DAL protocols).

PQL range-list syntax is

valSep ::= "," rangeSep ::= "/" qualSep ::= ";" step ::= somethingMagicallyDefined range ::= [literal] rangeSep literal | literal rangeSep steppedRange ::= range [rangeSep step] qualification ::= qualSep somethingMagicallyDefined listItem ::= steppedRange | literal rangeList ::= listItem {valSep listItem} [qualification]

This defines a regular language, and we're going to slaughter it using REs and ad hoccing.

Since the actually allowed grammar depends on the type of the parameter (e.g., steps make no sense for strings, and have a special grammar for dates), parsing is done by the specific PQLPar types (fromLiteral). See the PQLPar docstring for further info.

Classes
  PQLRange
a representation of a PQL range.
  PQLNoRange
a stand-in for PQLRange when no ranges are to be supported
  PQLPar
a representation for PQL expressions.
  PQLIntPar
a PQL parameter containing an integer.
  PQLDatePar
a PQL parameter containing a date.
  PQLPositionPar
a PQL position parameter, as for SSA.
  PQLFloatPar
a PQL float parameter.
  PQLCaselessPar
a PQL string parameter that's compared with case folding.
  PQLShellPatternPar
a PQL shell pattern parameter.
  PQLNocaseShellPatternPar
a shell-pattern matching parameter, ignoring case.
  PQLStringPar
a PQL normal string parameter.
  PQLTextParIR
a PQL string parameter matching "google-like", "Information Retrieval".
  ToPQLTypeConverter
Functions
 
getREForShPat(shPat)
returns a POSIX RE for a POSIX shell pattern.
source code
 
getPQLTypeFor(sqlType) source code
 
adaptInputKey(inputKey)
returns inputKey changed to generate SQL for PQL-like expressions.
source code
Variables
  QUALIFIER_RE = re.compile(r'([^;]*)(;[^;]*)?$')
  LIST_RE = re.compile(r'([^,]*),')
  RANGE_RE = re.compile(r'([^/]*)(/[^/]*)?(/[^/]*)?$')
  __package__ = 'gavo.svcs'
Function Details

getREForShPat(shPat)

source code 

returns a POSIX RE for a POSIX shell pattern.

>>> getREForShPat(r"ZU?\*[!A-Z]*")
'ZU.\\*[^A\\-Z].*'
>>> getREForShPat("no[*")
'no\\[.*'

adaptInputKey(inputKey)

source code 

returns inputKey changed to generate SQL for PQL-like expressions.

This is used for buildFrom on CondDescs and renderers having parameterStyle pql.