From bff20a58bf840aa1785e99b22e5236f72dabbe47 Mon Sep 17 00:00:00 2001 From: Laurent MICHEL Date: Sun, 15 Dec 2024 16:29:31 +0100 Subject: [PATCH] XML typography more homogeneous, parameter model_url of add_model made optional with mandatory keyword --- pyvo/mivot/writer/annotations.py | 42 ++++++++++++++++---------------- pyvo/mivot/writer/instance.py | 34 +++++++++++++------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/pyvo/mivot/writer/annotations.py b/pyvo/mivot/writer/annotations.py index 61200980..7d53e132 100644 --- a/pyvo/mivot/writer/annotations.py +++ b/pyvo/mivot/writer/annotations.py @@ -78,7 +78,7 @@ def __init__(self): @property def mivot_block(self): """ - Getter for the MIVOT block. + Getter for the whole MIVOT block. Returns ------- @@ -89,12 +89,12 @@ def mivot_block(self): def _get_report(self): """ - Generates the REPORT component of the MIVOT block. + Generate the component of the MIVOT block. Returns ------- str - The REPORT block as a string, indicating the success or failure of the process. + The block as a string, indicating the success or failure of the process. """ if self._report_status: return f'{self._report_message}' @@ -103,12 +103,12 @@ def _get_report(self): def _get_models(self): """ - Generates the MODEL components of the MIVOT block. + Generate the components of the MIVOT block. Returns ------- str - The MODEL components as a formatted string. + The components as a formatted string. """ models_block = "" for key, value in self._models.items(): @@ -121,12 +121,12 @@ def _get_models(self): def _get_globals(self): """ - Generates the GLOBALS component of the MIVOT block. + Generate the component of the MIVOT block. Returns ------- str - The GLOBALS block as a formatted string. + The block as a formatted string. """ globals_block = "\n" for glob in self._globals: @@ -137,12 +137,12 @@ def _get_globals(self): def _get_templates(self): """ - Generates the TEMPLATES component of the MIVOT block. + Generate the component of the MIVOT block. Returns ------- str - The TEMPLATES block as a formatted string, or an empty string if no templates are defined. + The block as a formatted string, or an empty string if no templates are defined. """ if not self._templates: return "" @@ -158,13 +158,13 @@ def _get_templates(self): def build_mivot_block(self, *, templates_id=None): """ - Builds a complete MIVOT block from the declared components and validates it + Build a complete MIVOT block from the declared components and validates it against the MIVOT XML schema. Parameters ---------- templates_id : str, optional - The ID to associate with the TEMPLATES block. Defaults to None. + The ID to associate with the block. Defaults to None. Raises ------ @@ -188,12 +188,12 @@ def build_mivot_block(self, *, templates_id=None): def add_templates(self, templates_instance): """ - Adds an block to the block. + Add an element to the block. Parameters ---------- templates_instance : str or MivotInstance - The block to be added. + The element to be added. Raises ------ @@ -211,7 +211,7 @@ def add_templates(self, templates_instance): def add_globals(self, globals_instance): """ - Adds an block to the block. + Add an block to the block. Parameters ---------- @@ -232,22 +232,22 @@ def add_globals(self, globals_instance): "Instance added to globals must be a string or MivotInstance." ) - def add_model(self, model_name, model_url): + def add_model(self, model_name, *, model_url=None): """ - Adds a MODEL element to the MIVOT block. + Add a element to the MIVOT block. Parameters ---------- model_name : str The short name of the model. - model_url : str + model_url : str, optional The URL of the VO-DML file associated with the model. """ self._models[model_name] = model_url def set_report(self, status, message): """ - Sets the REPORT element of the MIVOT block. + Set the element of the MIVOT block. Parameters ---------- @@ -269,7 +269,7 @@ def set_report(self, status, message): def check_xml(self): """ - Validates the MIVOT block against the MIVOT XML schema v1.0. + Validate the MIVOT block against the MIVOT XML schema v1.0. Raises ------ @@ -278,7 +278,7 @@ def check_xml(self): Notes ----- - The schema is loaded from a local file to avoid dependency on a remote service. + The schema (mivot 1.0) is loaded from a local file to avoid dependency on a remote service. """ # put here just to improve the test coverage root = etree.fromstring(self._mivot_block) @@ -299,7 +299,7 @@ def check_xml(self): def insert_into_votable(self, votable_file, override=False): """ - Inserts the MIVOT block into a VOTable. + Insert the MIVOT block into a VOTable. Parameters ---------- diff --git a/pyvo/mivot/writer/instance.py b/pyvo/mivot/writer/instance.py index 6c04a1d6..a8e4b06c 100644 --- a/pyvo/mivot/writer/instance.py +++ b/pyvo/mivot/writer/instance.py @@ -40,16 +40,16 @@ def __init__(self, dmtype=None, *, dmrole=None, dmid=None): Parameters ---------- dmtype : str - The dmtype of the INSTANCE (mandatory). + dmtype of the INSTANCE (mandatory) dmrole : str, optional - The dmrole of the INSTANCE. + dmrole of the INSTANCE dmid : str, optional - The dmid of the INSTANCE. + dmid of the INSTANCE Raises ------ MappingError - If ``dmtype`` is not provided. + If ``dmtype`` is not provided """ if not dmtype: raise MappingError("Cannot build an instance without dmtype") @@ -65,20 +65,20 @@ def add_attribute(self, dmtype=None, dmrole=None, *, ref=None, value=None, unit= Parameters ---------- dmtype : str - The dmtype of the ATTRIBUTE (mandatory). + dmtype of the ATTRIBUTE (mandatory) dmrole : str - The dmrole of the ATTRIBUTE (mandatory). + dmrole of the ATTRIBUTE (mandatory) ref : str, optional - ID of the column to set the attribute value. + ID of the column to set the attribute value value : str, optional - Default value of the attribute. + Default value of the attribute unit : str, optional - Unit of the attribute. + Unit of the attribute Raises ------ MappingError - If ``dmtype`` or ``dmrole`` is not provided, or if both ``ref`` and ``value`` are not defined. + If ``dmtype`` or ``dmrole`` is not provided, or if both ``ref`` and ``value`` are not defined """ if not dmtype: raise MappingError("Cannot add an attribute without dmtype") @@ -104,14 +104,14 @@ def add_reference(self, dmrole=None, dmref=None): Parameters ---------- dmrole : str - The dmrole of the REFERENCE (mandatory). + dmrole of the REFERENCE (mandatory) dmref : str - The dmref of the REFERENCE (mandatory). + dmref of the REFERENCE (mandatory) Raises ------ MappingError - If ``dmrole`` or ``dmref`` is not provided. + If ``dmrole`` or ``dmref`` is not provided """ if not dmref: raise MappingError("Cannot add a reference without dmref") @@ -128,12 +128,12 @@ def add_instance(self, mivot_instance): Parameters ---------- mivot_instance : MivotInstance - The INSTANCE to be added. + INSTANCE to be added Raises ------ MappingError - If ``mivot_instance`` is not of type ``MivotInstance``. + If ``mivot_instance`` is not of type ``MivotInstance`` """ if not isinstance(mivot_instance, MivotInstance): raise MappingError("Instance added must be of type MivotInstance") @@ -141,12 +141,12 @@ def add_instance(self, mivot_instance): def xml_string(self): """ - Build and serialize the INSTANCE element to a string. + Build and serialize the element as a string. Returns ------- str - The string representation of the INSTANCE element. + The string representation of the element """ xml_string = f'