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.

macro_commonmeta()[source]

expands to the content of tpart-commonmeta.xml.

macro_now()[source]

returns an ISO representation of just about now UTC.

macro_resdir()[source]

returns the last element of the current path.

This is assumed to be the intended resource directory.

macro_tpldesc(description)[source]

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>.*)')
feed(line)[source]
tableBorderPat = re.compile('--------+')
gavo.user.mkrd.formatColumnElement(colAttrs)[source]

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

gavo.user.mkrd.gencol()[source]

a UI function generating columns element from FITS binary tables.

gavo.user.mkrd.getColumnXML(colAttrs)[source]

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]
gavo.user.mkrd.isIgnoredKeyword(kw)[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.

gavo.user.mkrd.iterColAttrsFITS(table)[source]

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

gavo.user.mkrd.iterColAttrsVOTable(inFile)[source]

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.main()[source]
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]
gavo.user.mkrd.parseCommandLine()[source]
gavo.user.mkrd.parseGenColCommandLine()[source]
gavo.user.mkrd.parseStartCommandLine()[source]
gavo.user.mkrd.start()[source]
gavo.user.mkrd.structToETree(aStruct)[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.

gavo.user.mkrd.writePrettyPrintedXML(root)[source]