gavo.svcs.vizierexprs module¶
Classes and methods to support vizier-type specifications on fields.
-
class
gavo.svcs.vizierexprs.
DateFlattener
[source]¶ Bases:
gavo.svcs.vizierexprs._Flattener
A _Flattener producing SQL for data-like columns.
This is supposed to work for timestamp-valued and MJD-valued columns alike. The difference is handled on the level of nodes (DateNode vs. MJDNode).
-
class
gavo.svcs.vizierexprs.
DateNode
(children, operator)[source]¶ Bases:
gavo.svcs.vizierexprs.ParseNode
A node containing date operands (datetime objects, as a rule).
As an extension to VizieR, we interpret floats as well, where 1000 .. 3000 is a julian year, 10000 … 100000 is an MJD and 2000000 .. 4000000 is a JD.
-
class
gavo.svcs.vizierexprs.
NumericFlattener
[source]¶ Bases:
gavo.svcs.vizierexprs._Flattener
A _Flattener for float- and int-valued columns.
-
class
gavo.svcs.vizierexprs.
NumericIntervalFlattener
[source]¶ Bases:
gavo.svcs.vizierexprs.NumericFlattener
A _Flattener for matching against min/max pairs of columns.
Here, field is this (min_column, max_column) pair.
This currently isn’t used anywhere in DaCHS itself. You can use it in custom phraseMakers, though; cf. obsform/q
-
class
gavo.svcs.vizierexprs.
NumericNode
(children, operator)[source]¶ Bases:
gavo.svcs.vizierexprs.ParseNode
A node containing numeric operands (floats or dates).
-
class
gavo.svcs.vizierexprs.
ParseNode
(children, operator)[source]¶ Bases:
object
is a parse node, consisting of an operator and children.
The parse trees returned by the various parse functions are built from these.
This is an abstract class.
-
class
gavo.svcs.vizierexprs.
StringFlattener
[source]¶ Bases:
gavo.svcs.vizierexprs._Flattener
A _Flattener turning String-like Vizier expressions into SQL conditions against string-valued columns.
-
class
gavo.svcs.vizierexprs.
StringNode
(children, operator)[source]¶ Bases:
gavo.svcs.vizierexprs.ParseNode
A node containing string operands.
-
class
gavo.svcs.vizierexprs.
ToVexprConverter
[source]¶ Bases:
gavo.utils.typeconversions.FromSQLConverter
-
simpleMap
= {'bigint': 'vexpr-float', 'char': 'vexpr-string', 'date': 'vexpr-date', 'double': 'vexpr-float', 'double precision': 'vexpr-float', 'float': 'vexpr-float', 'int': 'vexpr-float', 'integer': 'vexpr-float', 'real': 'vexpr-float', 'smallint': 'vexpr-float', 'text': 'vexpr-string', 'timestamp': 'vexpr-date', 'unicode': 'vexpr-string', 'vexpr-date': 'vexpr-date', 'vexpr-float': 'vexpr-float', 'vexpr-string': 'vexpr-string'}¶
-
typeSystem
= 'vizierexpr'¶
-
-
gavo.svcs.vizierexprs.
adaptInputKey
(inputKey)[source]¶ returns ik changed to generate SQL for Vizier-like expressions.
This is used for buildFrom on CondDescs and renderers having parameterStyle form.
-
gavo.svcs.vizierexprs.
format_placeholder
(min_val, max_val, formatter)[source]¶ returns a placeholder string for a possibly open interval.
*_val
may be None, formatter has to accept a non-None value and return the proper representation for the placeholder string.If no placeholder can be generated, this function returns None.
-
gavo.svcs.vizierexprs.
getComplexGrammar
(baseLiteral, pmBuilder, errorLiteral=None, nodeClass=<class 'gavo.svcs.vizierexprs.NumericNode'>)[source]¶ returns the root element of a grammar parsing numeric vizier-like expressions.
This is used for both dates and floats, use baseLiteral to match the operand terminal. The trouble with dates is that the +/- operator has a simple float as the second operand, and that’s why you can pass in an errorLiteral and and pmBuilder.
-
gavo.svcs.vizierexprs.
getPlaceholderFor
(inputKey, values)[source]¶ returns a placeholder (suggested input) for inputKey, where values is the original values element.
This will currently be None unless we do a numeric input.
-
gavo.svcs.vizierexprs.
getStringGrammar
()[source]¶ returns a grammar for parsing vizier-like string expressions.
-
gavo.svcs.vizierexprs.
makeConeSearchFor
(inputKey)[source]¶ returns an //scs#makeSpointCD condDesc tailored for inputKey.
-
gavo.svcs.vizierexprs.
makeDatePmNode
(s, loc, toks)[source]¶ returns a +/- node for dates, i.e., toks[1] is a float in days.
-
gavo.svcs.vizierexprs.
makeMJDPmNode
(s, loc, toks)[source]¶ returns a +/- node for MJDs, i.e., toks[1] is a float in days, and an MJDNode must be returned.
-
gavo.svcs.vizierexprs.
parseDateExpr
(str, baseSymbol={expr StringEnd})[source]¶ returns a parse tree for vizier-like expressions over ISO dates.
Note that the semantic validity of the date (like, month<13) is not checked by the grammar.
-
gavo.svcs.vizierexprs.
parseDateExprToMJD
(str, baseSymbol={expr StringEnd})[source]¶ returns a parse tree for vizier-like expression of ISO dates with parsed values in MJD.
-
gavo.svcs.vizierexprs.
parseDateTime
(s, pos, tok)[source]¶ returns a datetime from a date/time spec.
This can be an ISO string or a julian year, JD, or MJD by heuristics (see DateNode for details).