gavo.formats.votableread module¶
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.
- class gavo.formats.votableread.AutoQuotedNameMaker(forRowmaker=False)[source]¶
Bases:
object
A name maker for makeTableDefForVOTable quoting names as necessary.
This is for PostgreSQL; it will also avoid PG’s reserved column names (oid and friends); hence, this is what you should be using to put VOTables into postgres tables.
This will break on duplicate names right now. I expect I’ll change that behaviour to just renaming away name clashes at some point.
- class gavo.formats.votableread.QuotedNameMaker[source]¶
Bases:
object
A name maker for makeTableDefForVOTable implementing TAP’s requirements.
- gavo.formats.votableread.makeDDForVOTable(tableId, vot, gunzip=False, rd=None, **moreArgs)[source]¶
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.
- gavo.formats.votableread.makeTableDefForVOTable(tableId, votTable, nameMaker=None, rd=None, **moreArgs)[source]¶
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.
- gavo.formats.votableread.uploadVOTable(tableId, srcFile, connection, gunzip=False, rd=None, **tableArgs)[source]¶
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).