hop.models

class hop.models.Blob(content: Union[str, int, float, bool, None, Dict[str, Any], List[Any]], missing_schema: bool = False)[source]

Defines an unformatted message blob.

asdict()[source]

Represents the message as a dictionary.

Returns

The dictionary representation of the message.

classmethod load(blob_input)[source]

Create a blob message from input text.

Parameters

blob_input – The unstructured message text or file object.

Returns

The Blob.

serialize()[source]

Wrap the message with its format and content.

Returns

A dictionary with “format” and “content” keys.

class hop.models.GCNCircular(header: dict, body: str)[source]

Defines a GCN Circular structure.

The parsed GCN circular is formatted as a dictionary with the following schema:

{‘headers’: {‘title’: …, ‘number’: …, …}, ‘body’: …}

classmethod load(email_input)[source]

Create a new GCNCircular from an RFC 822 formatted circular.

Parameters

email_input – A file object or string.

Returns

The GCNCircular.

serialize()[source]

Wrap the message with its format and content.

Returns

A dictionary with “format” and “content” key-value pairs.

class hop.models.MessageModel[source]

An abstract message model.

asdict()[source]

Represents the message model as a dictionary.

abstract classmethod load(input_)[source]

Create a new message model from a file object or string. This base implementation has no functionality and should not be called.

Parameters

input – A file object or string.

Returns

The message model.

classmethod load_file(filename)[source]

Create a new message model from a file.

Parameters

filename – The path to a file.

Returns

The message model.

serialize()[source]

Wrap the message with its format and content.

Returns

A dictionary with “format” and “content” keys.

class hop.models.VOEvent(ivorn: str, role: str = 'observation', version: str = '2.0', Who: dict = <factory>, What: dict = <factory>, WhereWhen: dict = <factory>, How: dict = <factory>, Why: dict = <factory>, Citations: dict = <factory>, Description: dict = <factory>, Reference: dict = <factory>)[source]

Defines a VOEvent 2.0 structure.

Implements the schema defined by:

http://www.ivoa.net/Documents/VOEvent/20110711/

classmethod load(xml_input)[source]

Create a new VOEvent from an XML-formatted VOEvent.

Parameters

xml_input – A file object, string, or generator.

Returns

The VOEvent.

classmethod load_file(filename)[source]

Create a new VOEvent from an XML-formatted VOEvent file.

Parameters

filename – Name of the VOEvent file.

Returns

The VOEvent.