Package gavo :: Package formats :: Module votableread
[frames] | no frames]

Module votableread

source code

Parsing and translating VOTables to internal data structures.

This is glue code to the more generic votable library. In general, you should access this module through formats.votable.

Classes
  QuotedNameMaker
A name maker for makeTableDefForVOTable implementing TAP's requirements.
  AutoQuotedNameMaker
A name maker for makeTableDefForVOTable quoting names as necessary.
Functions
 
addQ3CIndex(tableDef)
if td as unique main positions (by UCD), add an index to the table definition.
source code
 
makeTableDefForVOTable(tableId, votTable, nameMaker=None, rd=None, **moreArgs)
returns a TableDef for a Table element parsed from a VOTable.
source code
 
makeDDForVOTable(tableId, vot, gunzip=False, rd=None, **moreArgs)
returns a DD suitable for uploadVOTable.
source code
 
uploadVOTable(tableId, srcFile, connection, gunzip=False, rd=None, **tableArgs)
creates a temporary table with tableId containing the first table in the VOTable in srcFile.
source code
Variables
  __package__ = 'gavo.formats'
Function Details

makeTableDefForVOTable(tableId, votTable, nameMaker=None, rd=None, **moreArgs)

source code 

returns a TableDef for a Table element parsed from a VOTable.

Pass additional constructor arguments for the table in moreArgs. stcColumns is a dictionary mapping IDs within the source VOTable to pairs of stc and utype.

nameMaker is an optional argument; if given, it must be an object having a makeName(field) -> string or utils.QuotedName method. It must return unique objects from VOTable fields and do that reproducibly, i.e., for a given field the same name is returned.

The default is valuemappers.VOTNameMaker. When building TDs for Postgres, use AutoQuotedNameMaker to generate valid column names.

As an extra service, in particular for ADQL name resolving, the column objects returned here have an attribute originalName containing whatever was originally in a FIELD's @name.

If unique "main" positions are given, a spatial q3c index will be added.

makeDDForVOTable(tableId, vot, gunzip=False, rd=None, **moreArgs)

source code 

returns a DD suitable for uploadVOTable.

moreArgs are additional keywords for the construction of the target table.

Only the first resource will be turned into a DD. Currently, only the first table is used. This probably has to change.

uploadVOTable(tableId, srcFile, connection, gunzip=False, rd=None, **tableArgs)

source code 

creates a temporary table with tableId containing the first table in the VOTable in srcFile.

The function returns a DBTable instance for the new file.

srcFile must be an open file object (or some similar object).