gavo.user.mkrd module

Creation of resource descriptors

The first part of this is an early experiment to automatically create resource descriptors from structured data representations.

While parts of this may be recoverable for smarter gavo start functionality, doing this so that the result is actually useful is hard.

Instead, the new gavo start functionality just fetches one of a few commented RD templates, fills out a thing or two and leaves the rest to the operator.

class gavo.user.mkrd.MkrdMacroProcessor[source]

Bases: MacroExpander

a macro expander for RD templates.

class gavo.user.mkrd.TemplateMacroPackage[source]

Bases: MacroPackage

Macros for RD templates.


expands to the content of tpart-commonmeta.xml.


returns an ISO representation of just about now UTC.


returns the last element of the current path.

This is assumed to be the intended resource directory.


A silent macro used for self-documentation.

class gavo.user.mkrd.VizBBBParser[source]

Bases: object

A simple and naive parser for VizieR Byte-by-Byte descriptions.

The results are available in the colAttrs and bytesForCols attributes.

bbbLinePat = re.compile('\\s*(?P<from>\\d+)\\s*-\\s*(?P<to>\\d+)\\s+(?P<format>[A-Z0-9.]+)\\s+(?P<units>[^\\s]*)\\s+(?P<label>[^\\s]*)\\s+(?P<description>.*)')
tableBorderPat = re.compile('--------+')

returns a column element XML literal for colAttrs in Markus’ preferred formatting.


a UI function generating columns element from FITS binary tables.


returns formatted XML for a sequence for column attributes.

colAttrs is a sequence of dicts with fillers into COLUMN_ELEMENT_TEMPLATES; the must already be escaped for use in XML attributes.

gavo.user.mkrd.getTypeForFTFormat(format, name)[source]

returns a DaCHS type for FITS table column.

gavo.user.mkrd.indent(elem, level=0)[source]

returns true if kw should not be translated or put into the table.

This is important for all WCS keywords when you want to compute SIAP bboxes; these keywords must not be translated.


yields dicts of column attributes from a FITS binary table HDU.


tries to parse (binary) inFile as a VOTable and yields colAttrs dictionaries for all FIELDs in it.

gavo.user.mkrd.iterColAttrsViz(inFile, dumpRanges=False)[source]

tries to parse (text) inFile as a VizieR-Style bytes-by-bytes description and yields colAttrs for the first described table.

dumpRanges is for interactive use, where the function additionally dumps a colDefs content to stdout.

gavo.user.mkrd.makeDataForFITS(rd, srcName, opts)[source]
gavo.user.mkrd.makeDataForFT(rd, srcName, opts)[source]
gavo.user.mkrd.makeDataForVOTable(rd, srcName, opts)[source]
gavo.user.mkrd.makeRD(args, opts)[source]
gavo.user.mkrd.makeTableFromFITS(rd, srcName, opts)[source]
gavo.user.mkrd.makeTableFromFT(rd, srcName, opts)[source]
gavo.user.mkrd.makeTableFromVOTable(rd, srcName, opts)[source]

returns an ElementTree for the copyable content of aStruct.

Note that due to manipulations at parse time and non-copyable content, this will, in general, not reproduce the original XML trees.