Home | Trees | Indices | Help |
|
---|
|
Common code for generation of various data formats.
The main function here is formatData. It receives a string format id, a data instance and a destination file. It dispatches this to formatters previously registred using registerDataWriter.
The data writers must take a data instance and a file instance; their effect must be that a serialized representation of data, or, if the format does not support this, the data's primary table is written to the file instance.
Classes | |
CannotSerializeIn | |
FORMATS_REGISTRY a registry for data formats that can be produced by DaCHS. |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
Variables | |
PRESERVED_MIMES =
|
|
EXTENSION_FALLBACKS =
|
|
__package__ =
|
Function Details |
makes a DaCHS mime key from a content-type string. This is used for retrieving matching mime types and is a triple of major and minor mime type and a set of parameter pairs. contentType is a string-serialized mime type. |
writes a table to outputFile in the format given by key. Table may be a table or a ``Data`` instance. ``formatName`` is a format shortcut (``formats.iterFormats()`` gives keys available) or a media type. If you pass None, the default VOTable format will be selected. This raises a ``CannotSerializeIn`` exception if ``formatName`` is not recognized. Note that you have to import the serialising modules from the format package to make the formats available (fitstable, csvtable, geojson, jsontable, texttable, votable; api itself already imports the more popular of these). If a client knows a certain formatter understands additional arguments, it can hand them in as keywords arguments. This will raise an error if another formatter that doesn't understand the argument is being used. |
returns a string containing a representation of table in the format given by formatName. This is just wrapping the `function formatData`_; se there for formatName. This function will use large amounts of memory for large data. |
returns a media type plausible for a file named fName. This first uses the extension map inferred by our formats registry, has some built-in safety catches in case the formatters haven't been imported, and then falls back to built-in python mimetypes.guess_type If nothing matches, it returns application/octet-stream. Extensions are used case-insensitively. We don't do any encoding inference (yet). We may, though, so by all means shout if you're using this in DaCHS-external code. |
returns a suggested extension for files of mediaType. mediaType can be an RFC 2045 media type, or one of DaCHS' internal format codes. As a fallback, .dat will be returned. |
Variables Details |
PRESERVED_MIMES
|
EXTENSION_FALLBACKS
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |