Package gavo :: Package formats :: Module votablewrite :: Class VOTableContext
[frames] | no frames]

Class VOTableContext

source code

                     object --+    
                              |    
utils.codetricks.IdManagerMixin --+
                                  |
                                 VOTableContext

A context object for writing VOTables.

The constructor arguments work as keyword arguments to ``getAsVOTable``. Some other high-level functions accept finished contexts.

This class provides management for unique ID attributes, the value mapper registry, and possibly additional services for writing VOTables.

VOTableContexts optionally take

There's also an attribute produceVODML that will automatically be set for VOTable 1.4; you can set it to true manually, but the resulting VOTables will probably be invalid.

If VO-DML processing is enabled, the context also manages models declared; that's the modelsUsed dictionary, mapping prefix -> dm.Model instances

Instance Methods
 
__init__(self, mfRegistry=<gavo.utils.serializers.ValueMapperFactoryRegistry object>, tablecoding='binary', version=None, acquireSamples=True, suppressNamespace=False, overflowElement=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
addVODMLPrefix(self, prefix)
arranges the DM with prefix to be included in modelsUsed.
source code
 
addVODMLMaterial(self, stuff)
adds VODML annotation to this VOTable.
source code
 
makeTable(self, table)
returns xmlstan for a table.
source code
 
getEnclosingTable(self)
returns the xmlstan element of the table currently built.
source code
 
getEnclosingResource(self)
returns the xmlstan element of the resource currently built.
source code
 
getEnclosingContainer(self)
returns the innermost container element the builders have declared.
source code
 
activeContainer(*args, **kwds)
a context manager to be called by VOTable builders when they open a new TABLE or RESOURCE.
source code
 
buildingFromTable(*args, **kwds)
a context manager to control code that works on a DaCHS table.
source code
 
pushRefFor(self, rdEl, refVal)
orders refVal to be set as ref on rdEl's VOTable representation if such a thing is being serialised.
source code
 
addID(self, rdEl, votEl)
adds an ID attribute to votEl if rdEl has an id managed by self.
source code

Inherited from utils.codetricks.IdManagerMixin: cloneFrom, getForId, getIdFor, getOrMakeIdFor, makeIdFor

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  currentTable
the DaCHS table object from which things are currently built.

Inherited from object: __class__

Method Details

__init__(self, mfRegistry=<gavo.utils.serializers.ValueMapperFactoryRegistry object>, tablecoding='binary', version=None, acquireSamples=True, suppressNamespace=False, overflowElement=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

addVODMLMaterial(self, stuff)

source code 

adds VODML annotation to this VOTable.

Note that it will only be rendered if produceVODML is true (in general, for target versions >1.3).

makeTable(self, table)

source code 

returns xmlstan for a table.

This is exposed as a method of context as the dm subpackage needs it, but I don't want to import formats there (yet).

This may go away as I fix the interdependence of dm, votable, and format.

getEnclosingTable(self)

source code 

returns the xmlstan element of the table currently built.

This returns a ValueError if the context isn't aware of a table being built.

(This depends builders using activeContainer)

getEnclosingResource(self)

source code 

returns the xmlstan element of the resource currently built.

This returns a ValueError if the context isn't aware of a resource being built.

(This depends builders using activeContainer)

activeContainer(*args, **kwds)

source code 

a context manager to be called by VOTable builders when they open a new TABLE or RESOURCE.

Decorators:
  • @contextlib.contextmanager

buildingFromTable(*args, **kwds)

source code 

a context manager to control code that works on a DaCHS table.

Decorators:
  • @contextlib.contextmanager

pushRefFor(self, rdEl, refVal)

source code 

orders refVal to be set as ref on rdEl's VOTable representation if such a thing is being serialised.

This currently is more a hack for PARAMs with COOSYS than something that should be really used; if this were to become a general pattern, we should work out a way to assign the ref if rdEl's representation already is in the tree...

addID(self, rdEl, votEl)

source code 

adds an ID attribute to votEl if rdEl has an id managed by self.

Also, if a ref has been noted for rdEl, a ref attribute is being added, too. This is a special hack for params and coosys; and I suspect we shouldn't go beyond that.


Property Details

currentTable

the DaCHS table object from which things are currently built.

If no builder has declared a table being built (using buildingFromTable), it's a value error.

Get Method:
unreachable.currentTable(self) - the DaCHS table object from which things are currently built.