From 4dd17a5dbe1ca12be68a42cc3151b5e553712fc5 Mon Sep 17 00:00:00 2001 From: Mark Morgan Date: Wed, 18 Nov 2015 14:24:59 +0100 Subject: [PATCH] 1. python 3 compliance preparation. 2. QC properties display in viewer. 3. Made configuration loading implicit rather than explicit. --- MANIFEST.in | 1 + README.rst | 11 +- ...-experiment-definitions-with-pyesdoc.ipynb | 82 ++-- jobs/run_archive_echo.py | 2 + jobs/run_archive_populate.py | 1 + pyesdoc/__init__.py | 14 +- pyesdoc/archive/config.py | 44 +- pyesdoc/archive/folder_info.py | 2 +- pyesdoc/archive/manager.py | 25 +- pyesdoc/archive/parsing/doc_parser.py | 2 +- pyesdoc/archive/populate_from_feeds.py | 2 +- pyesdoc/codecs/dictionary/decoder.py | 39 +- pyesdoc/codecs/html/fieldsets/field_info.py | 4 +- ...are_model_component_hierarchy_details.html | 35 ++ .../codecs/html/templates/core/document.html | 2 +- pyesdoc/codecs/json/decoder.py | 9 +- pyesdoc/codecs/xml/decoder.py | 28 +- pyesdoc/codecs/xml/encoder.py | 3 +- pyesdoc/codecs/xml_metafor_cim_v1/decoder.py | 4 +- .../xml_metafor_cim_v1/decoder_utils.py | 174 +++---- pyesdoc/constants.py | 14 +- pyesdoc/exceptions.py | 16 +- .../cim/v1/software_model_component.py | 61 ++- .../v1/software_model_component_property_1.py | 8 +- .../v1/software_model_component_property_2.py | 30 +- pyesdoc/extensions/default.py | 24 +- pyesdoc/extensions/extender.py | 19 +- pyesdoc/factory.py | 12 +- pyesdoc/ontologies/__init__.py | 8 +- .../cim/v1/decoder_for_activity_package.py | 390 ++++++--------- .../cim/v1/decoder_for_data_package.py | 147 ++---- .../cim/v1/decoder_for_grids_package.py | 115 ++--- .../cim/v1/decoder_for_misc_package.py | 7 +- .../cim/v1/decoder_for_quality_package.py | 52 +- .../cim/v1/decoder_for_shared_package.py | 317 +++++------- .../cim/v1/decoder_for_software_package.py | 268 ++++------- .../ontologies/cim/v1/decoder_xml_utils.py | 174 +++---- .../cim/v1/typeset_for_activity_package.py | 56 +-- .../cim/v1/typeset_for_data_package.py | 64 +-- .../cim/v1/typeset_for_grids_package.py | 58 +-- .../cim/v1/typeset_for_quality_package.py | 20 +- .../cim/v1/typeset_for_shared_package.py | 126 ++--- .../cim/v1/typeset_for_software_package.py | 56 +-- pyesdoc/ontologies/cim/v1/typeset_meta.py | 451 +++++++++--------- .../cim/v2/typeset_for_activity_package.py | 22 +- .../cim/v2/typeset_for_data_package.py | 8 +- .../cim/v2/typeset_for_drs_package.py | 22 +- .../cim/v2/typeset_for_platform_package.py | 30 +- .../cim/v2/typeset_for_science_package.py | 36 +- .../cim/v2/typeset_for_shared_package.py | 56 +-- .../cim/v2/typeset_for_software_package.py | 26 +- pyesdoc/ontologies/cim/v2/typeset_meta.py | 242 +++++----- pyesdoc/options.py | 5 +- pyesdoc/publishing.py | 25 +- pyesdoc/serialization.py | 8 +- pyesdoc/utils/__init__.py | 3 +- pyesdoc/utils/config.py | 49 +- pyesdoc/utils/convert.py | 38 +- pyesdoc/utils/functional.py | 69 --- pyesdoc/utils/runtime.py | 284 ++--------- pyesdoc/validation/validator.py | 1 - setup.py | 2 +- tests/test_archive.py | 35 +- tests/test_factory.py | 21 +- tests/test_general.py | 7 +- tests/test_publishing.py | 8 +- tests/test_serialization.py | 4 +- tests/test_type_cim_v1_activity_ensemble_1.py | 16 +- tests/test_type_cim_v1_activity_ensemble_2.py | 3 - ...pe_cim_v1_activity_numerical_experiment.py | 21 +- ...est_type_cim_v1_activity_simulation_run.py | 3 - tests/test_type_cim_v1_data_data_object_1.py | 3 - tests/test_type_cim_v1_data_data_object_2.py | 3 - tests/test_type_cim_v1_grids_gridspec.py | 3 - tests/test_type_cim_v1_misc_document_set.py | 3 - tests/test_type_cim_v1_quality_cim_quality.py | 3 - tests/test_type_cim_v1_shared_platform.py | 3 - ..._type_cim_v1_software_model_component_1.py | 3 - ..._type_cim_v1_software_model_component_2.py | 3 - ...v1_software_statistical_model_component.py | 5 +- tests/test_types.py | 1 - tests/test_utils.py | 2 - 82 files changed, 1718 insertions(+), 2335 deletions(-) delete mode 100644 pyesdoc/utils/functional.py diff --git a/MANIFEST.in b/MANIFEST.in index cf909aa..10aedc3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ recursive-include pyesdoc *.py include LICENSE include README.rst +include pyesdoc.conf include requirements.txt include runtests.sh diff --git a/README.rst b/README.rst index 8ebdcbd..72b2bfc 100644 --- a/README.rst +++ b/README.rst @@ -28,16 +28,7 @@ Who uses pyesdoc ? Developers building value added software ontop of the ES-DOC eco-system. -What are the contents of pyesdoc ? --------------------------------------- - - \docs Library documentation. - \jobs Jobs to be run from command line. - \pyesdoc Source code. - \tests Unit tests. - - Further Information ? -------------------------------------- -Please refer to the [splash page](http:es-doc.org) for further information. \ No newline at end of file +See http:es-doc.org. \ No newline at end of file diff --git a/ipython-notebooks/creating-cmip6-experiment-definitions-with-pyesdoc.ipynb b/ipython-notebooks/creating-cmip6-experiment-definitions-with-pyesdoc.ipynb index acd8e13..50a0ced 100644 --- a/ipython-notebooks/creating-cmip6-experiment-definitions-with-pyesdoc.ipynb +++ b/ipython-notebooks/creating-cmip6-experiment-definitions-with-pyesdoc.ipynb @@ -51,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 3, "metadata": { "collapsed": true }, @@ -76,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "metadata": { "collapsed": false }, @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -105,19 +105,11 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 6, "metadata": { "collapsed": false }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1e19715f-d743-4f4e-b8e9-2b1765f638e8\n" - ] - } - ], + "outputs": [], "source": [ "# Create experimental requirement.\n", "tc = pyesdoc.create(cim.v2.TemporalConstraint, project=_PROJECT, author=author, source=_SOURCE)\n", @@ -133,7 +125,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 8, "metadata": { "collapsed": false }, @@ -158,7 +150,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 9, "metadata": { "collapsed": true }, @@ -174,7 +166,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "collapsed": true }, @@ -193,11 +185,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "doc.requirements[0].canonical_name --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].description --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].duration.date_type --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].duration.units --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].meta.metadata_author.email --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].meta.metadata_author.name --> is of invalid type (actual = , expected=)\n", + "doc.requirements[0].name --> is of invalid type (actual = , expected=)\n", + "doc.canonical_name --> is of invalid type (actual = , expected=)\n", + "doc.description --> is of invalid type (actual = , expected=)\n", + "doc.long_name --> is of invalid type (actual = , expected=)\n", + "doc.meta.metadata_author.email --> is of invalid type (actual = , expected=)\n", + "doc.meta.metadata_author.name --> is of invalid type (actual = , expected=)\n", + "doc.name --> is of invalid type (actual = , expected=)\n", + "doc.rationale --> is of invalid type (actual = , expected=)\n" + ] + } + ], "source": [ "# Validate document & print errors\n", "errors = pyesdoc.validate(experiment)\n", @@ -214,7 +227,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "collapsed": false }, @@ -226,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -238,7 +251,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": { "collapsed": false }, @@ -250,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -262,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "collapsed": false, "scrolled": false @@ -282,7 +295,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "collapsed": false }, @@ -294,7 +307,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "collapsed": false }, @@ -307,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "collapsed": false }, @@ -327,11 +340,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Cannot publish invalid documents.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Publish to ES-DOC web-service\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mpyesdoc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublish\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexperiment\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/Users/macg/dev/esdoc/repos/esdoc-py-client/pyesdoc/publishing.pyc\u001b[0m in \u001b[0;36mpublish\u001b[0;34m(doc)\u001b[0m\n\u001b[1;32m 198\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Cannot publish null documents.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_valid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdoc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 200\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Cannot publish invalid documents.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 201\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 202\u001b[0m \u001b[0;31m# Increment version.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mValueError\u001b[0m: Cannot publish invalid documents." + ] + } + ], "source": [ "# Publish to ES-DOC web-service\n", "pyesdoc.publish(experiment)" diff --git a/jobs/run_archive_echo.py b/jobs/run_archive_echo.py index b862f26..eb3a8b5 100644 --- a/jobs/run_archive_echo.py +++ b/jobs/run_archive_echo.py @@ -26,6 +26,8 @@ def _main(): """Main entry point. """ + pyesdoc.archive.init() + document = pyesdoc.archive.load(options.uid, options.version) if not document: pyesdoc.rt.log("document not found") diff --git a/jobs/run_archive_populate.py b/jobs/run_archive_populate.py index 65a59c8..bbc2ac2 100644 --- a/jobs/run_archive_populate.py +++ b/jobs/run_archive_populate.py @@ -26,6 +26,7 @@ def _main(): """Main entry point. """ + pyesdoc.archive.init() pyesdoc.archive.populate(options.throttle, options.project) diff --git a/pyesdoc/__init__.py b/pyesdoc/__init__.py index f29e928..c7d04a3 100644 --- a/pyesdoc/__init__.py +++ b/pyesdoc/__init__.py @@ -11,6 +11,14 @@ .. moduleauthor:: Earth System Documentation (ES-DOC) """ +# Standard package info. +__title__ = 'pyesdoc' +__version__ = '0.9.3.6' +__author__ = 'ES-DOC' +__license__ = 'GPL' +__copyright__ = 'Copyright 2015 ES-DOC' + + from pyesdoc.constants import * from pyesdoc.exceptions import * from pyesdoc.factory import create @@ -47,9 +55,3 @@ from pyesdoc import validation -# Standard package info. -__title__ = 'pyesdoc' -__version__ = '0.9.3.2' -__author__ = 'ES-DOC' -__license__ = 'GPL' -__copyright__ = 'Copyright 2015 ES-DOC' diff --git a/pyesdoc/archive/config.py b/pyesdoc/archive/config.py index 8ed2b82..3ba8b5b 100644 --- a/pyesdoc/archive/config.py +++ b/pyesdoc/archive/config.py @@ -10,30 +10,48 @@ """ -import os - from pyesdoc.utils import config -# Archive location comes from config. -DIR_ARCHIVE = config.archive.location - -# Set of supported projects. -PROJECTS = config.archive.projects - -# Set of supported sources. -SOURCES = config.archive.sources - - def get_project_sources(): """Returns iterable of unique project/source pairs. """ + config.init() + result = [] - for project in PROJECTS: + for project in get_projects(): for source in (f.source for f in project.feeds): if (project.name, source) not in result: result.append((project.name, source)) return tuple(result) + + +def get_directory(): + """Returns archive directory as defined withn pyesdoc.conf. + + """ + config.init() + + return config.data.archive.location + + +def get_projects(): + """Returns set of archive projects. + + """ + config.init() + + return config.data.archive.projects + + +def get_sources(): + """Returns set of archive sources. + + """ + config.init() + + return config.data.archive.sources + diff --git a/pyesdoc/archive/folder_info.py b/pyesdoc/archive/folder_info.py index 7681602..62dca67 100644 --- a/pyesdoc/archive/folder_info.py +++ b/pyesdoc/archive/folder_info.py @@ -51,7 +51,7 @@ def __repr__(self): """Instance representation. """ - return "{0}".format(self.path) + return "SSSS{0}".format(self.path) @property def exists(self): diff --git a/pyesdoc/archive/manager.py b/pyesdoc/archive/manager.py index ef20a38..d3a35d6 100644 --- a/pyesdoc/archive/manager.py +++ b/pyesdoc/archive/manager.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- """ -.. module:: model.py +.. module:: archive/manager.py :copyright: @2013 Earth System Documentation (http://es-doc.org) :license: GPL/CeCIL :platform: Unix, Windows - :synopsis: A model of a document archive. + :synopsis: Manages access to the document archive. .. moduleauthor:: Mark Conway-Greenslade @@ -13,7 +13,8 @@ """ import os -from pyesdoc.archive import config, constants +from pyesdoc.archive import config +from pyesdoc.archive import constants from pyesdoc.archive.file_info import ArchiveFileInfo from pyesdoc.archive.folder_info import ArchiveFolderInfo @@ -22,13 +23,17 @@ # Set of managed folders. _FOLDERS = set() -# Initialized managed folders from configuration file. -for project, source in config.get_project_sources(): - path = os.path.join(config.DIR_ARCHIVE, project) - path = os.path.join(path, source) - if not os.path.exists(path): - os.makedirs(path) - _FOLDERS.add(ArchiveFolderInfo(project, source, path)) + +def init(): + """Initializes archive manager. + + """ + for project, source in config.get_project_sources(): + path = os.path.join(config.get_directory(), project) + path = os.path.join(path, source) + if not os.path.exists(path): + os.makedirs(path) + _FOLDERS.add(ArchiveFolderInfo(project, source, path)) def delete_error_files(project=None, source=None): diff --git a/pyesdoc/archive/parsing/doc_parser.py b/pyesdoc/archive/parsing/doc_parser.py index 8d53731..93b568a 100644 --- a/pyesdoc/archive/parsing/doc_parser.py +++ b/pyesdoc/archive/parsing/doc_parser.py @@ -45,7 +45,7 @@ def _get_source_description(source): """Returns document source description. """ - for source_cfg in config.SOURCES: + for source_cfg in config.get_sources(): if source_cfg.name == source: return source_cfg.description return source diff --git a/pyesdoc/archive/populate_from_feeds.py b/pyesdoc/archive/populate_from_feeds.py index c39f73a..ea40d3a 100644 --- a/pyesdoc/archive/populate_from_feeds.py +++ b/pyesdoc/archive/populate_from_feeds.py @@ -96,7 +96,7 @@ def _yield_feeds(project_filter=None): """Yields feeds to be processed. """ - for project in config.PROJECTS: + for project in config.get_projects(): if project_filter and project.name != project_filter: continue for feed in [f for f in project.feeds if f.is_active]: diff --git a/pyesdoc/codecs/dictionary/decoder.py b/pyesdoc/codecs/dictionary/decoder.py index a0651af..0b6471a 100644 --- a/pyesdoc/codecs/dictionary/decoder.py +++ b/pyesdoc/codecs/dictionary/decoder.py @@ -20,48 +20,51 @@ -def _get_doc(d, doc_type): - """Returns document.""" - if doc_type.type_key != d['ontology_type_key']: - doc_type = ontologies.get_type_from_key(d['ontology_type_key']) +def _get_doc(obj, doc_type): + """Returns document. + + """ + if doc_type.type_key != obj['ontology_type_key']: + doc_type = ontologies.get_type_from_key(obj['ontology_type_key']) if doc_type is None: - rt.raise_error('Decoding type is unrecognized') + raise ValueError('Decoding type is unrecognized') return doc_type(), ontologies.get_type_info(doc_type) -def _decode_simple(v, type, iterable): - """Decodes a simple value.""" +def _decode_simple(value, target_type, iterable): + """Decodes a simple value. + + """ if iterable: - return map(lambda i : convert.str_to_typed_value(i, type), v) - else: - return convert.str_to_typed_value(v, type) + return [convert.text_to_typed_value(i, target_type) for i in value] + return convert.text_to_typed_value(value, target_type) -def _decode(v, type, iterable): +def _decode(value, doc_type, iterable): """Decodes a dictionary. """ - def _do(d): + def _do(obj): # Create doc. - doc, doc_type_info = _get_doc(d, type) + doc, doc_type_info = _get_doc(obj, doc_type) # Set doc attributes. for _name, _type, _required, _iterable in doc_type_info: # ... set placeholders - if _name not in d: + if _name not in obj: continue # ... set nulls - elif d[_name] is None: + elif obj[_name] is None: setattr(doc, _name, [] if _iterable else None) # ... set simple / complex types else: decoder = _decode if _type in ontologies.get_types() else _decode_simple - setattr(doc, _name, decoder(d[_name], _type, _iterable)) + setattr(doc, _name, decoder(obj[_name], _type, _iterable)) return doc - return _do(v) if not iterable else map(lambda i : _do(i), v) + return _do(value) if not iterable else [_do(i) for i in value] def decode(as_dict): @@ -76,7 +79,7 @@ def decode(as_dict): # Format keys. as_dict = convert.dict_keys(as_dict, convert.str_to_underscore_case) if 'ontology_type_key' not in as_dict: - rt.raise_error('Ontology type key is unspecified and therefore the document cannot be decoded.') + raise KeyError('ontology_type_key is unspecified and therefore the document cannot be decoded.') # Get document type. doc_type_key = as_dict['ontology_type_key'] diff --git a/pyesdoc/codecs/html/fieldsets/field_info.py b/pyesdoc/codecs/html/fieldsets/field_info.py index 0537797..f5f8c0a 100644 --- a/pyesdoc/codecs/html/fieldsets/field_info.py +++ b/pyesdoc/codecs/html/fieldsets/field_info.py @@ -14,7 +14,7 @@ import datetime from pyesdoc.utils import convert -from pyesdoc.utils import functional +from pyesdoc.utils import runtime as rt @@ -150,7 +150,7 @@ def is_collection_reference(attr): # ... collection filter by attribute elif "=" in attr: left, right = attr.split("=") - value = functional.first(value, left, right.lower(), lambda v: unicode(v).lower()) + value = rt.first(value, left, right.lower(), lambda v: unicode(v).lower()) # ... item attribute filter elif hasattr(value, attr): value = getattr(value, attr) diff --git a/pyesdoc/codecs/html/templates/cim_1/software_model_component_hierarchy_details.html b/pyesdoc/codecs/html/templates/cim_1/software_model_component_hierarchy_details.html index 5c6a8d1..445d51e 100644 --- a/pyesdoc/codecs/html/templates/cim_1/software_model_component_hierarchy_details.html +++ b/pyesdoc/codecs/html/templates/cim_1/software_model_component_hierarchy_details.html @@ -49,6 +49,41 @@
Scientific Properties ({{ len(c.ext.displayable_scientific_properties) }}) {% end %} + {% comment *************************** %} + {% comment ... quality control properties %} + {% comment *************************** %} + {% if c.ext.displayable_qc_properties %} +
+
+
Documentation Quality Control Properties
+
+ + + {% for p in c.ext.displayable_qc_properties %} + {% for v in sorted(p.values) %} + + + + {% end %} + {% end %} + +
+ {{ " > ".join(p.ext.display_name.split(" > ")[1:]) }}: + {% if p.ext.short_display_name == "Verification Status" %} + {% if v == "0" %} + Awaiting review + {% elif v == "1" %} + Under review + {% elif v == "2" %} + Accepted + {% end %} + {% else %} + {{v}} + {% end %} +
+
+ {% end %} + {% comment *************** %} {% comment ... citations %} {% comment *************** %} diff --git a/pyesdoc/codecs/html/templates/core/document.html b/pyesdoc/codecs/html/templates/core/document.html index 1e2ec24..840ef5a 100644 --- a/pyesdoc/codecs/html/templates/core/document.html +++ b/pyesdoc/codecs/html/templates/core/document.html @@ -18,7 +18,7 @@

{{ doc.ext.full_display_name }}

- ES-DOC Documentation Viewer (v0.9.2.1) © ES-DOC 2014 + ES-DOC Documentation Viewer (v0.9.3.0) © ES-DOC 2014

diff --git a/pyesdoc/codecs/json/decoder.py b/pyesdoc/codecs/json/decoder.py index fc70f3a..7b662d5 100644 --- a/pyesdoc/codecs/json/decoder.py +++ b/pyesdoc/codecs/json/decoder.py @@ -26,11 +26,14 @@ def decode(as_json): :rtype: object """ + # Convert to unicode. + as_json = convert.str_to_unicode(as_json) + # Convert to dictionary. - d = convert.json_to_dict(convert.str_to_unicode(as_json)) + as_dict = convert.json_to_dict(as_json) # Format dictionary keys. - d = convert.dict_keys(d, convert.str_to_underscore_case) + as_dict = convert.dict_keys(as_dict, convert.str_to_underscore_case) # Decode from dictionary. - return dict_decoder.decode(d) + return dict_decoder.decode(as_dict) diff --git a/pyesdoc/codecs/xml/decoder.py b/pyesdoc/codecs/xml/decoder.py index 7288dbe..152843a 100644 --- a/pyesdoc/codecs/xml/decoder.py +++ b/pyesdoc/codecs/xml/decoder.py @@ -24,27 +24,33 @@ def _get_doc(xml, doc_type): - """Returns document.""" + """Returns document. + + """ type_key = xml.get('ontologyTypeKey') if type_key and doc_type.type_key != type_key: doc_type = ontologies.get_type_from_key(xml.get('ontologyTypeKey')) if doc_type is None: - rt.raise_error('Decoding type is unrecognized') + raise ValueError('Decoding type is unrecognized') return doc_type(), ontologies.get_type_info(doc_type) def _decode_simple(v, type, iterable): - """Decodes a simple value.""" + """Decodes a simple type value. + + """ if iterable: - return map(lambda i : convert.str_to_typed_value(i.text, type), v) + return [convert.text_to_typed_value(i.text, type) for i in v] else: - return convert.str_to_typed_value(v.text, type) + return convert.text_to_typed_value(v.text, type) + +def _decode_complex(val, doc_type, iterable): + """Decodes a complex type value. -def _decode_complex(v, doc_type, iterable): - """Decodes a complex type.""" - def _do(xml): + """ + def _decode(xml): # Set doc. doc, doc_type_info = _get_doc(xml, doc_type) @@ -60,7 +66,7 @@ def _do(xml): return doc - return map(lambda i : _do(i), v) if iterable else _do(v) + return [_decode(i) for i in val] if iterable else _decode(val) def decode(as_xml): @@ -81,10 +87,10 @@ def decode(as_xml): # Verify etree. if not isinstance(as_xml, ET.Element): - rt.throw("Cannot decode non xml documents") + raise TypeError("Cannot decode non xml documents") # Get target type. doc_type_key = as_xml.get("ontologyTypeKey") doc_type = ontologies.get_type_from_key(doc_type_key) - return _decode_complex(as_xml, doc_type, False) \ No newline at end of file + return _decode_complex(as_xml, doc_type, False) diff --git a/pyesdoc/codecs/xml/encoder.py b/pyesdoc/codecs/xml/encoder.py index 40cac59..2e91a63 100644 --- a/pyesdoc/codecs/xml/encoder.py +++ b/pyesdoc/codecs/xml/encoder.py @@ -63,11 +63,10 @@ def _encode_simple(xml, val): elif isinstance(val, datetime.time): val = val.isoformat() else: - val = unicode(val) + val = convert.str_to_unicode(val) if val is None or len(val) == 0: val = u'' - # Assign to xml. xml.text = val.strip() diff --git a/pyesdoc/codecs/xml_metafor_cim_v1/decoder.py b/pyesdoc/codecs/xml_metafor_cim_v1/decoder.py index 1f9e0eb..96ead5a 100644 --- a/pyesdoc/codecs/xml_metafor_cim_v1/decoder.py +++ b/pyesdoc/codecs/xml_metafor_cim_v1/decoder.py @@ -48,12 +48,12 @@ def decode(as_xml): # Defensive programming. xml, nsmap = load_xml(as_xml, return_nsmap=True) if not isinstance(xml, et._Element): - rt.raise_error('Decoding failure due to invalid Metafor CIM v1 XML.') + raise TypeError('Decoding failure due to invalid Metafor CIM v1 XML.') # Validate decoder. doc_type = xml.tag.split('}')[1] if doc_type not in _decoders: - rt.raise_error("CIM v1 - {0} document type decoding unsupported.".format(doc_type)) + raise ValueError("CIM v1 - {0} document type decoding unsupported.".format(doc_type)) # Decode pyesdoc doc. return decode_xml(_decoders[doc_type], xml, nsmap, None) diff --git a/pyesdoc/codecs/xml_metafor_cim_v1/decoder_utils.py b/pyesdoc/codecs/xml_metafor_cim_v1/decoder_utils.py index fcacefa..34e50cb 100644 --- a/pyesdoc/codecs/xml_metafor_cim_v1/decoder_utils.py +++ b/pyesdoc/codecs/xml_metafor_cim_v1/decoder_utils.py @@ -24,101 +24,87 @@ # Null uuid for checking whether one has to be generated. -NULL_UUID = ['00000000-0000-0000-0000-000000000000'] +NULL_UUID = u'00000000-0000-0000-0000-000000000000' -def _get_value_as_string(xml, nsmap): - """Converts passed xml fragment to a string.""" - result = None - - # Strip first item from iterables. +def _get_value(xml, rtype=unicode): + """Returns xml node value.""" + # Get xml value. if isinstance(xml, types.ListType): - if len(xml) > 0: - xml = xml[0] - else: - xml = None - - # Get raw string. + xml = None if len(xml) == 0 else xml[0] if xml is None: - result = None - elif isinstance(xml, types.StringTypes): - result = convert.unicode_to_str(xml) + return None + + # Get unicode. + if rtype is unicode: + if isinstance(xml, types.StringTypes): + result = convert.str_to_unicode(xml) + else: + result = convert.str_to_unicode(et.tostring(xml)) else: - result = et.tostring(xml) + if isinstance(xml, types.StringTypes): + result = convert.unicode_to_str(xml) + else: + result = et.tostring(xml) - # Format string. - if result is not None: - result = result.strip() - result = result.rstrip('|') + # Format. + result = result.strip() + result = result.rstrip('|') return result -def _convert_to_string(xml, nsmap=None): - """Converts an etree element xml representation into a string type.""" - return _get_value_as_string(xml, nsmap) +def _convert_to_unicode(xml, nsmap=None): + """Converts an etree element xml representation into a unicode type.""" + return _get_value(xml, str) def _convert_to_bool(xml, nsmap=None): """Converts an etree element xml representation into a boolean type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: - return bool() - else: - as_string = as_string.upper() - if as_string in ['TRUE']: - return True - elif as_string in ['FALSE']: - return False - else: - return bool() + value = _get_value(xml) + + return True if value is not None and value.lower() in [u'true'] else bool() def _convert_to_integer(xml, nsmap=None): """Converts an etree element xml representation into an integer type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None or as_string.upper() == 'NONE': - return int() - else: - return int(as_string) + value = _get_value(xml) + + return int(value) if value is not None and value.upper() != u'NONE' else int() def _convert_to_float(xml, nsmap=None): """Converts an etree element xml representation into a float type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: - return float() - else: - return float(as_string) + value = _get_value(xml) + + return float(value) if value is not None else float() def _convert_to_uid(xml, nsmap=None): """Converts an etree element xml representation into a uid type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None or as_string in NULL_UUID: + value = _get_value(xml) + if value is None or value == NULL_UUID: return uuid.uuid4() - else: - try: - return uuid.UUID(as_string) - except ValueError: - # Workaround for poorly encoded uuid's in cmip5 questionnaire - return uuid.UUID(as_string[0:36]) + try: + return uuid.UUID(value) + except ValueError: + return uuid.UUID(value[0:36]) def _convert_to_datetime(xml, nsmap=None): """Converts an etree element xml representation into a datetime type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: + value = _get_value(xml) + if value is None: return None + if len(value) == 4: + return arrow.get(value, u"YYYY").datetime else: - if len(as_string) == 4: - return arrow.get(as_string, 'YYYY').datetime - else: - return arrow.get(as_string).datetime + return arrow.get(value).datetime + # Set of simple type convertors. -_simple_type_decoders = { +_SIMPLE_TYPE_DECODERS = { 'bool' : _convert_to_bool, 'date' : _convert_to_datetime, 'datetime' : _convert_to_datetime, @@ -126,8 +112,9 @@ def _convert_to_datetime(xml, nsmap=None): 'datetime.datetime' : _convert_to_datetime, 'float' : _convert_to_float, 'int' : _convert_to_integer, - 'str' : _convert_to_string, - 'uri' : _convert_to_string, + 'str' : _convert_to_unicode, + 'unicode' : _convert_to_unicode, + 'uri' : _convert_to_unicode, 'uuid' : _convert_to_uid, 'uuid.UUID' : _convert_to_uid, } @@ -136,17 +123,10 @@ def _convert_to_datetime(xml, nsmap=None): def set_attributes(target, xml, nsmap, decodings): """Decodes entity attributes from a collection of decodings. - :param target: A pyesdoc object with a set of attributes to be assigned. - :type target: object - - :param xml: An xml element. - :type xml: lxml.etree._Element - - :param nsmap: Set of xml namespace mappings. - :type nsmap: dict - - :param decodings: Set of mappings used to perform decoding. - :type decodings: dict + :param object target: A pyesdoc object with a set of attributes to be assigned. + :param lxml.etree._Element xml: An xml element. + :param dict nsmap: Set of xml namespace mappings. + :param dict decodings: Set of mappings used to perform decoding. :returns: A pyesdoc object with assigned attributes. :rtype: object @@ -164,7 +144,7 @@ def set_attributes(target, xml, nsmap, decodings): attrs.append(attr) # Determine if type is a simple one. - is_simple_type = type in _simple_type_decoders + is_simple_type = type in _SIMPLE_TYPE_DECODERS try: _set_attribute(target, @@ -237,48 +217,34 @@ def _set_attribute(target, def _get_attribute_value(xml, nsmap, decoder, xpath, is_simple_type, is_iterable): """Gets the value of an attribute from xml.""" - result = None - # Apply xpath (derive xml fragment from value is derived). att_xml = xml.xpath(xpath, namespaces=nsmap) if not att_xml: - return None if not is_iterable else [] + return [] if is_iterable else None # From xml derive value. # ... simple types. if is_simple_type: - if decoder in _simple_type_decoders: - decoder = _simple_type_decoders[decoder] + if decoder in _SIMPLE_TYPE_DECODERS: + decoder = _SIMPLE_TYPE_DECODERS[decoder] if is_iterable: - result = map(lambda i: decoder(i, nsmap), att_xml) + return [decoder(i, nsmap) for i in att_xml] else: - result = decoder(att_xml, nsmap) + decoded = decoder(att_xml, nsmap) + return None if decoded == str() else decoded # ... complex types. else: - result = decode_xml(decoder, att_xml, nsmap, is_iterable) - - # Workaround - decoding empty xml attributes. - if is_simple_type and not is_iterable and result == str(): - result = None - - return result + return decode_xml(decoder, att_xml, nsmap, is_iterable) def decode_xml(decoder, xml, nsmap, is_iterable): """Decodes either an entity or an entity collection from xml. - :param decoder: Decoder function pointer. - :type decoder: function - - :param xml: An xml element. - :type xml: lxml.etree._Element - - :param nsmap: Set of xml namespace mappings. - :type nsmap: dict - - :param take_first: Flag indicating whether to return only the first entity of a collection. - :type take_first: bool + :param function decoder: Decoder function pointer. + :param lxml.etree._Element xml: An xml element. + :param dict nsmap: Set of xml namespace mappings. + :param bool take_first: Flag indicating whether to return only the first entity of a collection. :returns: Decoded entity or entity collection. :rtype: miscellaneous @@ -311,14 +277,9 @@ def decode_xml(decoder, xml, nsmap, is_iterable): def load_xml(xml, return_nsmap=False, default_ns='cim'): """Loads etree xml element. - :param xml: An xml blob. - :type xml: string - - :param return_nsmap: Flag indicating whether namespace map will be returned or not. - :type return_nsmap: bool - - :param default_ns: Default namespace. - :type default_ns: str + :param string xml: An xml blob. + :param bool return_nsmap: Flag indicating whether namespace map will be returned or not. + :param str default_ns: Default namespace. :returns: XML element. :rtype: lxml.etree._Element @@ -328,7 +289,6 @@ def load_xml(xml, return_nsmap=False, default_ns='cim'): if xml is None: raise pyesdoc.DecodingException("XML is undefined.") - # ... etree elements. nsmap = None if isinstance(xml, et._Element): diff --git a/pyesdoc/constants.py b/pyesdoc/constants.py index a84c5f3..aa4129a 100644 --- a/pyesdoc/constants.py +++ b/pyesdoc/constants.py @@ -59,20 +59,20 @@ # All document versions label. ESDOC_DOC_VERSION_ALL = 'all' -# Default document language. -ESDOC_DEFAULT_LANGUAGE = 'en' - # Default document encoding. ESDOC_DEFAULT_ENCODING = 'json' +# Default document language. +ESDOC_DEFAULT_LANGUAGE = u'en' + # Default document project. -ESDOC_DEFAULT_PROJECT = '--' +ESDOC_DEFAULT_PROJECT = u'--' # Default document institute. -ESDOC_DEFAULT_INSTIUTE = '--' +ESDOC_DEFAULT_INSTIUTE = u'--' # Default document source. -ESDOC_DEFAULT_SOURCE = 'scripts' +ESDOC_DEFAULT_SOURCE = u'scripts' # Document viewer url. -ESDOC_VIEWER_URL = "index.html?renderMethod=id&project={0}&id={1}&version={2}" +ESDOC_VIEWER_URL = u"index.html?renderMethod=id&project={0}&id={1}&version={2}" diff --git a/pyesdoc/exceptions.py b/pyesdoc/exceptions.py index 0882bea..1f1bbb6 100644 --- a/pyesdoc/exceptions.py +++ b/pyesdoc/exceptions.py @@ -63,11 +63,11 @@ class InvalidOptionException(PYESDOC_Exception): """Raised when an attempt to access an invalid library option occurs. """ - def __init__(self): + def __init__(self, option): """Instance constructor. """ - super(InvalidOptionException, self).__init__(self, "Option is invalid.") + super(InvalidOptionException, self).__init__("Option {} is unsupported.".format(option)) class ExtendingException(PYESDOC_Exception): @@ -120,3 +120,15 @@ def __init__(self, err): err = "Document parsing failed: {}".format(err) super(ParsingException, self).__init__(err) + +class WebServiceException(PYESDOC_Exception): + """Exception raised when a web service operation fails. + + """ + def __init__(self, err): + """Instance constructor. + + """ + err = "Web service invocation failed: {}".format(err) + super(ParsingException, self).__init__(err) + diff --git a/pyesdoc/extensions/cim/v1/software_model_component.py b/pyesdoc/extensions/cim/v1/software_model_component.py index 523ed0c..2cc9e50 100644 --- a/pyesdoc/extensions/cim/v1/software_model_component.py +++ b/pyesdoc/extensions/cim/v1/software_model_component.py @@ -82,13 +82,13 @@ def _extend_component_01(ctx): if not hasattr(ctx.c, "ext"): ctx.c.ext = _ComponentExtensionInfo() if not hasattr(ctx.c.ext, "full_display_name"): - ctx.c.ext.full_display_name = str() + ctx.c.ext.full_display_name = unicode() if not hasattr(ctx.c.ext, "long_display_name"): - ctx.c.ext.long_display_name = str() + ctx.c.ext.long_display_name = unicode() if not hasattr(ctx.c.ext, "short_display_name"): - ctx.c.ext.short_display_name = str() + ctx.c.ext.short_display_name = unicode() if not hasattr(ctx.c.ext, "type_display_name"): - ctx.c.ext.type_display_name = str() + ctx.c.ext.type_display_name = unicode() ctx.c.ext.ancestors = ctx.ancestors ctx.c.ext.component_tree = [] @@ -134,16 +134,16 @@ def _extend_component_03(ctx): ctx.c.ext.short_display_name = ctx.c.type # Long name. - ctx.c.ext.long_display_name = "" + ctx.c.ext.long_display_name = unicode() if ctx.c.ext.depth > 1: ctx.c.ext.long_display_name += ctx.c.ext.parent.ext.long_display_name - ctx.c.ext.long_display_name += " > " + ctx.c.ext.long_display_name += u" > " ctx.c.ext.long_display_name += ctx.c.ext.short_display_name # Full name. if ctx.c.ext.depth > 0: ctx.c.ext.full_display_name += ctx.c.ext.parent.ext.full_display_name - ctx.c.ext.full_display_name += " > " + ctx.c.ext.full_display_name += u" > " ctx.c.ext.full_display_name += ctx.c.ext.short_display_name @@ -184,8 +184,8 @@ def _set_type_display_info(ctx): """Sets document type information. """ - ctx.meta.type_display_name = "Model" - ctx.meta.type_sort_key = "AA" + ctx.meta.type_display_name = u"Model" + ctx.meta.type_sort_key = u"AA" def _set_component_hierarchy(ctx): @@ -215,41 +215,34 @@ def _set_component_property_trees(ctx): """Extends component property tree. """ - def sort_tree(p_tree): - return sorted(p_tree, key=_get_sort_key) - - def build_tree(p_list, p_tree): + """Builds a flatted property tree. + + """ for p in p_list: p_tree.append(p) build_tree(p.sub_properties, p_tree) def get_displayable(p_tree): - return [p for p in p_tree if p.values] + """Returns only displayable properties within a tree. + """ + return [p for p in p_tree if p.values and p.values[0].lower() != 'none'] for c in [ctx.doc] + ctx.doc.ext.component_tree: - build_tree(c.ext.scientific_properties, - c.ext.scientific_property_tree) - build_tree(c.ext.standard_properties, - c.ext.standard_property_tree) - build_tree(c.ext.qc_properties, - c.ext.qc_property_tree) - - c.ext.scientific_property_tree = \ - sort_tree(c.ext.scientific_property_tree) - c.ext.standard_properties = \ - sort_tree(c.ext.standard_properties) - c.ext.qc_property_tree = \ - sort_tree(c.ext.qc_property_tree) - - c.ext.displayable_scientific_properties = \ - get_displayable(c.ext.scientific_property_tree) - c.ext.displayable_standard_properties = \ - get_displayable(c.ext.standard_property_tree) - c.ext.displayable_qc_properties = \ - get_displayable(c.ext.qc_property_tree) + # ... build trees + build_tree(c.ext.scientific_properties, c.ext.scientific_property_tree) + build_tree(c.ext.standard_properties, c.ext.standard_property_tree) + build_tree(c.ext.qc_properties, c.ext.qc_property_tree) + # ... sort trees + c.ext.scientific_property_tree = sorted(c.ext.scientific_property_tree, key=_get_sort_key) + c.ext.standard_property_tree = sorted(c.ext.standard_property_tree, key=_get_sort_key) + c.ext.qc_property_tree = sorted(c.ext.qc_property_tree, key=_get_sort_key) + # ... set displayable properties + c.ext.displayable_scientific_properties = get_displayable(c.ext.scientific_property_tree) + c.ext.displayable_standard_properties = get_displayable(c.ext.standard_property_tree) + c.ext.displayable_qc_properties = get_displayable(c.ext.qc_property_tree) def _set_component_meta_info(ctx): diff --git a/pyesdoc/extensions/cim/v1/software_model_component_property_1.py b/pyesdoc/extensions/cim/v1/software_model_component_property_1.py index 4eb6988..4370325 100644 --- a/pyesdoc/extensions/cim/v1/software_model_component_property_1.py +++ b/pyesdoc/extensions/cim/v1/software_model_component_property_1.py @@ -24,10 +24,10 @@ class _PropertyExtensionInfo(object): """Property extension properties.""" def __init__(self): - self.display_name = "" - self.full_display_name = "" - self.long_display_name = "" - self.short_display_name = "" + self.display_name = unicode() + self.full_display_name = unicode() + self.long_display_name = unicode() + self.short_display_name = unicode() def _extend_property_01(ctx): diff --git a/pyesdoc/extensions/cim/v1/software_model_component_property_2.py b/pyesdoc/extensions/cim/v1/software_model_component_property_2.py index 3b2c72a..f8bef71 100644 --- a/pyesdoc/extensions/cim/v1/software_model_component_property_2.py +++ b/pyesdoc/extensions/cim/v1/software_model_component_property_2.py @@ -12,7 +12,9 @@ def _create_property(p_tree, values, name, description): - """Sets & returns a component standard property.""" + """Sets & returns a component standard property. + + """ def append_value(p, v): if v is not None: p.values.append(v) @@ -39,7 +41,9 @@ def append_value(p, v): def _set_standard_properties_descriptive(c, p_tree): - """Sets descriptive standard properties.""" + """Sets descriptive standard properties. + + """ _create_property(p_tree, c.description, 'Description', @@ -142,7 +146,7 @@ def set_scientific_properties(c): """ # Create property group. - scipg = _create_property(c.ext.scientific_properties, + group = _create_property(c.ext.scientific_properties, None, 'Scientific Properties', 'Set of component scientific properties') @@ -151,13 +155,15 @@ def set_scientific_properties(c): for cp in c.properties: if "Key Properties" in cp.short_name or \ "KeyProperties" in cp.short_name: - scipg.sub_properties = cp.sub_properties + for cpp in cp.sub_properties: + if cpp.short_name.lower().find("qc properties") == -1: + group.sub_properties.append(cpp) return # Filter out QC properties. for cp in c.properties: - if cp.short_name.find("QC Properties") == -1: - scipg.sub_properties.append(cp) + if cp.short_name.lower().find("qc properties") == -1: + group.sub_properties.append(cp) def set_qc_properties(c): @@ -168,13 +174,13 @@ def set_qc_properties(c): """ # Create property group. - p = _create_property(c.ext.qc_properties, - None, - 'QC Properties', - 'Set of component quality control properties') + group = _create_property(c.ext.qc_properties, + None, + 'QC Properties', + 'Set of component quality control properties') # Append qc properties. for cp in c.properties: - if cp.short_name.find("QC Properties") != -1: - p.sub_properties = cp.sub_properties + if cp.short_name.lower().find("qc properties") != -1: + group.sub_properties = cp.sub_properties return diff --git a/pyesdoc/extensions/default.py b/pyesdoc/extensions/default.py index 0b58090..9ccfca5 100644 --- a/pyesdoc/extensions/default.py +++ b/pyesdoc/extensions/default.py @@ -78,15 +78,6 @@ def _set_description(ctx): ctx.ext.description = ctx.doc.long_name[:1023] -def _set_encodings(ctx): - """Returns set of file encodings for the passed document.""" - encodings = constants.ESDOC_ENCODINGS_FILE - if ctx.meta.type.startswith("cim.1"): - encodings = encodings + (constants.METAFOR_CIM_XML_ENCODING,) - - ctx.ext.encodings = ctx.meta.encodings = list(encodings) - - def _set_viewer_url(ctx): """Sets document viewer URL.""" ctx.ext.viewer_url = constants.ESDOC_VIEWER_URL.format(ctx.meta.project, @@ -99,26 +90,26 @@ def _set_full_display_name(ctx): if ctx.ext.full_display_name: return - name = "" + name = u"" if ctx.meta.project: name += ctx.meta.project.upper() - name += " " + name += u" " name += ctx.meta.type_display_name - name += " : " + name += u" : " if ctx.meta.institute and ctx.meta.institute != u"--": name += ctx.meta.institute.upper() - name += " - " + name += u" - " if ctx.ext.display_name: name += ctx.ext.display_name - name += " " + name += u" " ctx.ext.full_display_name = name.strip() def _set_sort_key(ctx): """Sets document full display name.""" - ctx.meta.sort_key = "{0}{1}".format( - ctx.meta.type_sort_key, ctx.ext.display_name or str()) + ctx.meta.sort_key = u"{0}{1}".format( + ctx.meta.type_sort_key, ctx.ext.display_name or unicode()) ctx.meta.sort_key = ctx.meta.sort_key.upper() @@ -132,7 +123,6 @@ def _set_sort_key(ctx): _set_display_name, _set_description, _set_summary_fields, - _set_encodings, _set_viewer_url, ) diff --git a/pyesdoc/extensions/extender.py b/pyesdoc/extensions/extender.py index 62dbc0c..ee23c43 100644 --- a/pyesdoc/extensions/extender.py +++ b/pyesdoc/extensions/extender.py @@ -54,15 +54,14 @@ def __init__(self): """ self.children = [] - self.css_class = str() - self.description = str() - self.display_name = str() - self.encodings = [] - self.full_display_name = str() - self.language = str() + self.css_class = unicode() + self.description = unicode() + self.display_name = unicode() + self.full_display_name = unicode() + self.language = unicode() self.summary_fields = [] - self.type = str() - self.viewer_url = str() + self.type = unicode() + self.viewer_url = unicode() def extend(doc): @@ -81,7 +80,7 @@ def extend(doc): # Verify that document type is supported. if type(doc) not in _TYPES: - rt.throw("Unsupported document type: {0}.".format(type(doc))) + raise TypeError("Unsupported document type: {0}.".format(type(doc))) # Initialize document extension information. doc.ext = DocumentExtensionInfo() @@ -129,7 +128,7 @@ def is_extendable(doc): """ # Defensive programming. if not isinstance(doc, str): - rt.assert_doc('doc', doc, "Invalid document") + rt.assert_doc(doc) doc_type = doc if isinstance(doc, str) else doc.type_key doc_type = doc_type.lower() diff --git a/pyesdoc/factory.py b/pyesdoc/factory.py index 47b1c43..e974d9d 100644 --- a/pyesdoc/factory.py +++ b/pyesdoc/factory.py @@ -25,7 +25,8 @@ def create(typeof, institute=None, language=None, source=None, - author=None): + author=None, + uid=None): """Creates a document. :param class typeof: Ontology type, e.g. cim.1.software.ModelComponent. @@ -34,6 +35,7 @@ def create(typeof, :param str language: Language wih which instance is associated. :param str source: Source application with which instance is associated. :param str author: Author wih which instance is associated. + :param uuid.UUID uid: Document unique identifier. :returns: A pyesdoc document instance. :rtype: pyesdoc object @@ -52,19 +54,23 @@ def create(typeof, project = constants.ESDOC_DEFAULT_PROJECT if not source: source = constants.ESDOC_DEFAULT_SOURCE + if not uid: + uid = uuid.uuid4() # Reformat. institute = unicode(institute).lower() language = unicode(language).lower() project = unicode(project).lower() source = unicode(source).lower() + if not isinstance(uid, uuid.UUID): + uid = uuid.UUID(uid) # Instantiate & initialize meta info (if necessary). doc = typeof() if hasattr(doc, 'meta'): now = datetime.datetime.now() doc.meta.author = author - doc.meta.id = uuid.uuid4() + doc.meta.id = uid doc.meta.version = 0 doc.meta.create_date = now doc.meta.institute = institute @@ -77,6 +83,6 @@ def create(typeof, # cim v2 support doc.meta.metadata_author = author doc.meta.metadata_last_updated = now - doc.meta.uid = str(doc.meta.id) + doc.meta.uid = unicode(uid) return doc diff --git a/pyesdoc/ontologies/__init__.py b/pyesdoc/ontologies/__init__.py index ddd0b2b..6f2c6cf 100644 --- a/pyesdoc/ontologies/__init__.py +++ b/pyesdoc/ontologies/__init__.py @@ -176,8 +176,6 @@ def get_type_from_key(key): if t.type_key.lower() == type_key: return t - return None - def is_supported(name, version, package=None, type=None): """Returns a flag indicating whether ontology/type is supported. @@ -266,10 +264,10 @@ def associate(left, attr, right): """ # Defensive Programming. - rt.assert_doc("left", left) - rt.assert_doc("right", right) + rt.assert_doc(left) + rt.assert_doc(right) if not hasattr(left, attr): - rt.throw("Cannot set association upon invalid attribute.") + raise ValueError("Cannot set association upon invalid attribute.") # Create reference. # TODO alter reference based upon ontology type. diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_activity_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_activity_package.py index 025079f..6ad6d19 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_activity_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_activity_package.py @@ -23,20 +23,17 @@ def decode_activity(xml, nsmap): """Decodes an instance of the following type: activity. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.Activity """ decodings = [ - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), ] @@ -46,20 +43,17 @@ def decode_activity(xml, nsmap): def decode_boundary_condition(xml, nsmap): """Decodes an instance of the following type: boundary condition. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.BoundaryCondition """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -76,19 +70,16 @@ def decode_boundary_condition(xml, nsmap): def decode_conformance(xml, nsmap): """Decodes an instance of the following type: conformance. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.Conformance """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('frequency', False, 'str', 'child::cim:frequency'), + ('description', False, 'unicode', 'child::cim:description'), + ('frequency', False, 'unicode', 'child::cim:frequency'), ('is_conformant', False, 'bool', '@conformant'), ('requirements', True, decode_boundary_condition, 'child::cim:requirement/cim:requirement/cim:boundaryCondition'), ('requirements', True, decode_initial_condition, 'child::cim:requirement/cim:requirement/cim:initialCondition'), @@ -103,7 +94,7 @@ def decode_conformance(xml, nsmap): ('sources', True, decode_processor_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('sources', True, decode_statistical_model_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('sources_references', True, decode_doc_reference, 'child::cim:source/cim:reference'), - ('type', False, 'str', '@type'), + ('type', False, 'unicode', '@type'), ] return set_attributes(typeset.activity.Conformance(), xml, nsmap, decodings) @@ -112,11 +103,8 @@ def decode_conformance(xml, nsmap): def decode_downscaling_simulation(xml, nsmap): """Decodes an instance of the following type: downscaling simulation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.DownscalingSimulation @@ -126,7 +114,7 @@ def decode_downscaling_simulation(xml, nsmap): ('calendar', False, decode_daily_360, 'child::cim:calendar/cim:daily-360'), ('calendar', False, decode_perpetual_period, 'child::cim:calendar/cim:perpetualPeriod'), ('calendar', False, decode_real_calendar, 'child::cim:calendar/cim:realCalendar'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('downscaled_from', False, decode_component_property, 'child::cim:downscaledFrom/cim:downscaledFrom/cim:componentProperty'), ('downscaled_from', False, decode_data_content, 'child::cim:downscaledFrom/cim:downscaledFrom/cim:dataContent'), ('downscaled_from', False, decode_data_object, 'child::cim:downscaledFrom/cim:downscaledFrom/cim:dataObject'), @@ -134,17 +122,17 @@ def decode_downscaling_simulation(xml, nsmap): ('downscaled_from', False, decode_processor_component, 'child::cim:downscaledFrom/cim:downscaledFrom/cim:softwareComponent'), ('downscaled_from', False, decode_statistical_model_component, 'child::cim:downscaledFrom/cim:downscaledFrom/cim:softwareComponent'), ('downscaled_from_reference', False, decode_doc_reference, 'child::cim:downscaledFrom/cim:reference'), - ('downscaling_id', False, 'str', 'child::cim:downscalingID'), - ('downscaling_type', False, 'str', 'self::cim:downscalingSimulation/@downscalingType'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), + ('downscaling_id', False, 'unicode', 'child::cim:downscalingID'), + ('downscaling_type', False, 'unicode', 'self::cim:downscalingSimulation/@downscalingType'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), ('inputs', True, decode_coupling, 'child::cim:input'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:downscalingSimulation'), ('outputs', True, decode_data_object, 'child::cim:output/cim:dataObject'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), ] @@ -155,20 +143,17 @@ def decode_downscaling_simulation(xml, nsmap): def decode_ensemble(xml, nsmap): """Decodes an instance of the following type: ensemble. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.Ensemble """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('long_name', False, 'str', 'child::cim:longName'), + ('description', False, 'unicode', 'child::cim:description'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('members', True, decode_ensemble_member, 'child::cim:ensembleMember'), ('meta', False, decode_doc_meta_info, 'self::cim:ensemble'), ('outputs', True, decode_component_property, 'child::cim:output/cim:output/cim:componentProperty'), @@ -178,13 +163,13 @@ def decode_ensemble(xml, nsmap): ('outputs', True, decode_processor_component, 'child::cim:output/cim:output/cim:softwareComponent'), ('outputs', True, decode_statistical_model_component, 'child::cim:output/cim:output/cim:softwareComponent'), ('outputs_references', True, decode_doc_reference, 'child::cim:output/cim:reference'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), - ('types', True, 'str', 'child::cim:ensembleType/@value'), + ('types', True, 'unicode', 'child::cim:ensembleType/@value'), ] return set_attributes(typeset.activity.Ensemble(), xml, nsmap, decodings) @@ -193,27 +178,24 @@ def decode_ensemble(xml, nsmap): def decode_ensemble_member(xml, nsmap): """Decodes an instance of the following type: ensemble member. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.EnsembleMember """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('ensemble', False, decode_ensemble, 'child::cim:ensemble/cim:ensemble'), ('ensemble_ids', True, decode_standard_name, 'child::cim:ensembleMemberID'), ('ensemble_reference', False, decode_doc_reference, 'child::cim:ensemble/cim:reference'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('long_name', False, 'str', 'child::cim:longName'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('simulation', False, decode_simulation, 'child::cim:ensemble/cim:simulation'), ('simulation_reference', False, decode_doc_reference, 'child::cim:simulation/cim:reference'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), @@ -226,20 +208,17 @@ def decode_ensemble_member(xml, nsmap): def decode_experiment(xml, nsmap): """Decodes an instance of the following type: experiment. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.Experiment """ decodings = [ - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), ] @@ -249,11 +228,8 @@ def decode_experiment(xml, nsmap): def decode_experiment_relationship(xml, nsmap): """Decodes an instance of the following type: experiment relationship. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.ExperimentRelationship @@ -268,11 +244,8 @@ def decode_experiment_relationship(xml, nsmap): def decode_experiment_relationship_target(xml, nsmap): """Decodes an instance of the following type: experiment relationship target. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.ExperimentRelationshipTarget @@ -287,20 +260,17 @@ def decode_experiment_relationship_target(xml, nsmap): def decode_initial_condition(xml, nsmap): """Decodes an instance of the following type: initial condition. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.InitialCondition """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -317,20 +287,17 @@ def decode_initial_condition(xml, nsmap): def decode_lateral_boundary_condition(xml, nsmap): """Decodes an instance of the following type: lateral boundary condition. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.LateralBoundaryCondition """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -347,20 +314,17 @@ def decode_lateral_boundary_condition(xml, nsmap): def decode_measurement_campaign(xml, nsmap): """Decodes an instance of the following type: measurement campaign. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.MeasurementCampaign """ decodings = [ - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), ] @@ -370,24 +334,21 @@ def decode_measurement_campaign(xml, nsmap): def decode_numerical_activity(xml, nsmap): """Decodes an instance of the following type: numerical activity. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.NumericalActivity """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('long_name', False, 'str', 'child::cim:longName'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('description', False, 'unicode', 'child::cim:description'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), ] @@ -398,24 +359,21 @@ def decode_numerical_activity(xml, nsmap): def decode_numerical_experiment(xml, nsmap): """Decodes an instance of the following type: numerical experiment. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.NumericalExperiment """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('experiment_id', False, 'str', 'child::cim:experimentID'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), - ('long_name', False, 'str', 'child::cim:longName'), + ('description', False, 'unicode', 'child::cim:description'), + ('experiment_id', False, 'unicode', 'child::cim:experimentID'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:numericalExperiment'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('requirements', True, decode_boundary_condition, 'child::cim:numericalRequirement/cim:boundaryCondition'), ('requirements', True, decode_boundary_condition, 'child::cim:numericalRequirement[@xsi:type="BoundaryCondition"]'), ('requirements', True, decode_initial_condition, 'child::cim:numericalRequirement/cim:initialCondition'), @@ -427,7 +385,7 @@ def decode_numerical_experiment(xml, nsmap): ('requirements', True, decode_spatio_temporal_constraint, 'child::cim:numericalRequirement/cim:spatioTemporalConstraint'), ('requirements', True, decode_spatio_temporal_constraint, 'child::cim:numericalRequirement[@xsi:type="SpatioTemporalConstraint"]'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ] return set_attributes(typeset.activity.NumericalExperiment(), xml, nsmap, decodings) @@ -436,20 +394,17 @@ def decode_numerical_experiment(xml, nsmap): def decode_numerical_requirement(xml, nsmap): """Decodes an instance of the following type: numerical requirement. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.NumericalRequirement """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -466,36 +421,33 @@ def decode_numerical_requirement(xml, nsmap): def decode_numerical_requirement_option(xml, nsmap): """Decodes an instance of the following type: numerical requirement option. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.NumericalRequirementOption """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('description', False, 'str', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:description'), - ('description', False, 'str', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:description'), - ('description', False, 'str', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:description'), - ('description', False, 'str', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:description'), - ('description', False, 'str', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('id', False, 'str', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:id'), - ('id', False, 'str', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:id'), - ('id', False, 'str', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:id'), - ('id', False, 'str', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:id'), - ('id', False, 'str', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:id'), - ('name', False, 'str', 'child::cim:name'), - ('name', False, 'str', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:name'), - ('name', False, 'str', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:name'), - ('name', False, 'str', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:name'), - ('name', False, 'str', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:name'), - ('name', False, 'str', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:name'), - ('relationship', False, 'str', 'self::cim:requirementOption/@optionRelationship'), + ('description', False, 'unicode', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:description'), + ('description', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:description'), + ('description', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:description'), + ('description', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:description'), + ('description', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('id', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:id'), + ('id', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:id'), + ('id', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:id'), + ('id', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:id'), + ('id', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:id'), + ('name', False, 'unicode', 'child::cim:name'), + ('name', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:boundaryCondition/cim:name'), + ('name', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:initialCondition/cim:name'), + ('name', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:lateralBoundaryCondition/cim:name'), + ('name', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:outputRequirement/cim:name'), + ('name', False, 'unicode', 'child::cim:requirement/cim:requirement/cim:spatioTemporalConstraint/cim:name'), + ('relationship', False, 'unicode', 'self::cim:requirementOption/@optionRelationship'), ] return set_attributes(typeset.activity.NumericalRequirementOption(), xml, nsmap, decodings) @@ -504,20 +456,17 @@ def decode_numerical_requirement_option(xml, nsmap): def decode_output_requirement(xml, nsmap): """Decodes an instance of the following type: output requirement. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.OutputRequirement """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -534,19 +483,16 @@ def decode_output_requirement(xml, nsmap): def decode_physical_modification(xml, nsmap): """Decodes an instance of the following type: physical modification. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.PhysicalModification """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('frequency', False, 'str', 'child::cim:frequency'), + ('description', False, 'unicode', 'child::cim:description'), + ('frequency', False, 'unicode', 'child::cim:frequency'), ('is_conformant', False, 'bool', '@conformant'), ('requirements', True, decode_boundary_condition, 'child::cim:requirement/cim:requirement/cim:boundaryCondition'), ('requirements', True, decode_initial_condition, 'child::cim:requirement/cim:requirement/cim:initialCondition'), @@ -561,7 +507,7 @@ def decode_physical_modification(xml, nsmap): ('sources', True, decode_processor_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('sources', True, decode_statistical_model_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('sources_references', True, decode_doc_reference, 'child::cim:source/cim:reference'), - ('type', False, 'str', '@type'), + ('type', False, 'unicode', '@type'), ] return set_attributes(typeset.activity.PhysicalModification(), xml, nsmap, decodings) @@ -570,18 +516,15 @@ def decode_physical_modification(xml, nsmap): def decode_simulation(xml, nsmap): """Decodes an instance of the following type: simulation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.Simulation """ decodings = [ - ('authors', False, 'str', 'child::cim:authorsList/cim:list'), + ('authors', False, 'unicode', 'child::cim:authorsList/cim:list'), ('calendar', False, decode_daily_360, 'child::cim:calendar/cim:daily-360'), ('calendar', False, decode_perpetual_period, 'child::cim:calendar/cim:perpetualPeriod'), ('calendar', False, decode_real_calendar, 'child::cim:calendar/cim:realCalendar'), @@ -590,15 +533,15 @@ def decode_simulation(xml, nsmap): ('control_simulation', False, decode_simulation, 'child::cim:controlSimulation/cim:controlSimulation'), ('control_simulation_reference', False, decode_doc_reference, 'child::cim:controlSimulation/cim:reference'), ('deployments', True, decode_deployment, 'child::cim:deployment'), - ('description', False, 'str', 'child::cim:description'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), + ('description', False, 'unicode', 'child::cim:description'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), ('inputs', True, decode_coupling, 'child::cim:input'), - ('long_name', False, 'str', 'child::cim:longName'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), - ('simulation_id', False, 'str', 'child::cim:simulationID'), + ('short_name', False, 'unicode', 'child::cim:shortName'), + ('simulation_id', False, 'unicode', 'child::cim:simulationID'), ('spinup_date_range', False, decode_closed_date_range, 'child::cim:dateRange/cim:closedDateRange'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), @@ -610,18 +553,15 @@ def decode_simulation(xml, nsmap): def decode_simulation_composite(xml, nsmap): """Decodes an instance of the following type: simulation composite. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.SimulationComposite """ decodings = [ - ('authors', False, 'str', 'child::cim:authorsList/cim:list'), + ('authors', False, 'unicode', 'child::cim:authorsList/cim:list'), ('calendar', False, decode_daily_360, 'child::cim:calendar/cim:daily-360'), ('calendar', False, decode_perpetual_period, 'child::cim:calendar/cim:perpetualPeriod'), ('calendar', False, decode_real_calendar, 'child::cim:calendar/cim:realCalendar'), @@ -634,17 +574,17 @@ def decode_simulation_composite(xml, nsmap): ('date_range', False, decode_closed_date_range, 'child::cim:dateRange/cim:closedDateRange'), ('date_range', False, decode_open_date_range, 'child::cim:dateRange/cim:openDateRange'), ('deployments', True, decode_deployment, 'child::cim:deployment'), - ('description', False, 'str', 'child::cim:description'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), + ('description', False, 'unicode', 'child::cim:description'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), ('inputs', True, decode_coupling, 'child::cim:input'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:simulationRun'), - ('projects', True, 'str', 'child::cim:project/@value'), + ('projects', True, 'unicode', 'child::cim:project/@value'), ('rank', False, 'int', 'child::cim:rank'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), - ('simulation_id', False, 'str', 'child::cim:simulationID'), + ('short_name', False, 'unicode', 'child::cim:shortName'), + ('simulation_id', False, 'unicode', 'child::cim:simulationID'), ('spinup_date_range', False, decode_closed_date_range, 'child::cim:dateRange/cim:closedDateRange'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), @@ -656,11 +596,8 @@ def decode_simulation_composite(xml, nsmap): def decode_simulation_relationship(xml, nsmap): """Decodes an instance of the following type: simulation relationship. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.SimulationRelationship @@ -675,11 +612,8 @@ def decode_simulation_relationship(xml, nsmap): def decode_simulation_relationship_target(xml, nsmap): """Decodes an instance of the following type: simulation relationship target. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.SimulationRelationshipTarget @@ -694,18 +628,15 @@ def decode_simulation_relationship_target(xml, nsmap): def decode_simulation_run(xml, nsmap): """Decodes an instance of the following type: simulation run. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.SimulationRun """ decodings = [ - ('authors', False, 'str', 'child::cim:authorsList/cim:list'), + ('authors', False, 'unicode', 'child::cim:authorsList/cim:list'), ('calendar', False, decode_daily_360, 'child::cim:calendar/cim:daily-360'), ('calendar', False, decode_perpetual_period, 'child::cim:calendar/cim:perpetualPeriod'), ('calendar', False, decode_real_calendar, 'child::cim:calendar/cim:realCalendar'), @@ -716,18 +647,18 @@ def decode_simulation_run(xml, nsmap): ('date_range', False, decode_closed_date_range, 'child::cim:dateRange/cim:closedDateRange'), ('date_range', False, decode_open_date_range, 'child::cim:dateRange/cim:openDateRange'), ('deployments', True, decode_deployment, 'child::cim:deployment'), - ('description', False, 'str', 'child::cim:description'), - ('funding_sources', True, 'str', 'child::cim:fundingSource'), + ('description', False, 'unicode', 'child::cim:description'), + ('funding_sources', True, 'unicode', 'child::cim:fundingSource'), ('inputs', True, decode_coupling, 'child::cim:input'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:simulationRun'), ('model', False, decode_model_component, 'child::cim:model/cim:modelComponent'), ('model_reference', False, decode_doc_reference, 'child::cim:model/cim:reference'), - ('projects', True, 'str', 'child::cim:project/@value'), - ('rationales', True, 'str', 'child::cim:rationale'), + ('projects', True, 'unicode', 'child::cim:project/@value'), + ('rationales', True, 'unicode', 'child::cim:rationale'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), - ('simulation_id', False, 'str', 'child::cim:simulationID'), + ('short_name', False, 'unicode', 'child::cim:shortName'), + ('simulation_id', False, 'unicode', 'child::cim:simulationID'), ('spinup_date_range', False, decode_closed_date_range, 'child::cim:dateRange/cim:closedDateRange'), ('supports', True, decode_experiment, 'child::cim:supports/cim:experiment'), ('supports_references', True, decode_doc_reference, 'child::cim:supports/cim:reference'), @@ -739,11 +670,8 @@ def decode_simulation_run(xml, nsmap): def decode_spatio_temporal_constraint(xml, nsmap): """Decodes an instance of the following type: spatio temporal constraint. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.activity.SpatioTemporalConstraint @@ -752,9 +680,9 @@ def decode_spatio_temporal_constraint(xml, nsmap): decodings = [ ('date_range', False, decode_closed_date_range, 'child::cim:requiredDuration/cim:closedDateRange'), ('date_range', False, decode_open_date_range, 'child::cim:requiredDuration/cim:openDateRange'), - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), ('options', True, decode_numerical_requirement_option, 'child::cim:requirementOption'), ('source', False, decode_component_property, 'child::cim:source/cim:source/cim:componentProperty'), ('source', False, decode_data_content, 'child::cim:source/cim:source/cim:dataContent'), @@ -763,7 +691,7 @@ def decode_spatio_temporal_constraint(xml, nsmap): ('source', False, decode_processor_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('source', False, decode_statistical_model_component, 'child::cim:source/cim:source/cim:softwareComponent'), ('source_reference', False, decode_doc_reference, 'child::cim:source/cim:reference'), - ('spatial_resolution', False, 'str', 'child::cim:spatialResolution'), + ('spatial_resolution', False, 'unicode', 'child::cim:spatialResolution'), ] return set_attributes(typeset.activity.SpatioTemporalConstraint(), xml, nsmap, decodings) diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_data_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_data_package.py index 030d5cc..42ae73e 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_data_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_data_package.py @@ -21,19 +21,16 @@ def decode_data_content(xml, nsmap): """Decodes an instance of the following type: data content. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataContent """ decodings = [ - ('aggregation', False, 'str', 'child::cim:aggregation'), - ('frequency', False, 'str', 'child::cim:frequency/@value'), + ('aggregation', False, 'unicode', 'child::cim:aggregation'), + ('frequency', False, 'unicode', 'child::cim:frequency/@value'), ('topic', False, decode_data_topic, 'child::cim:topic'), ] @@ -43,19 +40,16 @@ def decode_data_content(xml, nsmap): def decode_data_distribution(xml, nsmap): """Decodes an instance of the following type: data distribution. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataDistribution """ decodings = [ - ('access', False, 'str', '@distributionAccess'), - ('format', False, 'str', 'child::cim:distributionFormat/@value'), + ('access', False, 'unicode', '@distributionAccess'), + ('format', False, 'unicode', 'child::cim:distributionFormat/@value'), ('responsible_party', False, decode_responsible_party, 'child::cim:responsibleParty'), ] @@ -65,11 +59,8 @@ def decode_data_distribution(xml, nsmap): def decode_data_extent(xml, nsmap): """Decodes an instance of the following type: data extent. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataExtent @@ -86,11 +77,8 @@ def decode_data_extent(xml, nsmap): def decode_data_extent_geographical(xml, nsmap): """Decodes an instance of the following type: data extent geographical. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataExtentGeographical @@ -109,11 +97,8 @@ def decode_data_extent_geographical(xml, nsmap): def decode_data_extent_temporal(xml, nsmap): """Decodes an instance of the following type: data extent temporal. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataExtentTemporal @@ -131,11 +116,8 @@ def decode_data_extent_temporal(xml, nsmap): def decode_data_extent_time_interval(xml, nsmap): """Decodes an instance of the following type: data extent time interval. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataExtentTimeInterval @@ -144,7 +126,7 @@ def decode_data_extent_time_interval(xml, nsmap): decodings = [ ('factor', False, 'int', '@factor'), ('radix', False, 'int', '@radix'), - ('unit', False, 'str', '@unit'), + ('unit', False, 'unicode', '@unit'), ] return set_attributes(typeset.data.DataExtentTimeInterval(), xml, nsmap, decodings) @@ -153,11 +135,8 @@ def decode_data_extent_time_interval(xml, nsmap): def decode_data_hierarchy_level(xml, nsmap): """Decodes an instance of the following type: data hierarchy level. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataHierarchyLevel @@ -165,8 +144,8 @@ def decode_data_hierarchy_level(xml, nsmap): """ decodings = [ ('is_open', False, 'bool', 'child::cim:hierarchyLevelName/@open'), - ('name', False, 'str', 'child::cim:hierarchyLevelName/@value'), - ('value', False, 'str', 'child::cim:hierarchyLevelValue'), + ('name', False, 'unicode', 'child::cim:hierarchyLevelName/@value'), + ('value', False, 'unicode', 'child::cim:hierarchyLevelValue'), ] return set_attributes(typeset.data.DataHierarchyLevel(), xml, nsmap, decodings) @@ -175,30 +154,27 @@ def decode_data_hierarchy_level(xml, nsmap): def decode_data_object(xml, nsmap): """Decodes an instance of the following type: data object. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataObject """ decodings = [ - ('acronym', False, 'str', 'child::cim:acronym'), + ('acronym', False, 'unicode', 'child::cim:acronym'), ('citations', True, decode_citation, '//cim:citation[not(cim:citation)]'), ('content', True, decode_data_content, 'child::cim:content'), - ('data_status', False, 'str', 'self::cim:dataObject/@dataStatus'), - ('description', False, 'str', 'child::cim:description'), + ('data_status', False, 'unicode', 'self::cim:dataObject/@dataStatus'), + ('description', False, 'unicode', 'child::cim:description'), ('distribution', False, decode_data_distribution, 'child::cim:distribution'), ('extent', False, decode_data_extent, 'child::cim:extent'), ('hierarchy_level', False, decode_data_hierarchy_level, 'self::cim:dataObject'), - ('keyword', False, 'str', 'child::cim:keyword'), + ('keyword', False, 'unicode', 'child::cim:keyword'), ('meta', False, decode_doc_meta_info, 'self::cim:dataObject'), ('properties', True, decode_data_property, 'child::cim:dataProperty/cim:dataProperty'), - ('purpose', False, 'str', 'self::cim:dataObject/@purpose'), - ('purpose', False, 'str', 'self::cim:dataObject/@purpose'), + ('purpose', False, 'unicode', 'self::cim:dataObject/@purpose'), + ('purpose', False, 'unicode', 'self::cim:dataObject/@purpose'), ('storage', True, decode_data_storage_ip, 'child::cim:storage/cim:ipStorage'), ] @@ -208,20 +184,17 @@ def decode_data_object(xml, nsmap): def decode_data_property(xml, nsmap): """Decodes an instance of the following type: data property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataProperty """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('description', False, 'unicode', 'child::cim:description'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.data.DataProperty(), xml, nsmap, decodings) @@ -230,11 +203,8 @@ def decode_data_property(xml, nsmap): def decode_data_restriction(xml, nsmap): """Decodes an instance of the following type: data restriction. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataRestriction @@ -249,11 +219,8 @@ def decode_data_restriction(xml, nsmap): def decode_data_storage(xml, nsmap): """Decodes an instance of the following type: data storage. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataStorage @@ -268,11 +235,8 @@ def decode_data_storage(xml, nsmap): def decode_data_storage_db(xml, nsmap): """Decodes an instance of the following type: data storage db. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataStorageDb @@ -287,11 +251,8 @@ def decode_data_storage_db(xml, nsmap): def decode_data_storage_file(xml, nsmap): """Decodes an instance of the following type: data storage file. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataStorageFile @@ -306,19 +267,16 @@ def decode_data_storage_file(xml, nsmap): def decode_data_storage_ip(xml, nsmap): """Decodes an instance of the following type: data storage ip. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataStorageIp """ decodings = [ - ('file_name', False, 'str', 'child::cim:fileName'), - ('format', False, 'str', 'child::cim:dataFormat/@value'), + ('file_name', False, 'unicode', 'child::cim:fileName'), + ('format', False, 'unicode', 'child::cim:dataFormat/@value'), ] return set_attributes(typeset.data.DataStorageIp(), xml, nsmap, decodings) @@ -327,20 +285,17 @@ def decode_data_storage_ip(xml, nsmap): def decode_data_topic(xml, nsmap): """Decodes an instance of the following type: data topic. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.data.DataTopic """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('name', False, 'str', 'child::cim:name'), - ('unit', False, 'str', 'child::cim:unit/@value'), + ('description', False, 'unicode', 'child::cim:description'), + ('name', False, 'unicode', 'child::cim:name'), + ('unit', False, 'unicode', 'child::cim:unit/@value'), ] return set_attributes(typeset.data.DataTopic(), xml, nsmap, decodings) diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_grids_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_grids_package.py index e45ef90..03b12ee 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_grids_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_grids_package.py @@ -21,11 +21,8 @@ def decode_coordinate_list(xml, nsmap): """Decodes an instance of the following type: coordinate list. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.CoordinateList @@ -34,7 +31,7 @@ def decode_coordinate_list(xml, nsmap): decodings = [ ('has_constant_offset', False, 'bool', '@hasConstantOffset'), ('length', False, 'int', '@length'), - ('uom', False, 'str', '@uom'), + ('uom', False, 'unicode', '@uom'), ] return set_attributes(typeset.grids.CoordinateList(), xml, nsmap, decodings) @@ -43,22 +40,19 @@ def decode_coordinate_list(xml, nsmap): def decode_grid_extent(xml, nsmap): """Decodes an instance of the following type: grid extent. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridExtent """ decodings = [ - ('maximum_latitude', False, 'str', 'child::cim:latMax'), - ('maximum_longitude', False, 'str', 'child::cim:lonMax'), - ('minimum_latitude', False, 'str', 'child::cim:latMin'), - ('minimum_longitude', False, 'str', 'child::cim:lonMin'), - ('units', False, 'str', 'child::cim:units'), + ('maximum_latitude', False, 'unicode', 'child::cim:latMax'), + ('maximum_longitude', False, 'unicode', 'child::cim:lonMax'), + ('minimum_latitude', False, 'unicode', 'child::cim:latMin'), + ('minimum_longitude', False, 'unicode', 'child::cim:lonMin'), + ('units', False, 'unicode', 'child::cim:units'), ] return set_attributes(typeset.grids.GridExtent(), xml, nsmap, decodings) @@ -67,11 +61,8 @@ def decode_grid_extent(xml, nsmap): def decode_grid_mosaic(xml, nsmap): """Decodes an instance of the following type: grid mosaic. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridMosaic @@ -79,18 +70,18 @@ def decode_grid_mosaic(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citationList/cim:citation'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('has_congruent_tiles', False, 'bool', '@congruentTiles'), - ('id', False, 'str', '@id'), + ('id', False, 'unicode', '@id'), ('is_leaf', False, 'bool', '@isLeaf'), - ('long_name', False, 'str', 'child::cim:longName'), - ('mnemonic', False, 'str', 'child::cim:mnemonic'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('mnemonic', False, 'unicode', 'child::cim:mnemonic'), ('mosaic_count', False, 'int', '@numMosaics'), ('mosaics', True, decode_grid_mosaic, 'child::cim:gridMosaic'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('tile_count', False, 'int', '@numTiles'), ('tiles', True, decode_grid_tile, 'child::cim:gridTile'), - ('type', False, 'str', '@gridType'), + ('type', False, 'unicode', '@gridType'), ] return set_attributes(typeset.grids.GridMosaic(), xml, nsmap, decodings) @@ -99,19 +90,16 @@ def decode_grid_mosaic(xml, nsmap): def decode_grid_property(xml, nsmap): """Decodes an instance of the following type: grid property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridProperty """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.grids.GridProperty(), xml, nsmap, decodings) @@ -120,11 +108,8 @@ def decode_grid_property(xml, nsmap): def decode_grid_spec(xml, nsmap): """Decodes an instance of the following type: grid spec. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridSpec @@ -142,34 +127,31 @@ def decode_grid_spec(xml, nsmap): def decode_grid_tile(xml, nsmap): """Decodes an instance of the following type: grid tile. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridTile """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('discretization_type', False, 'str', '@discretizationType'), + ('description', False, 'unicode', 'child::cim:description'), + ('discretization_type', False, 'unicode', '@discretizationType'), ('extent', False, decode_grid_extent, 'child::cim:extent'), - ('geometry_type', False, 'str', '@geometryType'), + ('geometry_type', False, 'unicode', '@geometryType'), ('horizontal_resolution', False, decode_grid_tile_resolution_type, 'child::cim:horizontalResolution'), - ('id', False, 'str', '@id'), + ('id', False, 'unicode', '@id'), ('is_conformal', False, 'bool', '@isConformal'), ('is_regular', False, 'bool', '@isRegular'), ('is_terrain_following', False, 'bool', '@isTerrainFollowing'), ('is_uniform', False, 'bool', '@isUniform'), - ('long_name', False, 'str', 'child::cim:longName'), - ('mnemonic', False, 'str', 'child::cim:mnemonic'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('mnemonic', False, 'unicode', 'child::cim:mnemonic'), ('nx', False, 'int', '@nx'), ('ny', False, 'int', '@ny'), ('nz', False, 'int', '@nz'), - ('refinement_scheme', False, 'str', '@refinementScheme'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('refinement_scheme', False, 'unicode', '@refinementScheme'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('vertical_resolution', False, decode_grid_tile_resolution_type, 'child::cim:verticalResolution'), ('zcoords', False, decode_vertical_coordinate_list, 'child::cim:zcoords'), ] @@ -180,18 +162,15 @@ def decode_grid_tile(xml, nsmap): def decode_grid_tile_resolution_type(xml, nsmap): """Decodes an instance of the following type: grid tile resolution type. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.GridTileResolutionType """ decodings = [ - ('description', False, 'str', '@description'), + ('description', False, 'unicode', '@description'), ('properties', True, decode_grid_property, 'child::cim:property'), ] @@ -201,11 +180,8 @@ def decode_grid_tile_resolution_type(xml, nsmap): def decode_simple_grid_geometry(xml, nsmap): """Decodes an instance of the following type: simple grid geometry. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.SimpleGridGeometry @@ -220,23 +196,20 @@ def decode_simple_grid_geometry(xml, nsmap): def decode_vertical_coordinate_list(xml, nsmap): """Decodes an instance of the following type: vertical coordinate list. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.grids.VerticalCoordinateList """ decodings = [ - ('form', False, 'str', '@coordinateForm'), + ('form', False, 'unicode', '@coordinateForm'), ('has_constant_offset', False, 'bool', '@hasConstantOffset'), ('length', False, 'int', '@length'), ('properties', True, decode_grid_property, 'child::cim:property'), - ('type', False, 'str', '@coordinateType'), - ('uom', False, 'str', '@uom'), + ('type', False, 'unicode', '@coordinateType'), + ('uom', False, 'unicode', '@uom'), ] return set_attributes(typeset.grids.VerticalCoordinateList(), xml, nsmap, decodings) diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_misc_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_misc_package.py index f0c1b76..be70b09 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_misc_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_misc_package.py @@ -25,11 +25,8 @@ def decode_document_set(xml, nsmap): """Decodes an instance of the following type: document set. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.misc.DocumentSet diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_quality_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_quality_package.py index 5e95c14..bc5fcc4 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_quality_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_quality_package.py @@ -21,11 +21,8 @@ def decode_cim_quality(xml, nsmap): """Decodes an instance of the following type: cim quality. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.quality.CimQuality @@ -42,11 +39,8 @@ def decode_cim_quality(xml, nsmap): def decode_evaluation(xml, nsmap): """Decodes an instance of the following type: evaluation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.quality.Evaluation @@ -54,14 +48,14 @@ def decode_evaluation(xml, nsmap): """ decodings = [ ('date', False, 'datetime.datetime', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date'), - ('description', False, 'str', 'gmd:evaluationMethodDescription/gco:CharacterString'), + ('description', False, 'unicode', 'gmd:evaluationMethodDescription/gco:CharacterString'), ('did_pass', False, 'bool', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:pass/gco:Boolean'), - ('explanation', False, 'str', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:explanation/gco:CharacterString'), - ('specification', False, 'str', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/@xlink:title'), - ('specification_hyperlink', False, 'str', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/@xlink:href'), - ('title', False, 'str', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString'), - ('type', False, 'str', 'child::gmd:result/@xlink:title'), - ('type_hyperlink', False, 'str', 'child::gmd:result/@xlink:href'), + ('explanation', False, 'unicode', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:explanation/gco:CharacterString'), + ('specification', False, 'unicode', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/@xlink:title'), + ('specification_hyperlink', False, 'unicode', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/@xlink:href'), + ('title', False, 'unicode', 'child::gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString'), + ('type', False, 'unicode', 'child::gmd:result/@xlink:title'), + ('type_hyperlink', False, 'unicode', 'child::gmd:result/@xlink:href'), ] return set_attributes(typeset.quality.Evaluation(), xml, nsmap, decodings) @@ -70,22 +64,19 @@ def decode_evaluation(xml, nsmap): def decode_measure(xml, nsmap): """Decodes an instance of the following type: measure. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.quality.Measure """ decodings = [ - ('description', False, 'str', 'child::cim:measureDescription'), - ('description', False, 'str', 'parent::cim:report/child::gmd:measureDescription/gco:CharacterString'), - ('identification', False, 'str', 'child::cim:measureIdentification/gmd:code/gco:CharacterString'), - ('name', False, 'str', 'child::cim:nameOfMeasure'), - ('name', False, 'str', 'parent::cim:report/child::gmd:nameOfMeasure/gco:CharacterString'), + ('description', False, 'unicode', 'child::cim:measureDescription'), + ('description', False, 'unicode', 'parent::cim:report/child::gmd:measureDescription/gco:CharacterString'), + ('identification', False, 'unicode', 'child::cim:measureIdentification/gmd:code/gco:CharacterString'), + ('name', False, 'unicode', 'child::cim:nameOfMeasure'), + ('name', False, 'unicode', 'parent::cim:report/child::gmd:nameOfMeasure/gco:CharacterString'), ] return set_attributes(typeset.quality.Measure(), xml, nsmap, decodings) @@ -94,11 +85,8 @@ def decode_measure(xml, nsmap): def decode_report(xml, nsmap): """Decodes an instance of the following type: report. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.quality.Report diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_shared_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_shared_package.py index 9f7a23c..f9039cc 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_shared_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_shared_package.py @@ -20,18 +20,15 @@ def decode_calendar(xml, nsmap): """Decodes an instance of the following type: calendar. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Calendar """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('length', False, 'int', 'child::cim:length'), ('range', False, decode_closed_date_range, 'child::cim:range/cim:closedDateRange'), ('range', False, decode_open_date_range, 'child::cim:range/cim:openDateRange'), @@ -43,11 +40,8 @@ def decode_calendar(xml, nsmap): def decode_change(xml, nsmap): """Decodes an instance of the following type: change. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Change @@ -56,10 +50,10 @@ def decode_change(xml, nsmap): decodings = [ ('author', False, decode_responsible_party, 'child::cim:changeAuthor'), ('date', False, 'datetime.datetime', 'child::cim:changeDate'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('details', True, decode_change_property, 'child::cim:detail'), - ('name', False, 'str', 'child::cim:name'), - ('type', False, 'str', 'self::cim:change/@type'), + ('name', False, 'unicode', 'child::cim:name'), + ('type', False, 'unicode', 'self::cim:change/@type'), ] return set_attributes(typeset.shared.Change(), xml, nsmap, decodings) @@ -68,21 +62,18 @@ def decode_change(xml, nsmap): def decode_change_property(xml, nsmap): """Decodes an instance of the following type: change property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.ChangeProperty """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('id', False, 'str', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('description', False, 'unicode', 'child::cim:description'), + ('id', False, 'unicode', 'child::cim:id'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.shared.ChangeProperty(), xml, nsmap, decodings) @@ -91,28 +82,25 @@ def decode_change_property(xml, nsmap): def decode_citation(xml, nsmap): """Decodes an instance of the following type: citation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Citation """ decodings = [ - ('alternative_title', False, 'str', 'child::gmd:alternateTitle'), - ('alternative_title', False, 'str', 'child::gmd:alternateTitle/gco:CharacterString'), - ('collective_title', False, 'str', 'gmd:collectiveTitle'), - ('collective_title', False, 'str', 'gmd:collectiveTitle/gco:CharacterString'), + ('alternative_title', False, 'unicode', 'child::gmd:alternateTitle'), + ('alternative_title', False, 'unicode', 'child::gmd:alternateTitle/gco:CharacterString'), + ('collective_title', False, 'unicode', 'gmd:collectiveTitle'), + ('collective_title', False, 'unicode', 'gmd:collectiveTitle/gco:CharacterString'), ('date', False, 'datetime.datetime', 'child::gmd:date/gmd:CI_Date/gmd:date/gco:Date'), - ('date_type', False, 'str', 'child::gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeListValue'), - ('location', False, 'str', 'child::gmd:otherCitationDetails'), - ('location', False, 'str', 'child::gmd:otherCitationDetails/gco:CharacterString'), - ('title', False, 'str', 'child::gmd:title'), - ('title', False, 'str', 'child::gmd:title/gco:CharacterString'), - ('type', False, 'str', 'child::gmd:presentationForm/gmd:CI_PresentationFormCode/@codeListValue'), + ('date_type', False, 'unicode', 'child::gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeListValue'), + ('location', False, 'unicode', 'child::gmd:otherCitationDetails'), + ('location', False, 'unicode', 'child::gmd:otherCitationDetails/gco:CharacterString'), + ('title', False, 'unicode', 'child::gmd:title'), + ('title', False, 'unicode', 'child::gmd:title/gco:CharacterString'), + ('type', False, 'unicode', 'child::gmd:presentationForm/gmd:CI_PresentationFormCode/@codeListValue'), ] return set_attributes(typeset.shared.Citation(), xml, nsmap, decodings) @@ -121,18 +109,15 @@ def decode_citation(xml, nsmap): def decode_closed_date_range(xml, nsmap): """Decodes an instance of the following type: closed date range. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.ClosedDateRange """ decodings = [ - ('duration', False, 'str', 'child::cim:duration'), + ('duration', False, 'unicode', 'child::cim:duration'), ('end', False, 'datetime.datetime', 'child::cim:endDate'), ('start', False, 'datetime.datetime', 'child::cim:startDate'), ] @@ -143,23 +128,20 @@ def decode_closed_date_range(xml, nsmap): def decode_compiler(xml, nsmap): """Decodes an instance of the following type: compiler. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Compiler """ decodings = [ - ('environment_variables', False, 'str', 'child::cim:compilerEnvironmentVariables'), - ('language', False, 'str', 'child::cim:compilerLanguage'), - ('name', False, 'str', 'child::cim:compilerName'), - ('options', False, 'str', 'child::cim:compilerOptions'), - ('type', False, 'str', 'child::cim:compilerType'), - ('version', False, 'str', 'child::cim:compilerVersion'), + ('environment_variables', False, 'unicode', 'child::cim:compilerEnvironmentVariables'), + ('language', False, 'unicode', 'child::cim:compilerLanguage'), + ('name', False, 'unicode', 'child::cim:compilerName'), + ('options', False, 'unicode', 'child::cim:compilerOptions'), + ('type', False, 'unicode', 'child::cim:compilerType'), + ('version', False, 'unicode', 'child::cim:compilerVersion'), ] return set_attributes(typeset.shared.Compiler(), xml, nsmap, decodings) @@ -168,18 +150,15 @@ def decode_compiler(xml, nsmap): def decode_daily_360(xml, nsmap): """Decodes an instance of the following type: daily 360. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Daily360 """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('length', False, 'int', 'child::cim:length'), ('range', False, decode_closed_date_range, 'child::cim:range/cim:closedDateRange'), ('range', False, decode_open_date_range, 'child::cim:range/cim:openDateRange'), @@ -191,11 +170,8 @@ def decode_daily_360(xml, nsmap): def decode_data_source(xml, nsmap): """Decodes an instance of the following type: data source. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DataSource @@ -210,18 +186,15 @@ def decode_data_source(xml, nsmap): def decode_date_range(xml, nsmap): """Decodes an instance of the following type: date range. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DateRange """ decodings = [ - ('duration', False, 'str', 'child::cim:duration'), + ('duration', False, 'unicode', 'child::cim:duration'), ] return set_attributes(typeset.shared.DateRange(), xml, nsmap, decodings) @@ -230,11 +203,8 @@ def decode_date_range(xml, nsmap): def decode_doc_genealogy(xml, nsmap): """Decodes an instance of the following type: doc genealogy. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DocGenealogy @@ -250,11 +220,8 @@ def decode_doc_genealogy(xml, nsmap): def decode_doc_meta_info(xml, nsmap): """Decodes an instance of the following type: doc meta info. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DocMetaInfo @@ -266,6 +233,7 @@ def decode_doc_meta_info(xml, nsmap): ('external_ids', True, decode_standard_name, 'child::cim:externalID'), ('genealogy', False, decode_doc_genealogy, 'child::cim:documentGenealogy'), ('id', False, 'uuid.UUID', 'child::cim:documentID'), + ('update_date', False, 'datetime.datetime', 'child::cim:documentCreationDate'), ('version', False, 'int', 'child::cim:documentVersion'), ('version', False, 'int', 'self::cim:numericalExperiment/@documentVersion'), ] @@ -276,11 +244,8 @@ def decode_doc_meta_info(xml, nsmap): def decode_doc_reference(xml, nsmap): """Decodes an instance of the following type: doc reference. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DocReference @@ -288,11 +253,11 @@ def decode_doc_reference(xml, nsmap): """ decodings = [ ('changes', True, decode_change, 'child::cim:change'), - ('description', False, 'str', 'child::cim:description'), - ('external_id', False, 'str', 'child::cim:externalID'), + ('description', False, 'unicode', 'child::cim:description'), + ('external_id', False, 'unicode', 'child::cim:externalID'), ('id', False, 'uuid.UUID', 'child::cim:id'), - ('name', False, 'str', 'child::cim:name'), - ('type', False, 'str', 'child::cim:type'), + ('name', False, 'unicode', 'child::cim:name'), + ('type', False, 'unicode', 'child::cim:type'), ('version', False, 'int', 'child::cim:version'), ] @@ -302,21 +267,18 @@ def decode_doc_reference(xml, nsmap): def decode_doc_relationship(xml, nsmap): """Decodes an instance of the following type: doc relationship. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DocRelationship """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('direction', False, 'str', 'self::cim:documentRelationship/@direction'), + ('description', False, 'unicode', 'child::cim:description'), + ('direction', False, 'unicode', 'self::cim:documentRelationship/@direction'), ('target', False, decode_doc_relationship_target, 'child::cim:target'), - ('type', False, 'str', 'self::cim:documentRelationship/@type'), + ('type', False, 'unicode', 'self::cim:documentRelationship/@type'), ] return set_attributes(typeset.shared.DocRelationship(), xml, nsmap, decodings) @@ -325,11 +287,8 @@ def decode_doc_relationship(xml, nsmap): def decode_doc_relationship_target(xml, nsmap): """Decodes an instance of the following type: doc relationship target. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.DocRelationshipTarget @@ -345,11 +304,8 @@ def decode_doc_relationship_target(xml, nsmap): def decode_license(xml, nsmap): """Decodes an instance of the following type: license. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.License @@ -364,11 +320,8 @@ def decode_license(xml, nsmap): def decode_machine(xml, nsmap): """Decodes an instance of the following type: machine. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Machine @@ -376,17 +329,17 @@ def decode_machine(xml, nsmap): """ decodings = [ ('cores_per_processor', False, 'int', 'child::cim:machineCoresPerProcessor'), - ('description', False, 'str', 'child::cim:machineDescription'), - ('interconnect', False, 'str', 'child::cim:machineInterconnect/@value'), - ('libraries', True, 'str', 'child::cim:machineLibrary'), - ('location', False, 'str', 'child::cim:machineLocation'), + ('description', False, 'unicode', 'child::cim:machineDescription'), + ('interconnect', False, 'unicode', 'child::cim:machineInterconnect/@value'), + ('libraries', True, 'unicode', 'child::cim:machineLibrary'), + ('location', False, 'unicode', 'child::cim:machineLocation'), ('maximum_processors', False, 'int', 'child::cim:machineMaximumProcessors'), - ('name', False, 'str', 'child::cim:machineName'), - ('operating_system', False, 'str', 'child::cim:machineOperatingSystem/@value'), - ('processor_type', False, 'str', 'child::cim:machineProcessorType/@value'), - ('system', False, 'str', 'child::cim:machineSystem'), - ('type', False, 'str', '@machineType'), - ('vendor', False, 'str', 'child::cim:machineVendor/@value'), + ('name', False, 'unicode', 'child::cim:machineName'), + ('operating_system', False, 'unicode', 'child::cim:machineOperatingSystem/@value'), + ('processor_type', False, 'unicode', 'child::cim:machineProcessorType/@value'), + ('system', False, 'unicode', 'child::cim:machineSystem'), + ('type', False, 'unicode', '@machineType'), + ('vendor', False, 'unicode', 'child::cim:machineVendor/@value'), ] return set_attributes(typeset.shared.Machine(), xml, nsmap, decodings) @@ -395,11 +348,8 @@ def decode_machine(xml, nsmap): def decode_machine_compiler_unit(xml, nsmap): """Decodes an instance of the following type: machine compiler unit. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.MachineCompilerUnit @@ -416,18 +366,15 @@ def decode_machine_compiler_unit(xml, nsmap): def decode_open_date_range(xml, nsmap): """Decodes an instance of the following type: open date range. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.OpenDateRange """ decodings = [ - ('duration', False, 'str', 'child::cim:duration'), + ('duration', False, 'unicode', 'child::cim:duration'), ('end', False, 'datetime.datetime', 'child::cim:endDate'), ('start', False, 'datetime.datetime', 'child::cim:startDate'), ] @@ -438,18 +385,15 @@ def decode_open_date_range(xml, nsmap): def decode_perpetual_period(xml, nsmap): """Decodes an instance of the following type: perpetual period. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.PerpetualPeriod """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('length', False, 'int', 'child::cim:length'), ('range', False, decode_closed_date_range, 'child::cim:range/cim:closedDateRange'), ('range', False, decode_open_date_range, 'child::cim:range/cim:openDateRange'), @@ -461,11 +405,8 @@ def decode_perpetual_period(xml, nsmap): def decode_platform(xml, nsmap): """Decodes an instance of the following type: platform. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Platform @@ -473,10 +414,10 @@ def decode_platform(xml, nsmap): """ decodings = [ ('contacts', True, decode_responsible_party, 'child::cim:contact'), - ('description', False, 'str', 'child::cim:description'), - ('long_name', False, 'str', 'child::cim:longName'), + ('description', False, 'unicode', 'child::cim:description'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:platform'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('units', True, decode_machine_compiler_unit, 'child::cim:unit'), ] @@ -486,19 +427,16 @@ def decode_platform(xml, nsmap): def decode_property(xml, nsmap): """Decodes an instance of the following type: property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Property """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.shared.Property(), xml, nsmap, decodings) @@ -507,18 +445,15 @@ def decode_property(xml, nsmap): def decode_real_calendar(xml, nsmap): """Decodes an instance of the following type: real calendar. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.RealCalendar """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('length', False, 'int', 'child::cim:length'), ('range', False, decode_closed_date_range, 'child::cim:range/cim:closedDateRange'), ('range', False, decode_open_date_range, 'child::cim:range/cim:openDateRange'), @@ -530,11 +465,8 @@ def decode_real_calendar(xml, nsmap): def decode_relationship(xml, nsmap): """Decodes an instance of the following type: relationship. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Relationship @@ -549,28 +481,25 @@ def decode_relationship(xml, nsmap): def decode_responsible_party(xml, nsmap): """Decodes an instance of the following type: responsible party. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.ResponsibleParty """ decodings = [ - ('abbreviation', False, 'str', 'child::cim:abbreviation'), - ('address', False, 'str', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint'), - ('address', False, 'str', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint/gco:CharacterString'), - ('email', False, 'str', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress'), - ('email', False, 'str', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString'), - ('individual_name', False, 'str', 'child::gmd:individualName'), - ('individual_name', False, 'str', 'child::gmd:individualName/gco:CharacterString'), - ('organisation_name', False, 'str', 'child::gmd:organisationName'), - ('organisation_name', False, 'str', 'child::gmd:organisationName/gco:CharacterString'), - ('role', False, 'str', 'gmd:role/gmd:CI_RoleCode/@codeListValue'), - ('url', False, 'str', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:onlineResource/gmd:CI_OnlineResource/gmd:linkage/gmd:URL'), + ('abbreviation', False, 'unicode', 'child::cim:abbreviation'), + ('address', False, 'unicode', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint'), + ('address', False, 'unicode', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint/gco:CharacterString'), + ('email', False, 'unicode', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress'), + ('email', False, 'unicode', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString'), + ('individual_name', False, 'unicode', 'child::gmd:individualName'), + ('individual_name', False, 'unicode', 'child::gmd:individualName/gco:CharacterString'), + ('organisation_name', False, 'unicode', 'child::gmd:organisationName'), + ('organisation_name', False, 'unicode', 'child::gmd:organisationName/gco:CharacterString'), + ('role', False, 'unicode', 'gmd:role/gmd:CI_RoleCode/@codeListValue'), + ('url', False, 'unicode', 'child::gmd:contactInfo/gmd:CI_Contact/gmd:onlineResource/gmd:CI_OnlineResource/gmd:linkage/gmd:URL'), ] return set_attributes(typeset.shared.ResponsibleParty(), xml, nsmap, decodings) @@ -579,20 +508,17 @@ def decode_responsible_party(xml, nsmap): def decode_standard(xml, nsmap): """Decodes an instance of the following type: standard. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.Standard """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('name', False, 'str', 'child::cim:name'), - ('version', False, 'str', 'child::cim:version'), + ('description', False, 'unicode', 'child::cim:description'), + ('name', False, 'unicode', 'child::cim:name'), + ('version', False, 'unicode', 'child::cim:version'), ] return set_attributes(typeset.shared.Standard(), xml, nsmap, decodings) @@ -601,11 +527,8 @@ def decode_standard(xml, nsmap): def decode_standard_name(xml, nsmap): """Decodes an instance of the following type: standard name. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.shared.StandardName @@ -614,7 +537,7 @@ def decode_standard_name(xml, nsmap): decodings = [ ('is_open', False, 'bool', '@open'), ('standards', True, decode_standard, 'child::cim:standard'), - ('value', False, 'str', '@value'), + ('value', False, 'unicode', '@value'), ] return set_attributes(typeset.shared.StandardName(), xml, nsmap, decodings) diff --git a/pyesdoc/ontologies/cim/v1/decoder_for_software_package.py b/pyesdoc/ontologies/cim/v1/decoder_for_software_package.py index e9d3d7d..f0992d4 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_for_software_package.py +++ b/pyesdoc/ontologies/cim/v1/decoder_for_software_package.py @@ -24,11 +24,8 @@ def decode_component(xml, nsmap): """Decodes an instance of the following type: component. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Component @@ -36,15 +33,15 @@ def decode_component(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citation'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('language', False, decode_component_language, 'child::cim:componentLanguage'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('properties', True, decode_component_property, 'child::cim:componentProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:numericalProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:scientificProperties/cim:componentProperty'), ('release_date', False, 'datetime.datetime', 'child::cim:releaseDate'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('sub_components', True, decode_model_component, 'child::cim:childComponent/cim:modelComponent'), ('sub_components', True, decode_processor_component, 'child::cim:childComponent/cim:processorComponent'), ] @@ -55,18 +52,15 @@ def decode_component(xml, nsmap): def decode_component_language(xml, nsmap): """Decodes an instance of the following type: component language. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ComponentLanguage """ decodings = [ - ('name', False, 'str', 'child::cim:name'), + ('name', False, 'unicode', 'child::cim:name'), ] return set_attributes(typeset.software.ComponentLanguage(), xml, nsmap, decodings) @@ -75,19 +69,16 @@ def decode_component_language(xml, nsmap): def decode_component_language_property(xml, nsmap): """Decodes an instance of the following type: component language property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ComponentLanguageProperty """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.software.ComponentLanguageProperty(), xml, nsmap, decodings) @@ -96,11 +87,8 @@ def decode_component_language_property(xml, nsmap): def decode_component_property(xml, nsmap): """Decodes an instance of the following type: component property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ComponentProperty @@ -108,15 +96,15 @@ def decode_component_property(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citation'), - ('description', False, 'str', 'child::cim:description'), - ('intent', False, 'str', 'self::cim:componentProperty/@intent'), + ('description', False, 'unicode', 'child::cim:description'), + ('intent', False, 'unicode', 'self::cim:componentProperty/@intent'), ('is_represented', False, 'bool', 'self::cim:componentProperty/@represented'), - ('long_name', False, 'str', 'child::cim:longName'), - ('short_name', False, 'str', 'child::cim:shortName'), - ('standard_names', True, 'str', 'child::cim:standardName/@value'), + ('long_name', False, 'unicode', 'child::cim:longName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), + ('standard_names', True, 'unicode', 'child::cim:standardName/@value'), ('sub_properties', True, decode_component_property, 'child::cim:componentProperty'), - ('units', False, 'str', 'child::cim:units/@value'), - ('values', True, 'str', 'child::cim:value'), + ('units', False, 'unicode', 'child::cim:units/@value'), + ('values', True, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.software.ComponentProperty(), xml, nsmap, decodings) @@ -125,11 +113,8 @@ def decode_component_property(xml, nsmap): def decode_composition(xml, nsmap): """Decodes an instance of the following type: composition. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Composition @@ -144,18 +129,15 @@ def decode_composition(xml, nsmap): def decode_connection(xml, nsmap): """Decodes an instance of the following type: connection. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Connection """ decodings = [ - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('priming', False, decode_component_property, 'child::cim:priming/cim:priming/cim:componentProperty'), ('priming', False, decode_data_content, 'child::cim:priming/cim:priming/cim:dataContent'), ('priming', False, decode_data_object, 'child::cim:priming/cim:priming/cim:dataObject'), @@ -167,12 +149,12 @@ def decode_connection(xml, nsmap): ('sources', True, decode_connection_endpoint, 'child::cim:connectionSource'), ('spatial_regridding', True, decode_spatial_regridding, 'child::cim:spatialRegridding'), ('target', False, decode_connection_endpoint, 'child::cim:connectionTarget'), - ('time_lag', False, 'str', 'child::cim:timeLag'), + ('time_lag', False, 'unicode', 'child::cim:timeLag'), ('time_profile', False, decode_timing, 'child::cim:timeProfile'), ('time_transformation', False, decode_time_transformation, 'child::cim:timeTransformation'), ('transformers', True, decode_processor_component, 'child::cim:transformer/cim:processorComponent'), ('transformers_references', True, decode_doc_reference, 'child::cim:transformer/cim:reference'), - ('type', False, 'str', 'child::cim:type/@value'), + ('type', False, 'unicode', 'child::cim:type/@value'), ] return set_attributes(typeset.software.Connection(), xml, nsmap, decodings) @@ -181,11 +163,8 @@ def decode_connection(xml, nsmap): def decode_connection_endpoint(xml, nsmap): """Decodes an instance of the following type: connection endpoint. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ConnectionEndpoint @@ -199,7 +178,7 @@ def decode_connection_endpoint(xml, nsmap): ('data_source', False, decode_processor_component, 'child::cim:dataSource/cim:dataSource/cim:softwareComponent'), ('data_source', False, decode_statistical_model_component, 'child::cim:dataSource/cim:dataSource/cim:softwareComponent'), ('data_source_reference', False, decode_doc_reference, 'child::cim:dataSource/cim:reference'), - ('instance_id', False, 'str', 'child::cim:instanceID'), + ('instance_id', False, 'unicode', 'child::cim:instanceID'), ('properties', True, decode_connection_property, 'child::cim:connectionProperty'), ] @@ -209,19 +188,16 @@ def decode_connection_endpoint(xml, nsmap): def decode_connection_property(xml, nsmap): """Decodes an instance of the following type: connection property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ConnectionProperty """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.software.ConnectionProperty(), xml, nsmap, decodings) @@ -230,11 +206,8 @@ def decode_connection_property(xml, nsmap): def decode_coupling(xml, nsmap): """Decodes an instance of the following type: coupling. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Coupling @@ -242,7 +215,7 @@ def decode_coupling(xml, nsmap): """ decodings = [ ('connections', True, decode_connection, 'child::cim:connection'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('is_fully_specified', False, 'bool', '@fullySpecified'), ('priming', False, decode_component_property, 'child::cim:priming/cim:priming/cim:componentProperty'), ('priming', False, decode_data_content, 'child::cim:priming/cim:priming/cim:dataContent'), @@ -252,7 +225,7 @@ def decode_coupling(xml, nsmap): ('priming', False, decode_statistical_model_component, 'child::cim:priming/cim:priming/cim:softwareComponent'), ('priming_reference', False, decode_doc_reference, 'child::cim:priming/cim:reference'), ('properties', True, decode_coupling_property, 'child::cim:couplingProperty'), - ('purpose', False, 'str', '@purpose'), + ('purpose', False, 'unicode', '@purpose'), ('sources', True, decode_coupling_endpoint, 'child::cim:couplingSource'), ('spatial_regriddings', True, decode_spatial_regridding, 'child::cim:spatialRegridding'), ('target', False, decode_coupling_endpoint, 'child::cim:couplingTarget'), @@ -261,7 +234,7 @@ def decode_coupling(xml, nsmap): ('time_transformation', False, decode_time_transformation, 'child::cim:timeTransformation'), ('transformers', True, decode_processor_component, 'child::cim:transformer/cim:processorComponent'), ('transformers_references', True, decode_doc_reference, 'child::cim:transformer/cim:reference'), - ('type', False, 'str', 'child::cim:type/@value'), + ('type', False, 'unicode', 'child::cim:type/@value'), ] return set_attributes(typeset.software.Coupling(), xml, nsmap, decodings) @@ -270,11 +243,8 @@ def decode_coupling(xml, nsmap): def decode_coupling_endpoint(xml, nsmap): """Decodes an instance of the following type: coupling endpoint. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.CouplingEndpoint @@ -288,7 +258,7 @@ def decode_coupling_endpoint(xml, nsmap): ('data_source', False, decode_processor_component, 'child::cim:dataSource/cim:dataSource/cim:softwareComponent'), ('data_source', False, decode_statistical_model_component, 'child::cim:dataSource/cim:dataSource/cim:softwareComponent'), ('data_source_reference', False, decode_doc_reference, 'child::cim:dataSource/cim:reference'), - ('instance_id', False, 'str', 'child::cim:instanceID'), + ('instance_id', False, 'unicode', 'child::cim:instanceID'), ('properties', True, decode_coupling_property, 'child::cim:couplingProperty'), ] @@ -298,19 +268,16 @@ def decode_coupling_endpoint(xml, nsmap): def decode_coupling_property(xml, nsmap): """Decodes an instance of the following type: coupling property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.CouplingProperty """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.software.CouplingProperty(), xml, nsmap, decodings) @@ -319,11 +286,8 @@ def decode_coupling_property(xml, nsmap): def decode_deployment(xml, nsmap): """Decodes an instance of the following type: deployment. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Deployment @@ -331,9 +295,9 @@ def decode_deployment(xml, nsmap): """ decodings = [ ('deployment_date', False, 'datetime.datetime', 'child::cim:deploymentDate'), - ('description', False, 'str', 'child::cim:description'), - ('executable_arguments', True, 'str', 'child::cim:executableArgument'), - ('executable_name', False, 'str', 'child::cim:executableName'), + ('description', False, 'unicode', 'child::cim:description'), + ('executable_arguments', True, 'unicode', 'child::cim:executableArgument'), + ('executable_name', False, 'unicode', 'child::cim:executableName'), ('parallelisation', False, decode_parallelisation, 'child::cim:parallelisation'), ('platform', False, decode_platform, 'child::cim:platform/cim:platform'), ('platform_reference', False, decode_doc_reference, 'child::cim:platform/cim:reference'), @@ -345,11 +309,8 @@ def decode_deployment(xml, nsmap): def decode_entry_point(xml, nsmap): """Decodes an instance of the following type: entry point. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.EntryPoint @@ -364,11 +325,8 @@ def decode_entry_point(xml, nsmap): def decode_model_component(xml, nsmap): """Decodes an instance of the following type: model component. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ModelComponent @@ -376,21 +334,21 @@ def decode_model_component(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citation'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('language', False, decode_component_language, 'child::cim:componentLanguage'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:modelComponent'), ('properties', True, decode_component_property, 'child::cim:componentProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:numericalProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:scientificProperties/cim:componentProperty'), ('release_date', False, 'datetime.datetime', 'child::cim:releaseDate'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('sub_components', True, decode_model_component, 'child::cim:childComponent/cim:modelComponent'), ('sub_components', True, decode_processor_component, 'child::cim:childComponent/cim:processorComponent'), ('timing', False, decode_timing, 'child::cim:timing'), - ('type', False, 'str', 'child::cim:type[1]/@value'), - ('types', True, 'str', 'child::cim:type/@value'), + ('type', False, 'unicode', 'child::cim:type[1]/@value'), + ('types', True, 'unicode', 'child::cim:type/@value'), ] return set_attributes(typeset.software.ModelComponent(), xml, nsmap, decodings) @@ -399,11 +357,8 @@ def decode_model_component(xml, nsmap): def decode_parallelisation(xml, nsmap): """Decodes an instance of the following type: parallelisation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Parallelisation @@ -420,11 +375,8 @@ def decode_parallelisation(xml, nsmap): def decode_processor_component(xml, nsmap): """Decodes an instance of the following type: processor component. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.ProcessorComponent @@ -432,16 +384,16 @@ def decode_processor_component(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citation'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('language', False, decode_component_language, 'child::cim:componentLanguage'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:modelComponent'), ('properties', True, decode_component_property, 'child::cim:componentProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:numericalProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:scientificProperties/cim:componentProperty'), ('release_date', False, 'datetime.datetime', 'child::cim:releaseDate'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('sub_components', True, decode_model_component, 'child::cim:childComponent/cim:modelComponent'), ('sub_components', True, decode_processor_component, 'child::cim:childComponent/cim:processorComponent'), ] @@ -452,11 +404,8 @@ def decode_processor_component(xml, nsmap): def decode_rank(xml, nsmap): """Decodes an instance of the following type: rank. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Rank @@ -475,20 +424,17 @@ def decode_rank(xml, nsmap): def decode_spatial_regridding(xml, nsmap): """Decodes an instance of the following type: spatial regridding. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.SpatialRegridding """ decodings = [ - ('dimension', False, 'str', 'child::cim:spatialRegriddingDimension'), + ('dimension', False, 'unicode', 'child::cim:spatialRegriddingDimension'), ('properties', True, decode_spatial_regridding_property, 'child::cim:spatialRegriddingProperty'), - ('standard_method', False, 'str', 'child::cim:spatialRegriddingStandardMethod'), + ('standard_method', False, 'unicode', 'child::cim:spatialRegriddingStandardMethod'), ('user_method', False, decode_spatial_regridding_user_method, 'child::cim:spatialRegriddingUserMethod'), ] @@ -498,19 +444,16 @@ def decode_spatial_regridding(xml, nsmap): def decode_spatial_regridding_property(xml, nsmap): """Decodes an instance of the following type: spatial regridding property. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.SpatialRegriddingProperty """ decodings = [ - ('name', False, 'str', 'child::cim:name'), - ('value', False, 'str', 'child::cim:value'), + ('name', False, 'unicode', 'child::cim:name'), + ('value', False, 'unicode', 'child::cim:value'), ] return set_attributes(typeset.software.SpatialRegriddingProperty(), xml, nsmap, decodings) @@ -519,11 +462,8 @@ def decode_spatial_regridding_property(xml, nsmap): def decode_spatial_regridding_user_method(xml, nsmap): """Decodes an instance of the following type: spatial regridding user method. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.SpatialRegriddingUserMethod @@ -532,7 +472,7 @@ def decode_spatial_regridding_user_method(xml, nsmap): decodings = [ ('file', False, decode_data_object, 'child::cim:file/cim:dataObject'), ('file_reference', False, decode_doc_reference, 'child::cim:file/cim:reference'), - ('name', False, 'str', 'child::cim:name'), + ('name', False, 'unicode', 'child::cim:name'), ] return set_attributes(typeset.software.SpatialRegriddingUserMethod(), xml, nsmap, decodings) @@ -541,11 +481,8 @@ def decode_spatial_regridding_user_method(xml, nsmap): def decode_statistical_model_component(xml, nsmap): """Decodes an instance of the following type: statistical model component. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.StatisticalModelComponent @@ -553,21 +490,21 @@ def decode_statistical_model_component(xml, nsmap): """ decodings = [ ('citations', True, decode_citation, 'child::cim:citation'), - ('description', False, 'str', 'child::cim:description'), + ('description', False, 'unicode', 'child::cim:description'), ('language', False, decode_component_language, 'child::cim:componentLanguage'), - ('long_name', False, 'str', 'child::cim:longName'), + ('long_name', False, 'unicode', 'child::cim:longName'), ('meta', False, decode_doc_meta_info, 'self::cim:statisticalModelComponent'), ('properties', True, decode_component_property, 'child::cim:componentProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:numericalProperties/cim:componentProperty'), ('properties', True, decode_component_property, 'child::cim:scientificProperties/cim:componentProperty'), ('release_date', False, 'datetime.datetime', 'child::cim:releaseDate'), ('responsible_parties', True, decode_responsible_party, 'child::cim:responsibleParty'), - ('short_name', False, 'str', 'child::cim:shortName'), + ('short_name', False, 'unicode', 'child::cim:shortName'), ('sub_components', True, decode_model_component, 'child::cim:childComponent/cim:modelComponent'), ('sub_components', True, decode_processor_component, 'child::cim:childComponent/cim:processorComponent'), ('timing', False, decode_timing, 'child::cim:timing'), - ('type', False, 'str', 'child::cim:type[1]/@value'), - ('types', True, 'str', 'child::cim:type/@value'), + ('type', False, 'unicode', 'child::cim:type[1]/@value'), + ('types', True, 'unicode', 'child::cim:type/@value'), ] return set_attributes(typeset.software.StatisticalModelComponent(), xml, nsmap, decodings) @@ -576,18 +513,15 @@ def decode_statistical_model_component(xml, nsmap): def decode_time_lag(xml, nsmap): """Decodes an instance of the following type: time lag. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.TimeLag """ decodings = [ - ('units', False, 'str', '@units'), + ('units', False, 'unicode', '@units'), ('value', False, 'int', 'child::cim:value'), ] @@ -597,19 +531,16 @@ def decode_time_lag(xml, nsmap): def decode_time_transformation(xml, nsmap): """Decodes an instance of the following type: time transformation. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.TimeTransformation """ decodings = [ - ('description', False, 'str', 'child::cim:description'), - ('mapping_type', False, 'str', 'child::cim:mappingType/@value'), + ('description', False, 'unicode', 'child::cim:description'), + ('mapping_type', False, 'unicode', 'child::cim:mappingType/@value'), ] return set_attributes(typeset.software.TimeTransformation(), xml, nsmap, decodings) @@ -618,11 +549,8 @@ def decode_time_transformation(xml, nsmap): def decode_timing(xml, nsmap): """Decodes an instance of the following type: timing. - :param xml: XML from which type is to be decoded. - :type xml: lxml.etree - - :param nsmap: XML namespace mappings. - :type nsmap: dict + :param lxml.etree xml: XML from which type is to be decoded. + :param dict nsmap: XML namespace mappings. :returns: A decoded type instance. :rtype: cim.v1.typeset.software.Timing @@ -633,7 +561,7 @@ def decode_timing(xml, nsmap): ('is_variable_rate', False, 'bool', '@variableRate'), ('rate', False, 'int', 'child::cim:rate'), ('start', False, 'datetime.datetime', 'child::cim:start'), - ('units', False, 'str', '@units'), + ('units', False, 'unicode', '@units'), ] return set_attributes(typeset.software.Timing(), xml, nsmap, decodings) diff --git a/pyesdoc/ontologies/cim/v1/decoder_xml_utils.py b/pyesdoc/ontologies/cim/v1/decoder_xml_utils.py index fcacefa..42b343c 100644 --- a/pyesdoc/ontologies/cim/v1/decoder_xml_utils.py +++ b/pyesdoc/ontologies/cim/v1/decoder_xml_utils.py @@ -24,101 +24,87 @@ # Null uuid for checking whether one has to be generated. -NULL_UUID = ['00000000-0000-0000-0000-000000000000'] +NULL_UUID = u'00000000-0000-0000-0000-000000000000' -def _get_value_as_string(xml, nsmap): - """Converts passed xml fragment to a string.""" - result = None - - # Strip first item from iterables. +def _get_value(xml, rtype=unicode): + """Returns xml node value.""" + # Get xml node. if isinstance(xml, types.ListType): - if len(xml) > 0: - xml = xml[0] - else: - xml = None - - # Get raw string. + xml = None if len(xml) == 0 else xml[0] if xml is None: - result = None - elif isinstance(xml, types.StringTypes): - result = convert.unicode_to_str(xml) + return None + + # Convert xml node. + if rtype is unicode: + if isinstance(xml, types.StringTypes): + result = convert.str_to_unicode(xml) + else: + result = convert.str_to_unicode(et.tostring(xml)) else: - result = et.tostring(xml) + if isinstance(xml, types.StringTypes): + result = convert.unicode_to_str(xml) + else: + result = et.tostring(xml) - # Format string. - if result is not None: - result = result.strip() - result = result.rstrip('|') + # Format. + result = result.strip() + result = result.rstrip('|') return result -def _convert_to_string(xml, nsmap=None): - """Converts an etree element xml representation into a string type.""" - return _get_value_as_string(xml, nsmap) +def _convert_to_unicode(xml, nsmap=None): + """Converts an etree element xml representation into a unicode type.""" + return _get_value(xml, str) def _convert_to_bool(xml, nsmap=None): """Converts an etree element xml representation into a boolean type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: - return bool() - else: - as_string = as_string.upper() - if as_string in ['TRUE']: - return True - elif as_string in ['FALSE']: - return False - else: - return bool() + value = _get_value(xml) + + return True if value is not None and value.lower() in [u'true'] else bool() def _convert_to_integer(xml, nsmap=None): """Converts an etree element xml representation into an integer type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None or as_string.upper() == 'NONE': - return int() - else: - return int(as_string) + value = _get_value(xml) + + return int(value) if value is not None and value.upper() != u'NONE' else int() def _convert_to_float(xml, nsmap=None): """Converts an etree element xml representation into a float type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: - return float() - else: - return float(as_string) + value = _get_value(xml) + + return float(value) if value is not None else float() def _convert_to_uid(xml, nsmap=None): """Converts an etree element xml representation into a uid type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None or as_string in NULL_UUID: + value = _get_value(xml) + if value is None or value == NULL_UUID: return uuid.uuid4() - else: - try: - return uuid.UUID(as_string) - except ValueError: - # Workaround for poorly encoded uuid's in cmip5 questionnaire - return uuid.UUID(as_string[0:36]) + try: + return uuid.UUID(value) + except ValueError: + return uuid.UUID(value[0:36]) def _convert_to_datetime(xml, nsmap=None): """Converts an etree element xml representation into a datetime type.""" - as_string = _get_value_as_string(xml, nsmap) - if as_string is None: + value = _get_value(xml) + if value is None: return None + if len(value) == 4: + return arrow.get(value, u"YYYY").datetime else: - if len(as_string) == 4: - return arrow.get(as_string, 'YYYY').datetime - else: - return arrow.get(as_string).datetime + return arrow.get(value).datetime + # Set of simple type convertors. -_simple_type_decoders = { +_SIMPLE_TYPE_DECODERS = { 'bool' : _convert_to_bool, 'date' : _convert_to_datetime, 'datetime' : _convert_to_datetime, @@ -126,8 +112,9 @@ def _convert_to_datetime(xml, nsmap=None): 'datetime.datetime' : _convert_to_datetime, 'float' : _convert_to_float, 'int' : _convert_to_integer, - 'str' : _convert_to_string, - 'uri' : _convert_to_string, + 'str' : _convert_to_unicode, + 'unicode' : _convert_to_unicode, + 'uri' : _convert_to_unicode, 'uuid' : _convert_to_uid, 'uuid.UUID' : _convert_to_uid, } @@ -136,17 +123,10 @@ def _convert_to_datetime(xml, nsmap=None): def set_attributes(target, xml, nsmap, decodings): """Decodes entity attributes from a collection of decodings. - :param target: A pyesdoc object with a set of attributes to be assigned. - :type target: object - - :param xml: An xml element. - :type xml: lxml.etree._Element - - :param nsmap: Set of xml namespace mappings. - :type nsmap: dict - - :param decodings: Set of mappings used to perform decoding. - :type decodings: dict + :param object target: A pyesdoc object with a set of attributes to be assigned. + :param lxml.etree._Element xml: An xml element. + :param dict nsmap: Set of xml namespace mappings. + :param dict decodings: Set of mappings used to perform decoding. :returns: A pyesdoc object with assigned attributes. :rtype: object @@ -164,7 +144,7 @@ def set_attributes(target, xml, nsmap, decodings): attrs.append(attr) # Determine if type is a simple one. - is_simple_type = type in _simple_type_decoders + is_simple_type = type in _SIMPLE_TYPE_DECODERS try: _set_attribute(target, @@ -237,48 +217,34 @@ def _set_attribute(target, def _get_attribute_value(xml, nsmap, decoder, xpath, is_simple_type, is_iterable): """Gets the value of an attribute from xml.""" - result = None - # Apply xpath (derive xml fragment from value is derived). att_xml = xml.xpath(xpath, namespaces=nsmap) if not att_xml: - return None if not is_iterable else [] + return [] if is_iterable else None # From xml derive value. # ... simple types. if is_simple_type: - if decoder in _simple_type_decoders: - decoder = _simple_type_decoders[decoder] + if decoder in _SIMPLE_TYPE_DECODERS: + decoder = _SIMPLE_TYPE_DECODERS[decoder] if is_iterable: - result = map(lambda i: decoder(i, nsmap), att_xml) + return [decoder(i, nsmap) for i in att_xml] else: - result = decoder(att_xml, nsmap) + decoded = decoder(att_xml, nsmap) + return None if decoded == str() else decoded # ... complex types. else: - result = decode_xml(decoder, att_xml, nsmap, is_iterable) - - # Workaround - decoding empty xml attributes. - if is_simple_type and not is_iterable and result == str(): - result = None - - return result + return decode_xml(decoder, att_xml, nsmap, is_iterable) def decode_xml(decoder, xml, nsmap, is_iterable): """Decodes either an entity or an entity collection from xml. - :param decoder: Decoder function pointer. - :type decoder: function - - :param xml: An xml element. - :type xml: lxml.etree._Element - - :param nsmap: Set of xml namespace mappings. - :type nsmap: dict - - :param take_first: Flag indicating whether to return only the first entity of a collection. - :type take_first: bool + :param function decoder: Decoder function pointer. + :param lxml.etree._Element xml: An xml element. + :param dict nsmap: Set of xml namespace mappings. + :param bool take_first: Flag indicating whether to return only the first entity of a collection. :returns: Decoded entity or entity collection. :rtype: miscellaneous @@ -311,14 +277,9 @@ def decode_xml(decoder, xml, nsmap, is_iterable): def load_xml(xml, return_nsmap=False, default_ns='cim'): """Loads etree xml element. - :param xml: An xml blob. - :type xml: string - - :param return_nsmap: Flag indicating whether namespace map will be returned or not. - :type return_nsmap: bool - - :param default_ns: Default namespace. - :type default_ns: str + :param string xml: An xml blob. + :param bool return_nsmap: Flag indicating whether namespace map will be returned or not. + :param str default_ns: Default namespace. :returns: XML element. :rtype: lxml.etree._Element @@ -328,7 +289,6 @@ def load_xml(xml, return_nsmap=False, default_ns='cim'): if xml is None: raise pyesdoc.DecodingException("XML is undefined.") - # ... etree elements. nsmap = None if isinstance(xml, et._Element): diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_activity_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_activity_package.py index f28cc90..e21cf15 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_activity_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_activity_package.py @@ -35,9 +35,9 @@ def __init__(self): """ super(Activity, self).__init__() - self.funding_sources = [] # str + self.funding_sources = [] # unicode self.projects = [] # activity.ProjectType - self.rationales = [] # str + self.rationales = [] # unicode self.responsible_parties = [] # shared.ResponsibleParty @@ -53,7 +53,7 @@ def __init__(self): """ super(Conformance, self).__init__() - self.description = None # str + self.description = None # unicode self.frequency = None # activity.FrequencyType self.is_conformant = None # bool self.requirements = [] # activity.NumericalRequirement @@ -109,11 +109,11 @@ def __init__(self): """ super(NumericalRequirement, self).__init__() - self.description = None # str - self.id = None # str - self.name = None # str + self.description = None # unicode + self.id = None # unicode + self.name = None # unicode self.options = [] # activity.NumericalRequirementOption - self.requirement_type = None # str + self.requirement_type = None # unicode self.source = None # shared.DataSource self.source_reference = None # shared.DocReference @@ -130,10 +130,10 @@ def __init__(self): """ super(NumericalRequirementOption, self).__init__() - self.description = None # str - self.id = None # str - self.name = None # str - self.relationship = None # str + self.description = None # unicode + self.id = None # unicode + self.name = None # unicode + self.relationship = None # unicode self.sub_options = [] # activity.NumericalRequirementOption @@ -181,7 +181,7 @@ def __init__(self): """ super(BoundaryCondition, self).__init__() - self.requirement_type = str("boundaryCondition") + self.requirement_type = unicode("boundaryCondition") class Experiment(Activity): @@ -198,11 +198,11 @@ def __init__(self): """ super(Experiment, self).__init__() - self.generates = [] # str + self.generates = [] # unicode self.measurement_campaigns = [] # activity.MeasurementCampaign self.requires = [] # activity.NumericalActivity self.requires_references = [] # shared.DocReference - self.supports = [] # str + self.supports = [] # unicode self.supports_references = [] # shared.DocReference @@ -218,7 +218,7 @@ def __init__(self): """ super(InitialCondition, self).__init__() - self.requirement_type = str("initialCondition") + self.requirement_type = unicode("initialCondition") class LateralBoundaryCondition(NumericalRequirement): @@ -233,7 +233,7 @@ def __init__(self): """ super(LateralBoundaryCondition, self).__init__() - self.requirement_type = str("lateralBoundaryCondition") + self.requirement_type = unicode("lateralBoundaryCondition") class MeasurementCampaign(Activity): @@ -265,9 +265,9 @@ def __init__(self): """ super(NumericalActivity, self).__init__() - self.description = None # str - self.long_name = None # str - self.short_name = None # str + self.description = None # unicode + self.long_name = None # unicode + self.short_name = None # unicode self.supports = [] # activity.Experiment self.supports_references = [] # shared.DocReference @@ -284,12 +284,12 @@ def __init__(self): """ super(NumericalExperiment, self).__init__() - self.description = None # str - self.experiment_id = None # str - self.long_name = None # str + self.description = None # unicode + self.experiment_id = None # unicode + self.long_name = None # unicode self.meta = shared.DocMetaInfo() # shared.DocMetaInfo self.requirements = [] # activity.NumericalRequirement - self.short_name = None # str + self.short_name = None # unicode class OutputRequirement(NumericalRequirement): @@ -304,7 +304,7 @@ def __init__(self): """ super(OutputRequirement, self).__init__() - self.requirement_type = str("outputRequirement") + self.requirement_type = unicode("outputRequirement") class PhysicalModification(Conformance): @@ -335,7 +335,7 @@ def __init__(self): """ super(Simulation, self).__init__() - self.authors = None # str + self.authors = None # unicode self.calendar = None # shared.Calendar self.conformances = [] # activity.Conformance self.control_simulation = None # activity.Simulation @@ -346,7 +346,7 @@ def __init__(self): self.outputs = [] # data.DataObject self.restart_references = [] # shared.DocReference self.restarts = [] # data.DataObject - self.simulation_id = None # str + self.simulation_id = None # unicode self.spinup_date_range = None # shared.ClosedDateRange self.spinup_simulation = None # activity.Simulation self.spinup_simulation_reference = None # shared.DocReference @@ -402,7 +402,7 @@ def __init__(self): self.date_range = None # shared.DateRange self.spatial_resolution = None # activity.ResolutionType - self.requirement_type = str("spatioTemporalConstraint") + self.requirement_type = unicode("spatioTemporalConstraint") class DownscalingSimulation(NumericalActivity): @@ -422,7 +422,7 @@ def __init__(self): self.calendar = None # shared.Calendar self.downscaled_from = None # shared.DataSource self.downscaled_from_reference = None # shared.DocReference - self.downscaling_id = None # str + self.downscaling_id = None # unicode self.downscaling_type = None # activity.DownscalingType self.inputs = [] # software.Coupling self.meta = shared.DocMetaInfo() # shared.DocMetaInfo diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_data_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_data_package.py index 477bfe3..c2c649e 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_data_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_data_package.py @@ -33,8 +33,8 @@ def __init__(self): """ super(DataContent, self).__init__() - self.aggregation = None # str - self.frequency = None # str + self.aggregation = None # unicode + self.frequency = None # unicode self.topic = None # data.DataTopic @@ -50,9 +50,9 @@ def __init__(self): """ super(DataDistribution, self).__init__() - self.access = None # str - self.fee = None # str - self.format = None # str + self.access = None # unicode + self.fee = None # unicode + self.format = None # unicode self.responsible_party = None # shared.ResponsibleParty @@ -121,7 +121,7 @@ def __init__(self): self.factor = None # int self.radix = None # int - self.unit = None # str + self.unit = None # unicode class DataHierarchyLevel(object): @@ -138,7 +138,7 @@ def __init__(self): self.is_open = None # bool self.name = None # data.DataHierarchyType - self.value = None # str + self.value = None # unicode class DataObject(shared.DataSource): @@ -153,24 +153,24 @@ def __init__(self): """ super(DataObject, self).__init__() - self.acronym = None # str + self.acronym = None # unicode self.child_object = [] # data.DataObject self.citations = [] # shared.Citation self.content = [] # data.DataContent self.data_status = None # data.DataStatusType - self.description = None # str + self.description = None # unicode self.distribution = None # data.DataDistribution self.extent = None # data.DataExtent - self.geometry_model = None # str + self.geometry_model = None # unicode self.hierarchy_level = None # data.DataHierarchyLevel - self.keyword = None # str + self.keyword = None # unicode self.meta = shared.DocMetaInfo() # shared.DocMetaInfo self.parent_object = None # data.DataObject self.parent_object_reference = None # shared.DocReference self.properties = [] # data.DataProperty - self.purpose = None # str + self.purpose = None # unicode self.restriction = [] # data.DataRestriction - self.source_simulation = None # str + self.source_simulation = None # unicode self.storage = [] # data.DataStorage @@ -186,7 +186,7 @@ def __init__(self): """ super(DataProperty, self).__init__() - self.description = None # str + self.description = None # unicode class DataRestriction(object): @@ -202,8 +202,8 @@ def __init__(self): super(DataRestriction, self).__init__() self.license = None # shared.License - self.restriction = None # str - self.scope = None # str + self.restriction = None # unicode + self.scope = None # unicode class DataStorage(object): @@ -220,8 +220,8 @@ def __init__(self): """ super(DataStorage, self).__init__() - self.format = None # str - self.location = None # str + self.format = None # unicode + self.location = None # unicode self.modification_date = None # datetime.datetime self.size = None # int @@ -238,9 +238,9 @@ def __init__(self): """ super(DataTopic, self).__init__() - self.description = None # str - self.name = None # str - self.unit = None # str + self.description = None # unicode + self.name = None # unicode + self.unit = None # unicode class DataStorageDb(DataStorage): @@ -255,10 +255,10 @@ def __init__(self): """ super(DataStorageDb, self).__init__() - self.access_string = None # str - self.name = None # str - self.owner = None # str - self.table = None # str + self.access_string = None # unicode + self.name = None # unicode + self.owner = None # unicode + self.table = None # unicode class DataStorageFile(DataStorage): @@ -273,9 +273,9 @@ def __init__(self): """ super(DataStorageFile, self).__init__() - self.file_name = None # str - self.file_system = None # str - self.path = None # str + self.file_name = None # unicode + self.file_system = None # unicode + self.path = None # unicode class DataStorageIp(DataStorage): @@ -290,10 +290,10 @@ def __init__(self): """ super(DataStorageIp, self).__init__() - self.file_name = None # str - self.host = None # str - self.path = None # str - self.protocol = None # str + self.file_name = None # unicode + self.host = None # unicode + self.path = None # unicode + self.protocol = None # unicode class DataHierarchyType(object): diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_grids_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_grids_package.py index f746c2b..637730b 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_grids_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_grids_package.py @@ -35,7 +35,7 @@ def __init__(self): self.has_constant_offset = None # bool self.length = None # int - self.uom = None # str + self.uom = None # unicode class GridExtent(object): @@ -50,11 +50,11 @@ def __init__(self): """ super(GridExtent, self).__init__() - self.maximum_latitude = None # str - self.maximum_longitude = None # str - self.minimum_latitude = None # str - self.minimum_longitude = None # str - self.units = None # str + self.maximum_latitude = None # unicode + self.maximum_longitude = None # unicode + self.minimum_latitude = None # unicode + self.minimum_longitude = None # unicode + self.units = None # unicode class GridMosaic(object): @@ -70,19 +70,19 @@ def __init__(self): super(GridMosaic, self).__init__() self.citations = [] # shared.Citation - self.description = None # str + self.description = None # unicode self.extent = None # grids.GridExtent self.has_congruent_tiles = None # bool - self.id = None # str + self.id = None # unicode self.is_leaf = None # bool - self.long_name = None # str - self.mnemonic = None # str + self.long_name = None # unicode + self.mnemonic = None # unicode self.mosaic_count = None # int self.mosaics = [] # grids.GridMosaic - self.short_name = None # str + self.short_name = None # unicode self.tile_count = None # int self.tiles = [] # grids.GridTile - self.type = None # str + self.type = None # unicode class GridProperty(shared.Property): @@ -128,32 +128,32 @@ def __init__(self): """ super(GridTile, self).__init__() - self.area = None # str - self.cell_array = None # str - self.cell_ref_array = None # str - self.coord_file = None # str - self.coordinate_pole = None # str - self.description = None # str + self.area = None # unicode + self.cell_array = None # unicode + self.cell_ref_array = None # unicode + self.coord_file = None # unicode + self.coordinate_pole = None # unicode + self.description = None # unicode self.discretization_type = None # grids.DiscretizationEnum self.extent = None # grids.GridExtent self.geometry_type = None # grids.GeometryTypeEnum - self.grid_north_pole = None # str - self.horizontal_crs = None # str + self.grid_north_pole = None # unicode + self.horizontal_crs = None # unicode self.horizontal_resolution = None # grids.GridTileResolutionType - self.id = None # str + self.id = None # unicode self.is_conformal = None # bool self.is_regular = None # bool self.is_terrain_following = None # bool self.is_uniform = None # bool - self.long_name = None # str - self.mnemonic = None # str + self.long_name = None # unicode + self.mnemonic = None # unicode self.nx = None # int self.ny = None # int self.nz = None # int self.refinement_scheme = None # grids.RefinementTypeEnum - self.short_name = None # str + self.short_name = None # unicode self.simple_grid_geom = None # grids.SimpleGridGeometry - self.vertical_crs = None # str + self.vertical_crs = None # unicode self.vertical_resolution = None # grids.GridTileResolutionType self.zcoords = None # grids.VerticalCoordinateList @@ -170,7 +170,7 @@ def __init__(self): """ super(GridTileResolutionType, self).__init__() - self.description = None # str + self.description = None # unicode self.properties = [] # grids.GridProperty @@ -186,7 +186,7 @@ def __init__(self): """ super(SimpleGridGeometry, self).__init__() - self.dim_order = None # str + self.dim_order = None # unicode self.is_mesh = None # bool self.num_dims = None # int self.xcoords = None # grids.CoordinateList @@ -206,9 +206,9 @@ def __init__(self): """ super(VerticalCoordinateList, self).__init__() - self.form = None # str + self.form = None # unicode self.properties = [] # grids.GridProperty - self.type = None # str + self.type = None # unicode class ArcTypeEnum(object): diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_quality_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_quality_package.py index 2a7deb1..9b93d8d 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_quality_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_quality_package.py @@ -50,14 +50,14 @@ def __init__(self): super(Evaluation, self).__init__() self.date = None # datetime.datetime - self.description = None # str + self.description = None # unicode self.did_pass = None # bool - self.explanation = None # str - self.specification = None # str - self.specification_hyperlink = None # str - self.title = None # str - self.type = None # str - self.type_hyperlink = None # str + self.explanation = None # unicode + self.specification = None # unicode + self.specification_hyperlink = None # unicode + self.title = None # unicode + self.type = None # unicode + self.type_hyperlink = None # unicode class Measure(object): @@ -72,9 +72,9 @@ def __init__(self): """ super(Measure, self).__init__() - self.description = None # str - self.identification = None # str - self.name = None # str + self.description = None # unicode + self.identification = None # unicode + self.name = None # unicode class Report(object): diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_shared_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_shared_package.py index b5bcbe4..07315ba 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_shared_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_shared_package.py @@ -34,7 +34,7 @@ def __init__(self): """ super(Calendar, self).__init__() - self.description = None # str + self.description = None # unicode self.length = None # int self.range = None # shared.DateRange @@ -53,9 +53,9 @@ def __init__(self): self.author = None # shared.ResponsibleParty self.date = None # datetime.datetime - self.description = None # str + self.description = None # unicode self.details = [] # shared.ChangeProperty - self.name = None # str + self.name = None # unicode self.type = None # shared.ChangePropertyType @@ -71,16 +71,16 @@ def __init__(self): """ super(Citation, self).__init__() - self.alternative_title = None # str - self.collective_title = None # str + self.alternative_title = None # unicode + self.collective_title = None # unicode self.date = None # datetime.datetime - self.date_type = None # str - self.location = None # str - self.organisation = None # str + self.date_type = None # unicode + self.location = None # unicode + self.organisation = None # unicode self.reference = None # shared.DocReference - self.role = None # str - self.title = None # str - self.type = None # str + self.role = None # unicode + self.title = None # unicode + self.type = None # unicode class Compiler(object): @@ -95,12 +95,12 @@ def __init__(self): """ super(Compiler, self).__init__() - self.environment_variables = None # str - self.language = None # str - self.name = None # str - self.options = None # str + self.environment_variables = None # unicode + self.language = None # unicode + self.name = None # unicode + self.options = None # unicode self.type = None # shared.CompilerType - self.version = None # str + self.version = None # unicode class DataSource(object): @@ -134,7 +134,7 @@ def __init__(self): """ super(DateRange, self).__init__() - self.duration = None # str + self.duration = None # unicode class DocGenealogy(object): @@ -166,26 +166,26 @@ def __init__(self): self.author = None # shared.ResponsibleParty self.create_date = None # datetime.datetime - self.drs_keys = [] # str - self.drs_path = None # str - self.encodings = [] # str + self.drs_keys = [] # unicode + self.drs_path = None # unicode self.external_ids = [] # shared.StandardName self.genealogy = None # shared.DocGenealogy self.id = None # uuid.UUID - self.institute = None # str - self.language = None # str - self.metadata_id = None # str - self.metadata_version = None # str - self.project = None # str - self.sort_key = None # str - self.source = None # str - self.source_key = None # str + self.institute = None # unicode + self.language = None # unicode + self.metadata_id = None # unicode + self.metadata_version = None # unicode + self.project = None # unicode + self.sort_key = None # unicode + self.source = None # unicode + self.source_key = None # unicode self.status = None # shared.DocStatusType - self.type = None # str - self.type_display_name = None # str - self.type_sort_key = None # str + self.type = None # unicode + self.type_display_name = None # unicode + self.type_sort_key = None # unicode self.update_date = None # datetime.datetime self.version = None # int + self.source = unicode("scripts") class DocReference(object): @@ -201,12 +201,12 @@ def __init__(self): super(DocReference, self).__init__() self.changes = [] # shared.Change - self.description = None # str - self.external_id = None # str + self.description = None # unicode + self.external_id = None # unicode self.id = None # uuid.UUID - self.name = None # str - self.type = None # str - self.url = None # str + self.name = None # unicode + self.type = None # unicode + self.url = None # unicode self.version = None # int @@ -238,10 +238,10 @@ def __init__(self): """ super(License, self).__init__() - self.contact = None # str - self.description = None # str + self.contact = None # unicode + self.description = None # unicode self.is_unrestricted = None # bool - self.name = None # str + self.name = None # unicode class Machine(object): @@ -257,15 +257,15 @@ def __init__(self): super(Machine, self).__init__() self.cores_per_processor = None # int - self.description = None # str + self.description = None # unicode self.interconnect = None # shared.InterconnectType - self.libraries = [] # str - self.location = None # str + self.libraries = [] # unicode + self.location = None # unicode self.maximum_processors = None # int - self.name = None # str + self.name = None # unicode self.operating_system = None # shared.OperatingSystemType self.processor_type = None # shared.ProcessorType - self.system = None # str + self.system = None # unicode self.type = None # shared.MachineType self.vendor = None # shared.MachineVendorType @@ -299,10 +299,10 @@ def __init__(self): super(Platform, self).__init__() self.contacts = [] # shared.ResponsibleParty - self.description = None # str - self.long_name = None # str + self.description = None # unicode + self.long_name = None # unicode self.meta = DocMetaInfo() # shared.DocMetaInfo - self.short_name = None # str + self.short_name = None # unicode self.units = [] # shared.MachineCompilerUnit @@ -318,8 +318,8 @@ def __init__(self): """ super(Property, self).__init__() - self.name = None # str - self.value = None # str + self.name = None # unicode + self.value = None # unicode class Relationship(object): @@ -336,7 +336,7 @@ def __init__(self): """ super(Relationship, self).__init__() - self.description = None # str + self.description = None # unicode self.direction = None # shared.DocRelationshipDirectionType @@ -352,13 +352,13 @@ def __init__(self): """ super(ResponsibleParty, self).__init__() - self.abbreviation = None # str - self.address = None # str - self.email = None # str - self.individual_name = None # str - self.organisation_name = None # str - self.role = None # str - self.url = None # str + self.abbreviation = None # unicode + self.address = None # unicode + self.email = None # unicode + self.individual_name = None # unicode + self.organisation_name = None # unicode + self.role = None # unicode + self.url = None # unicode class Standard(object): @@ -373,9 +373,9 @@ def __init__(self): """ super(Standard, self).__init__() - self.description = None # str - self.name = None # str - self.version = None # str + self.description = None # unicode + self.name = None # unicode + self.version = None # unicode class StandardName(object): @@ -392,7 +392,7 @@ def __init__(self): self.is_open = None # bool self.standards = [] # shared.Standard - self.value = None # str + self.value = None # unicode class ChangeProperty(Property): @@ -407,8 +407,8 @@ def __init__(self): """ super(ChangeProperty, self).__init__() - self.description = None # str - self.id = None # str + self.description = None # unicode + self.id = None # unicode class ClosedDateRange(DateRange): diff --git a/pyesdoc/ontologies/cim/v1/typeset_for_software_package.py b/pyesdoc/ontologies/cim/v1/typeset_for_software_package.py index f5831bb..4478a9c 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_for_software_package.py +++ b/pyesdoc/ontologies/cim/v1/typeset_for_software_package.py @@ -34,27 +34,27 @@ def __init__(self): super(Component, self).__init__() self.citations = [] # shared.Citation - self.code_access = None # str + self.code_access = None # unicode self.composition = None # software.Composition self.coupling_framework = None # software.CouplingFrameworkType self.dependencies = [] # software.EntryPoint self.deployments = [] # software.Deployment - self.description = None # str - self.funding_sources = [] # str + self.description = None # unicode + self.funding_sources = [] # unicode self.grid = None # grids.GridSpec self.is_embedded = None # bool self.language = None # software.ComponentLanguage self.license = None # shared.License - self.long_name = None # str - self.online_resource = None # str + self.long_name = None # unicode + self.online_resource = None # unicode self.parent = None # software.Component - self.previous_version = None # str + self.previous_version = None # unicode self.properties = [] # software.ComponentProperty self.release_date = None # datetime.datetime self.responsible_parties = [] # shared.ResponsibleParty - self.short_name = None # str + self.short_name = None # unicode self.sub_components = [] # software.Component - self.version = None # str + self.version = None # unicode class ComponentLanguage(object): @@ -69,7 +69,7 @@ def __init__(self): """ super(ComponentLanguage, self).__init__() - self.name = None # str + self.name = None # unicode self.properties = [] # software.ComponentLanguageProperty @@ -100,16 +100,16 @@ def __init__(self): super(ComponentProperty, self).__init__() self.citations = [] # shared.Citation - self.description = None # str - self.grid = None # str + self.description = None # unicode + self.grid = None # unicode self.intent = None # software.ComponentPropertyIntentType self.is_represented = None # bool - self.long_name = None # str - self.short_name = None # str - self.standard_names = [] # str + self.long_name = None # unicode + self.short_name = None # unicode + self.standard_names = [] # unicode self.sub_properties = [] # software.ComponentProperty self.units = None # shared.UnitType - self.values = [] # str + self.values = [] # unicode class Composition(object): @@ -124,8 +124,8 @@ def __init__(self): """ super(Composition, self).__init__() - self.couplings = [] # str - self.description = None # str + self.couplings = [] # unicode + self.description = None # unicode class Connection(object): @@ -140,14 +140,14 @@ def __init__(self): """ super(Connection, self).__init__() - self.description = None # str + self.description = None # unicode self.priming = None # shared.DataSource self.priming_reference = None # shared.DocReference self.properties = [] # software.ConnectionProperty self.sources = [] # software.ConnectionEndpoint self.spatial_regridding = [] # software.SpatialRegridding self.target = None # software.ConnectionEndpoint - self.time_lag = None # str + self.time_lag = None # unicode self.time_profile = None # software.Timing self.time_transformation = None # software.TimeTransformation self.transformers = [] # software.ProcessorComponent @@ -169,7 +169,7 @@ def __init__(self): self.data_source = None # shared.DataSource self.data_source_reference = None # shared.DocReference - self.instance_id = None # str + self.instance_id = None # unicode self.properties = [] # software.ConnectionProperty @@ -200,7 +200,7 @@ def __init__(self): super(Coupling, self).__init__() self.connections = [] # software.Connection - self.description = None # str + self.description = None # unicode self.is_fully_specified = None # bool self.priming = None # shared.DataSource self.priming_reference = None # shared.DocReference @@ -231,7 +231,7 @@ def __init__(self): self.data_source = None # shared.DataSource self.data_source_reference = None # shared.DocReference - self.instance_id = None # str + self.instance_id = None # unicode self.properties = [] # software.CouplingProperty @@ -262,9 +262,9 @@ def __init__(self): super(Deployment, self).__init__() self.deployment_date = None # datetime.datetime - self.description = None # str - self.executable_arguments = [] # str - self.executable_name = None # str + self.description = None # unicode + self.executable_arguments = [] # unicode + self.executable_name = None # unicode self.parallelisation = None # software.Parallelisation self.platform = None # shared.Platform self.platform_reference = None # shared.DocReference @@ -282,7 +282,7 @@ def __init__(self): """ super(EntryPoint, self).__init__() - self.name = None # str + self.name = None # unicode class Parallelisation(object): @@ -365,7 +365,7 @@ def __init__(self): self.file = None # data.DataObject self.file_reference = None # shared.DocReference - self.name = None # str + self.name = None # unicode class TimeLag(object): @@ -396,7 +396,7 @@ def __init__(self): """ super(TimeTransformation, self).__init__() - self.description = None # str + self.description = None # unicode self.mapping_type = None # software.TimeMappingType diff --git a/pyesdoc/ontologies/cim/v1/typeset_meta.py b/pyesdoc/ontologies/cim/v1/typeset_meta.py index 9d55d6e..f418ab6 100644 --- a/pyesdoc/ontologies/cim/v1/typeset_meta.py +++ b/pyesdoc/ontologies/cim/v1/typeset_meta.py @@ -134,9 +134,9 @@ # Set type info (name, type, is_required, is_iterative). activity.Activity.type_info = ( - ('funding_sources', str, False, True), - ('projects', str, False, True), - ('rationales', str, False, True), + ('funding_sources', unicode, False, True), + ('projects', unicode, False, True), + ('rationales', unicode, False, True), ('responsible_parties', shared.ResponsibleParty, False, True), ) @@ -144,22 +144,22 @@ ) activity.Conformance.type_info = ( - ('description', str, False, False), - ('frequency', str, False, False), + ('description', unicode, False, False), + ('frequency', unicode, False, False), ('is_conformant', bool, True, False), ('requirements', activity.NumericalRequirement, False, True), ('requirements_references', shared.DocReference, False, True), ('sources', shared.DataSource, False, True), ('sources_references', shared.DocReference, False, True), - ('type', str, False, False), + ('type', unicode, False, False), ) activity.DownscalingSimulation.type_info = ( ('calendar', shared.Calendar, True, False), ('downscaled_from', shared.DataSource, True, False), ('downscaled_from_reference', shared.DocReference, True, False), - ('downscaling_id', str, False, False), - ('downscaling_type', str, False, False), + ('downscaling_id', unicode, False, False), + ('downscaling_type', unicode, False, False), ('inputs', software.Coupling, False, True), ('meta', shared.DocMetaInfo, True, False), ('output_references', shared.DocReference, False, True), @@ -171,7 +171,7 @@ ('meta', shared.DocMetaInfo, True, False), ('outputs', shared.DataSource, False, True), ('outputs_references', shared.DocReference, False, True), - ('types', str, True, True), + ('types', unicode, True, True), ) activity.EnsembleMember.type_info = ( @@ -183,17 +183,17 @@ ) activity.Experiment.type_info = ( - ('generates', str, False, True), + ('generates', unicode, False, True), ('measurement_campaigns', activity.MeasurementCampaign, False, True), ('requires', activity.NumericalActivity, False, True), ('requires_references', shared.DocReference, False, True), - ('supports', str, False, True), + ('supports', unicode, False, True), ('supports_references', shared.DocReference, False, True), ) activity.ExperimentRelationship.type_info = ( ('target', activity.ExperimentRelationshipTarget, True, False), - ('type', str, True, False), + ('type', unicode, True, False), ) activity.ExperimentRelationshipTarget.type_info = ( @@ -212,37 +212,37 @@ ) activity.NumericalActivity.type_info = ( - ('description', str, False, False), - ('long_name', str, False, False), - ('short_name', str, True, False), + ('description', unicode, False, False), + ('long_name', unicode, False, False), + ('short_name', unicode, True, False), ('supports', activity.Experiment, False, True), ('supports_references', shared.DocReference, False, True), ) activity.NumericalExperiment.type_info = ( - ('description', str, False, False), - ('experiment_id', str, False, False), - ('long_name', str, False, False), + ('description', unicode, False, False), + ('experiment_id', unicode, False, False), + ('long_name', unicode, False, False), ('meta', shared.DocMetaInfo, True, False), ('requirements', activity.NumericalRequirement, False, True), - ('short_name', str, True, False), + ('short_name', unicode, True, False), ) activity.NumericalRequirement.type_info = ( - ('description', str, False, False), - ('id', str, False, False), - ('name', str, True, False), + ('description', unicode, False, False), + ('id', unicode, False, False), + ('name', unicode, True, False), ('options', activity.NumericalRequirementOption, False, True), - ('requirement_type', str, True, False), + ('requirement_type', unicode, True, False), ('source', shared.DataSource, False, False), ('source_reference', shared.DocReference, False, False), ) activity.NumericalRequirementOption.type_info = ( - ('description', str, False, False), - ('id', str, False, False), - ('name', str, True, False), - ('relationship', str, False, False), + ('description', unicode, False, False), + ('id', unicode, False, False), + ('name', unicode, True, False), + ('relationship', unicode, False, False), ('sub_options', activity.NumericalRequirementOption, False, True), ) @@ -253,7 +253,7 @@ ) activity.Simulation.type_info = ( - ('authors', str, False, False), + ('authors', unicode, False, False), ('calendar', shared.Calendar, True, False), ('conformances', activity.Conformance, False, True), ('control_simulation', activity.Simulation, False, False), @@ -264,7 +264,7 @@ ('outputs', data.DataObject, False, True), ('restart_references', shared.DocReference, False, True), ('restarts', data.DataObject, False, True), - ('simulation_id', str, False, False), + ('simulation_id', unicode, False, False), ('spinup_date_range', shared.ClosedDateRange, False, False), ('spinup_simulation', activity.Simulation, False, False), ('spinup_simulation_reference', shared.DocReference, False, False), @@ -279,12 +279,12 @@ activity.SimulationRelationship.type_info = ( ('target', activity.SimulationRelationshipTarget, True, False), - ('type', str, True, False), + ('type', unicode, True, False), ) activity.SimulationRelationshipTarget.type_info = ( ('reference', shared.DocReference, False, False), - ('target', str, False, False), + ('target', unicode, False, False), ) activity.SimulationRun.type_info = ( @@ -296,19 +296,19 @@ activity.SpatioTemporalConstraint.type_info = ( ('date_range', shared.DateRange, False, False), - ('spatial_resolution', str, False, False), + ('spatial_resolution', unicode, False, False), ) data.DataContent.type_info = ( - ('aggregation', str, False, False), - ('frequency', str, False, False), + ('aggregation', unicode, False, False), + ('frequency', unicode, False, False), ('topic', data.DataTopic, True, False), ) data.DataDistribution.type_info = ( - ('access', str, False, False), - ('fee', str, False, False), - ('format', str, False, False), + ('access', unicode, False, False), + ('fee', unicode, False, False), + ('format', unicode, False, False), ('responsible_party', shared.ResponsibleParty, False, False), ) @@ -333,109 +333,109 @@ data.DataExtentTimeInterval.type_info = ( ('factor', int, False, False), ('radix', int, False, False), - ('unit', str, False, False), + ('unit', unicode, False, False), ) data.DataHierarchyLevel.type_info = ( ('is_open', bool, False, False), - ('name', str, False, False), - ('value', str, False, False), + ('name', unicode, False, False), + ('value', unicode, False, False), ) data.DataObject.type_info = ( - ('acronym', str, False, False), + ('acronym', unicode, False, False), ('child_object', data.DataObject, False, True), ('citations', shared.Citation, False, True), ('content', data.DataContent, False, True), - ('data_status', str, False, False), - ('description', str, False, False), + ('data_status', unicode, False, False), + ('description', unicode, False, False), ('distribution', data.DataDistribution, False, False), ('extent', data.DataExtent, False, False), - ('geometry_model', str, False, False), + ('geometry_model', unicode, False, False), ('hierarchy_level', data.DataHierarchyLevel, False, False), - ('keyword', str, False, False), + ('keyword', unicode, False, False), ('meta', shared.DocMetaInfo, True, False), ('parent_object', data.DataObject, False, False), ('parent_object_reference', shared.DocReference, False, False), ('properties', data.DataProperty, False, True), - ('purpose', str, False, False), + ('purpose', unicode, False, False), ('restriction', data.DataRestriction, False, True), - ('source_simulation', str, False, False), + ('source_simulation', unicode, False, False), ('storage', data.DataStorage, False, True), ) data.DataProperty.type_info = ( - ('description', str, False, False), + ('description', unicode, False, False), ) data.DataRestriction.type_info = ( ('license', shared.License, False, False), - ('restriction', str, False, False), - ('scope', str, False, False), + ('restriction', unicode, False, False), + ('scope', unicode, False, False), ) data.DataStorage.type_info = ( - ('format', str, False, False), - ('location', str, False, False), + ('format', unicode, False, False), + ('location', unicode, False, False), ('modification_date', datetime.datetime, False, False), ('size', int, False, False), ) data.DataStorageDb.type_info = ( - ('access_string', str, False, False), - ('name', str, False, False), - ('owner', str, False, False), - ('table', str, False, False), + ('access_string', unicode, False, False), + ('name', unicode, False, False), + ('owner', unicode, False, False), + ('table', unicode, False, False), ) data.DataStorageFile.type_info = ( - ('file_name', str, False, False), - ('file_system', str, False, False), - ('path', str, False, False), + ('file_name', unicode, False, False), + ('file_system', unicode, False, False), + ('path', unicode, False, False), ) data.DataStorageIp.type_info = ( - ('file_name', str, False, False), - ('host', str, False, False), - ('path', str, False, False), - ('protocol', str, False, False), + ('file_name', unicode, False, False), + ('host', unicode, False, False), + ('path', unicode, False, False), + ('protocol', unicode, False, False), ) data.DataTopic.type_info = ( - ('description', str, False, False), - ('name', str, False, False), - ('unit', str, False, False), + ('description', unicode, False, False), + ('name', unicode, False, False), + ('unit', unicode, False, False), ) grids.CoordinateList.type_info = ( ('has_constant_offset', bool, False, False), ('length', int, False, False), - ('uom', str, False, False), + ('uom', unicode, False, False), ) grids.GridExtent.type_info = ( - ('maximum_latitude', str, True, False), - ('maximum_longitude', str, True, False), - ('minimum_latitude', str, True, False), - ('minimum_longitude', str, True, False), - ('units', str, False, False), + ('maximum_latitude', unicode, True, False), + ('maximum_longitude', unicode, True, False), + ('minimum_latitude', unicode, True, False), + ('minimum_longitude', unicode, True, False), + ('units', unicode, False, False), ) grids.GridMosaic.type_info = ( ('citations', shared.Citation, False, True), - ('description', str, False, False), + ('description', unicode, False, False), ('extent', grids.GridExtent, False, False), ('has_congruent_tiles', bool, False, False), - ('id', str, True, False), + ('id', unicode, True, False), ('is_leaf', bool, True, False), - ('long_name', str, False, False), - ('mnemonic', str, False, False), + ('long_name', unicode, False, False), + ('mnemonic', unicode, False, False), ('mosaic_count', int, False, False), ('mosaics', grids.GridMosaic, False, True), - ('short_name', str, True, False), + ('short_name', unicode, True, False), ('tile_count', int, False, False), ('tiles', grids.GridTile, False, True), - ('type', str, True, False), + ('type', unicode, True, False), ) grids.GridProperty.type_info = ( @@ -448,43 +448,43 @@ ) grids.GridTile.type_info = ( - ('area', str, False, False), - ('cell_array', str, False, False), - ('cell_ref_array', str, False, False), - ('coord_file', str, False, False), - ('coordinate_pole', str, False, False), - ('description', str, False, False), - ('discretization_type', str, False, False), + ('area', unicode, False, False), + ('cell_array', unicode, False, False), + ('cell_ref_array', unicode, False, False), + ('coord_file', unicode, False, False), + ('coordinate_pole', unicode, False, False), + ('description', unicode, False, False), + ('discretization_type', unicode, False, False), ('extent', grids.GridExtent, False, False), - ('geometry_type', str, False, False), - ('grid_north_pole', str, False, False), - ('horizontal_crs', str, False, False), + ('geometry_type', unicode, False, False), + ('grid_north_pole', unicode, False, False), + ('horizontal_crs', unicode, False, False), ('horizontal_resolution', grids.GridTileResolutionType, False, False), - ('id', str, False, False), + ('id', unicode, False, False), ('is_conformal', bool, False, False), ('is_regular', bool, False, False), ('is_terrain_following', bool, False, False), ('is_uniform', bool, False, False), - ('long_name', str, False, False), - ('mnemonic', str, False, False), + ('long_name', unicode, False, False), + ('mnemonic', unicode, False, False), ('nx', int, False, False), ('ny', int, False, False), ('nz', int, False, False), - ('refinement_scheme', str, False, False), - ('short_name', str, False, False), + ('refinement_scheme', unicode, False, False), + ('short_name', unicode, False, False), ('simple_grid_geom', grids.SimpleGridGeometry, False, False), - ('vertical_crs', str, False, False), + ('vertical_crs', unicode, False, False), ('vertical_resolution', grids.GridTileResolutionType, False, False), ('zcoords', grids.VerticalCoordinateList, False, False), ) grids.GridTileResolutionType.type_info = ( - ('description', str, False, False), + ('description', unicode, False, False), ('properties', grids.GridProperty, False, True), ) grids.SimpleGridGeometry.type_info = ( - ('dim_order', str, False, False), + ('dim_order', unicode, False, False), ('is_mesh', bool, False, False), ('num_dims', int, True, False), ('xcoords', grids.CoordinateList, True, False), @@ -493,9 +493,9 @@ ) grids.VerticalCoordinateList.type_info = ( - ('form', str, False, False), + ('form', unicode, False, False), ('properties', grids.GridProperty, False, True), - ('type', str, False, False), + ('type', unicode, False, False), ) misc.DocumentSet.type_info = ( @@ -523,20 +523,20 @@ quality.Evaluation.type_info = ( ('date', datetime.datetime, False, False), - ('description', str, False, False), + ('description', unicode, False, False), ('did_pass', bool, False, False), - ('explanation', str, False, False), - ('specification', str, False, False), - ('specification_hyperlink', str, False, False), - ('title', str, False, False), - ('type', str, False, False), - ('type_hyperlink', str, False, False), + ('explanation', unicode, False, False), + ('specification', unicode, False, False), + ('specification_hyperlink', unicode, False, False), + ('title', unicode, False, False), + ('type', unicode, False, False), + ('type_hyperlink', unicode, False, False), ) quality.Measure.type_info = ( - ('description', str, False, False), - ('identification', str, False, False), - ('name', str, False, False), + ('description', unicode, False, False), + ('identification', unicode, False, False), + ('name', unicode, False, False), ) quality.Report.type_info = ( @@ -547,7 +547,7 @@ ) shared.Calendar.type_info = ( - ('description', str, False, False), + ('description', unicode, False, False), ('length', int, False, False), ('range', shared.DateRange, False, False), ) @@ -555,28 +555,28 @@ shared.Change.type_info = ( ('author', shared.ResponsibleParty, False, False), ('date', datetime.datetime, False, False), - ('description', str, False, False), + ('description', unicode, False, False), ('details', shared.ChangeProperty, True, True), - ('name', str, False, False), - ('type', str, False, False), + ('name', unicode, False, False), + ('type', unicode, False, False), ) shared.ChangeProperty.type_info = ( - ('description', str, False, False), - ('id', str, False, False), + ('description', unicode, False, False), + ('id', unicode, False, False), ) shared.Citation.type_info = ( - ('alternative_title', str, False, False), - ('collective_title', str, False, False), + ('alternative_title', unicode, False, False), + ('collective_title', unicode, False, False), ('date', datetime.datetime, False, False), - ('date_type', str, False, False), - ('location', str, False, False), - ('organisation', str, False, False), + ('date_type', unicode, False, False), + ('location', unicode, False, False), + ('organisation', unicode, False, False), ('reference', shared.DocReference, False, False), - ('role', str, False, False), - ('title', str, False, False), - ('type', str, False, False), + ('role', unicode, False, False), + ('title', unicode, False, False), + ('type', unicode, False, False), ) shared.ClosedDateRange.type_info = ( @@ -585,23 +585,23 @@ ) shared.Compiler.type_info = ( - ('environment_variables', str, False, False), - ('language', str, False, False), - ('name', str, True, False), - ('options', str, False, False), - ('type', str, False, False), - ('version', str, True, False), + ('environment_variables', unicode, False, False), + ('language', unicode, False, False), + ('name', unicode, True, False), + ('options', unicode, False, False), + ('type', unicode, False, False), + ('version', unicode, True, False), ) shared.Daily360.type_info = ( ) shared.DataSource.type_info = ( - ('purpose', str, False, False), + ('purpose', unicode, False, False), ) shared.DateRange.type_info = ( - ('duration', str, False, False), + ('duration', unicode, False, False), ) shared.DocGenealogy.type_info = ( @@ -611,69 +611,68 @@ shared.DocMetaInfo.type_info = ( ('author', shared.ResponsibleParty, False, False), ('create_date', datetime.datetime, True, False), - ('drs_keys', str, False, True), - ('drs_path', str, False, False), - ('encodings', str, False, True), + ('drs_keys', unicode, False, True), + ('drs_path', unicode, False, False), ('external_ids', shared.StandardName, False, True), ('genealogy', shared.DocGenealogy, False, False), ('id', uuid.UUID, True, False), - ('institute', str, False, False), - ('language', str, True, False), - ('metadata_id', str, False, False), - ('metadata_version', str, False, False), - ('project', str, True, False), - ('sort_key', str, False, False), - ('source', str, True, False), - ('source_key', str, False, False), - ('status', str, False, False), - ('type', str, True, False), - ('type_display_name', str, False, False), - ('type_sort_key', str, False, False), + ('institute', unicode, False, False), + ('language', unicode, True, False), + ('metadata_id', unicode, False, False), + ('metadata_version', unicode, False, False), + ('project', unicode, True, False), + ('sort_key', unicode, False, False), + ('source', unicode, True, False), + ('source_key', unicode, False, False), + ('status', unicode, False, False), + ('type', unicode, True, False), + ('type_display_name', unicode, False, False), + ('type_sort_key', unicode, False, False), ('update_date', datetime.datetime, True, False), ('version', int, True, False), ) shared.DocReference.type_info = ( ('changes', shared.Change, False, True), - ('description', str, False, False), - ('external_id', str, False, False), + ('description', unicode, False, False), + ('external_id', unicode, False, False), ('id', uuid.UUID, False, False), - ('name', str, False, False), - ('type', str, False, False), - ('url', str, False, False), + ('name', unicode, False, False), + ('type', unicode, False, False), + ('url', unicode, False, False), ('version', int, False, False), ) shared.DocRelationship.type_info = ( ('target', shared.DocRelationshipTarget, True, False), - ('type', str, True, False), + ('type', unicode, True, False), ) shared.DocRelationshipTarget.type_info = ( - ('document', str, False, False), + ('document', unicode, False, False), ('reference', shared.DocReference, False, False), ) shared.License.type_info = ( - ('contact', str, False, False), - ('description', str, False, False), + ('contact', unicode, False, False), + ('description', unicode, False, False), ('is_unrestricted', bool, False, False), - ('name', str, False, False), + ('name', unicode, False, False), ) shared.Machine.type_info = ( ('cores_per_processor', int, False, False), - ('description', str, False, False), - ('interconnect', str, False, False), - ('libraries', str, False, True), - ('location', str, False, False), + ('description', unicode, False, False), + ('interconnect', unicode, False, False), + ('libraries', unicode, False, True), + ('location', unicode, False, False), ('maximum_processors', int, False, False), - ('name', str, True, False), - ('operating_system', str, False, False), - ('processor_type', str, False, False), - ('system', str, False, False), - ('type', str, False, False), - ('vendor', str, False, False), + ('name', unicode, True, False), + ('operating_system', unicode, False, False), + ('processor_type', unicode, False, False), + ('system', unicode, False, False), + ('type', unicode, False, False), + ('vendor', unicode, False, False), ) shared.MachineCompilerUnit.type_info = ( @@ -691,75 +690,75 @@ shared.Platform.type_info = ( ('contacts', shared.ResponsibleParty, False, True), - ('description', str, False, False), - ('long_name', str, False, False), + ('description', unicode, False, False), + ('long_name', unicode, False, False), ('meta', shared.DocMetaInfo, True, False), - ('short_name', str, True, False), + ('short_name', unicode, True, False), ('units', shared.MachineCompilerUnit, True, True), ) shared.Property.type_info = ( - ('name', str, False, False), - ('value', str, False, False), + ('name', unicode, False, False), + ('value', unicode, False, False), ) shared.RealCalendar.type_info = ( ) shared.Relationship.type_info = ( - ('description', str, False, False), - ('direction', str, True, False), + ('description', unicode, False, False), + ('direction', unicode, True, False), ) shared.ResponsibleParty.type_info = ( - ('abbreviation', str, False, False), - ('address', str, False, False), - ('email', str, False, False), - ('individual_name', str, False, False), - ('organisation_name', str, False, False), - ('role', str, False, False), - ('url', str, False, False), + ('abbreviation', unicode, False, False), + ('address', unicode, False, False), + ('email', unicode, False, False), + ('individual_name', unicode, False, False), + ('organisation_name', unicode, False, False), + ('role', unicode, False, False), + ('url', unicode, False, False), ) shared.Standard.type_info = ( - ('description', str, False, False), - ('name', str, True, False), - ('version', str, False, False), + ('description', unicode, False, False), + ('name', unicode, True, False), + ('version', unicode, False, False), ) shared.StandardName.type_info = ( ('is_open', bool, True, False), ('standards', shared.Standard, False, True), - ('value', str, True, False), + ('value', unicode, True, False), ) software.Component.type_info = ( ('citations', shared.Citation, False, True), - ('code_access', str, False, False), + ('code_access', unicode, False, False), ('composition', software.Composition, False, False), - ('coupling_framework', str, False, False), + ('coupling_framework', unicode, False, False), ('dependencies', software.EntryPoint, False, True), ('deployments', software.Deployment, False, True), - ('description', str, False, False), - ('funding_sources', str, False, True), + ('description', unicode, False, False), + ('funding_sources', unicode, False, True), ('grid', grids.GridSpec, False, False), ('is_embedded', bool, False, False), ('language', software.ComponentLanguage, False, False), ('license', shared.License, False, False), - ('long_name', str, False, False), - ('online_resource', str, False, False), + ('long_name', unicode, False, False), + ('online_resource', unicode, False, False), ('parent', software.Component, False, False), - ('previous_version', str, False, False), + ('previous_version', unicode, False, False), ('properties', software.ComponentProperty, False, True), ('release_date', datetime.datetime, False, False), ('responsible_parties', shared.ResponsibleParty, False, True), - ('short_name', str, True, False), + ('short_name', unicode, True, False), ('sub_components', software.Component, False, True), - ('version', str, False, False), + ('version', unicode, False, False), ) software.ComponentLanguage.type_info = ( - ('name', str, True, False), + ('name', unicode, True, False), ('properties', software.ComponentLanguageProperty, False, True), ) @@ -768,43 +767,43 @@ software.ComponentProperty.type_info = ( ('citations', shared.Citation, False, True), - ('description', str, False, False), - ('grid', str, False, False), - ('intent', str, False, False), + ('description', unicode, False, False), + ('grid', unicode, False, False), + ('intent', unicode, False, False), ('is_represented', bool, True, False), - ('long_name', str, False, False), - ('short_name', str, True, False), - ('standard_names', str, False, True), + ('long_name', unicode, False, False), + ('short_name', unicode, True, False), + ('standard_names', unicode, False, True), ('sub_properties', software.ComponentProperty, False, True), - ('units', str, False, False), - ('values', str, False, True), + ('units', unicode, False, False), + ('values', unicode, False, True), ) software.Composition.type_info = ( - ('couplings', str, False, True), - ('description', str, False, False), + ('couplings', unicode, False, True), + ('description', unicode, False, False), ) software.Connection.type_info = ( - ('description', str, False, False), + ('description', unicode, False, False), ('priming', shared.DataSource, False, False), ('priming_reference', shared.DocReference, False, False), ('properties', software.ConnectionProperty, False, True), ('sources', software.ConnectionEndpoint, False, True), ('spatial_regridding', software.SpatialRegridding, False, True), ('target', software.ConnectionEndpoint, False, False), - ('time_lag', str, False, False), + ('time_lag', unicode, False, False), ('time_profile', software.Timing, False, False), ('time_transformation', software.TimeTransformation, False, False), ('transformers', software.ProcessorComponent, False, True), ('transformers_references', shared.DocReference, False, True), - ('type', str, False, False), + ('type', unicode, False, False), ) software.ConnectionEndpoint.type_info = ( ('data_source', shared.DataSource, False, False), ('data_source_reference', shared.DocReference, False, False), - ('instance_id', str, False, False), + ('instance_id', unicode, False, False), ('properties', software.ConnectionProperty, False, True), ) @@ -813,12 +812,12 @@ software.Coupling.type_info = ( ('connections', software.Connection, False, True), - ('description', str, False, False), + ('description', unicode, False, False), ('is_fully_specified', bool, True, False), ('priming', shared.DataSource, False, False), ('priming_reference', shared.DocReference, False, False), ('properties', software.CouplingProperty, False, True), - ('purpose', str, True, False), + ('purpose', unicode, True, False), ('sources', software.CouplingEndpoint, True, True), ('spatial_regriddings', software.SpatialRegridding, False, True), ('target', software.CouplingEndpoint, True, False), @@ -827,13 +826,13 @@ ('time_transformation', software.TimeTransformation, False, False), ('transformers', software.ProcessorComponent, False, True), ('transformers_references', shared.DocReference, False, True), - ('type', str, False, False), + ('type', unicode, False, False), ) software.CouplingEndpoint.type_info = ( ('data_source', shared.DataSource, False, False), ('data_source_reference', shared.DocReference, False, False), - ('instance_id', str, False, False), + ('instance_id', unicode, False, False), ('properties', software.CouplingProperty, False, True), ) @@ -842,24 +841,24 @@ software.Deployment.type_info = ( ('deployment_date', datetime.datetime, False, False), - ('description', str, False, False), - ('executable_arguments', str, False, True), - ('executable_name', str, False, False), + ('description', unicode, False, False), + ('executable_arguments', unicode, False, True), + ('executable_name', unicode, False, False), ('parallelisation', software.Parallelisation, False, False), ('platform', shared.Platform, False, False), ('platform_reference', shared.DocReference, False, False), ) software.EntryPoint.type_info = ( - ('name', str, False, False), + ('name', unicode, False, False), ) software.ModelComponent.type_info = ( ('activity', activity.Activity, False, False), ('meta', shared.DocMetaInfo, True, False), ('timing', software.Timing, False, False), - ('type', str, False, False), - ('types', str, True, True), + ('type', unicode, False, False), + ('types', unicode, True, True), ) software.Parallelisation.type_info = ( @@ -879,9 +878,9 @@ ) software.SpatialRegridding.type_info = ( - ('dimension', str, False, False), + ('dimension', unicode, False, False), ('properties', software.SpatialRegriddingProperty, False, True), - ('standard_method', str, False, False), + ('standard_method', unicode, False, False), ('user_method', software.SpatialRegriddingUserMethod, False, False), ) @@ -891,24 +890,24 @@ software.SpatialRegriddingUserMethod.type_info = ( ('file', data.DataObject, False, False), ('file_reference', shared.DocReference, False, False), - ('name', str, True, False), + ('name', unicode, True, False), ) software.StatisticalModelComponent.type_info = ( ('meta', shared.DocMetaInfo, True, False), ('timing', software.Timing, False, False), - ('type', str, False, False), - ('types', str, True, True), + ('type', unicode, False, False), + ('types', unicode, True, True), ) software.TimeLag.type_info = ( - ('units', str, False, False), + ('units', unicode, False, False), ('value', int, False, False), ) software.TimeTransformation.type_info = ( - ('description', str, False, False), - ('mapping_type', str, True, False), + ('description', unicode, False, False), + ('mapping_type', unicode, True, False), ) software.Timing.type_info = ( @@ -916,6 +915,6 @@ ('is_variable_rate', bool, False, False), ('rate', int, False, False), ('start', datetime.datetime, False, False), - ('units', str, False, False), + ('units', unicode, False, False), ) diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_activity_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_activity_package.py index b37a149..984a50f 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_activity_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_activity_package.py @@ -37,14 +37,14 @@ def __init__(self): """ super(Activity, self).__init__() - self.canonical_name = None # str - self.description = None # str + self.canonical_name = None # unicode + self.description = None # unicode self.duration = None # shared.TimePeriod - self.keywords = [] # str - self.long_name = None # str + self.keywords = [] # unicode + self.long_name = None # unicode self.meta = shared.Meta() # shared.Meta - self.name = None # str - self.rationale = None # str + self.name = None # unicode + self.rationale = None # unicode self.references = [] # shared.Citation self.responsible_parties = [] # shared.Responsibility @@ -63,7 +63,7 @@ def __init__(self): """ super(AxisMember, self).__init__() - self.description = None # str + self.description = None # unicode self.index = None # int self.value = None # float @@ -80,9 +80,9 @@ def __init__(self): """ super(EnsembleAxis, self).__init__() - self.extra_detail = None # str + self.extra_detail = None # unicode self.member = [] # activity.AxisMember - self.short_identifier = None # str + self.short_identifier = None # unicode self.target_requirement = None # activity.NumericalRequirement @@ -244,7 +244,7 @@ def __init__(self): super(Simulation, self).__init__() self.calendar = None # shared.Calendar - self.ensemble_identifier = None # str + self.ensemble_identifier = None # unicode self.parent_simulation = None # activity.ParentSimulation self.part_of_project = [] # activity.Project self.primary_ensemble = None # activity.Ensemble @@ -365,7 +365,7 @@ def __init__(self): """ super(ForcingConstraint, self).__init__() - self.additional_constraint = None # str + self.additional_constraint = None # unicode self.category = None # shared.VocabMember self.code = None # shared.VocabMember self.data_link = None # shared.OnlineResource diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_data_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_data_package.py index 153894b..82e131f 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_data_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_data_package.py @@ -34,10 +34,10 @@ def __init__(self): super(Dataset, self).__init__() self.availability = [] # shared.OnlineResource - self.description = None # str + self.description = None # unicode self.drs_datasets = [] # drs.DrsPublicationDataset self.meta = shared.Meta() # shared.Meta - self.name = None # str + self.name = None # unicode self.produced_by = None # activity.Simulation self.references = [] # shared.Citation self.related_to_dataset = [] # data.RelatedData @@ -72,8 +72,8 @@ def __init__(self): """ super(VariableCollection, self).__init__() - self.collection_name = None # str - self.variables = [] # str + self.collection_name = None # unicode + self.variables = [] # unicode class DataAssociationTypes(object): diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_drs_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_drs_package.py index ba87e37..73efc5a 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_drs_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_drs_package.py @@ -50,9 +50,9 @@ def __init__(self): """ super(DrsGeographicalIndicator, self).__init__() - self.bounding_box = None # str + self.bounding_box = None # unicode self.operator = None # drs.DrsGeographicalOperators - self.spatial_domain = None # str + self.spatial_domain = None # unicode class DrsPublicationDataset(object): @@ -67,12 +67,12 @@ def __init__(self): """ super(DrsPublicationDataset, self).__init__() - self.activity = None # str - self.experiment = None # str + self.activity = None # unicode + self.experiment = None # unicode self.frequency = None # drs.DrsFrequencyTypes - self.institute = None # str - self.model = None # str - self.product = None # str + self.institute = None # unicode + self.model = None # unicode + self.product = None # unicode self.realm = None # drs.DrsRealms self.version_number = None # int @@ -93,8 +93,8 @@ def __init__(self): """ super(DrsTemporalIdentifier, self).__init__() - self.end = None # str - self.start = None # str + self.end = None # unicode + self.start = None # unicode self.suffix = None # drs.DrsTimeSuffixes @@ -112,9 +112,9 @@ def __init__(self): self.ensemble_member = None # drs.DrsEnsembleIdentifier self.geographical_constraint = None # drs.DrsGeographicalIndicator - self.mip_table = None # str + self.mip_table = None # unicode self.temporal_constraint = None # drs.DrsTemporalIdentifier - self.variable_name = None # str + self.variable_name = None # unicode class DrsFrequencyTypes(object): diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_platform_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_platform_package.py index f088c5a..ff9e0b6 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_platform_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_platform_package.py @@ -35,7 +35,7 @@ def __init__(self): super(ComponentPerformance, self).__init__() self.component = None # software.SoftwareComponent - self.component_name = None # str + self.component_name = None # unicode self.cores_used = None # int self.nodes_used = None # int self.speed = None # float @@ -53,17 +53,17 @@ def __init__(self): """ super(ComputePool, self).__init__() - self.accelerator_type = None # str + self.accelerator_type = None # unicode self.accelerators_per_node = None # int self.compute_cores_per_node = None # int - self.cpu_type = None # str - self.description = None # str - self.interconnect = None # str + self.cpu_type = None # unicode + self.description = None # unicode + self.interconnect = None # unicode self.memory_per_node = None # platform.StorageVolume - self.model_number = None # str - self.name = None # str + self.model_number = None # unicode + self.name = None # unicode self.number_of_nodes = None # int - self.operating_system = None # str + self.operating_system = None # unicode class Partition(object): @@ -79,10 +79,10 @@ def __init__(self): super(Partition, self).__init__() self.compute_pools = [] # platform.ComputePool - self.description = None # str + self.description = None # unicode self.institution = None # shared.Party - self.model_number = None # str - self.name = None # str + self.model_number = None # unicode + self.name = None # unicode self.online_documentation = [] # shared.OnlineResource self.partition = [] # platform.Partition self.storage_pools = [] # platform.StoragePool @@ -104,14 +104,14 @@ def __init__(self): self.asypd = None # float self.chsy = None # float - self.compiler = None # str + self.compiler = None # unicode self.coupler_load = None # float self.io_load = None # float self.load_imbalance = None # float self.memory_bloat = None # float self.meta = shared.Meta() # shared.Meta self.model = None # software.Model - self.name = None # str + self.name = None # unicode self.platform = None # platform.Machine self.subcomponent_performance = None # platform.ComponentPerformance self.sypd = None # float @@ -130,8 +130,8 @@ def __init__(self): """ super(StoragePool, self).__init__() - self.description = None # str - self.name = None # str + self.description = None # unicode + self.name = None # unicode self.type = None # platform.StorageSystems self.vendor = None # shared.Party self.volume_available = None # platform.StorageVolume diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_science_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_science_package.py index 994f680..b61cc7b 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_science_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_science_package.py @@ -35,8 +35,8 @@ def __init__(self): super(Algorithm, self).__init__() self.diagnostic_variables = [] # data.VariableCollection - self.heading = None # str - self.implementation_overview = None # str + self.heading = None # unicode + self.implementation_overview = None # unicode self.prognostic_variables = [] # data.VariableCollection self.references = [] # shared.Citation @@ -54,7 +54,7 @@ def __init__(self): super(ConservationProperties, self).__init__() self.corrected_conserved_prognostic_variables = None# data.VariableCollection - self.correction_methodology = None # str + self.correction_methodology = None # unicode self.flux_correction_was_used = None # bool @@ -78,10 +78,10 @@ def __init__(self): self.maximum_vertical_level = None # float self.minimum_vertical_level = None # float self.northern_boundary = None # float - self.region_known_as = [] # str + self.region_known_as = [] # unicode self.southern_boundary = None # float self.western_boundary = None # float - self.z_units = None # str + self.z_units = None # unicode class GridSummary(object): @@ -117,11 +117,11 @@ def __init__(self): super(Process, self).__init__() self.algorithm_properties = [] # science.Algorithm - self.description = None # str + self.description = None # unicode self.detailed_properties = [] # science.ProcessDetail - self.implementation_overview = None # str - self.keywords = None # str - self.name = None # str + self.implementation_overview = None # unicode + self.keywords = None # unicode + self.name = None # unicode self.references = [] # shared.Reference self.time_step_in_process = None # float @@ -141,11 +141,11 @@ def __init__(self): """ super(ProcessDetail, self).__init__() - self.content = None # str - self.heading = None # str + self.content = None # unicode + self.heading = None # unicode self.properties = [] # shared.KeyFloat - self.selection = [] # str - self.vocabulary = None # str + self.selection = [] # unicode + self.vocabulary = None # unicode class Resolution(object): @@ -166,7 +166,7 @@ def __init__(self): self.equivalent_horizontal_resolution = None # float self.is_adaptive_grid = None # bool - self.name = None # str + self.name = None # unicode self.number_of_levels = [] # int self.number_of_xy_gridpoints = [] # int @@ -187,9 +187,9 @@ def __init__(self): self.extra_conservation_properties = None # science.ConservationProperties self.grid = None # science.GridSummary self.meta = shared.Meta() # shared.Meta - self.name = None # str - self.overview = None # str - self.realm = None # str + self.name = None # unicode + self.overview = None # unicode + self.realm = None # unicode self.references = [] # shared.Reference self.resolution = None # science.Resolution self.simulates = [] # science.Process @@ -208,7 +208,7 @@ def __init__(self): """ super(Tuning, self).__init__() - self.description = None # str + self.description = None # unicode self.global_mean_metrics_used = None # data.VariableCollection self.regional_metrics_used = None # data.VariableCollection self.trend_metrics_used = None # data.VariableCollection diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_shared_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_shared_package.py index 1f90e22..d070251 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_shared_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_shared_package.py @@ -35,9 +35,9 @@ def __init__(self): super(Calendar, self).__init__() self.cal_type = None # shared.CalendarTypes - self.description = None # str + self.description = None # unicode self.month_lengths = [] # int - self.name = None # str + self.name = None # unicode class Cimtext(object): @@ -53,7 +53,7 @@ def __init__(self): """ super(Cimtext, self).__init__() - self.content = None # str + self.content = None # unicode self.content_type = None # shared.TextCode @@ -69,11 +69,11 @@ def __init__(self): """ super(Citation, self).__init__() - self.abstract = None # str - self.citation_str = None # str - self.context = None # str - self.doi = None # str - self.title = None # str + self.abstract = None # unicode + self.citation_str = None # unicode + self.context = None # unicode + self.doi = None # unicode + self.title = None # unicode self.url = None # shared.OnlineResource @@ -92,7 +92,7 @@ def __init__(self): super(DateTime, self).__init__() self.offset = None # bool - self.value = None # str + self.value = None # unicode class DatetimeSet(object): @@ -126,7 +126,7 @@ def __init__(self): """ super(KeyFloat, self).__init__() - self.key = None # str + self.key = None # unicode self.value = None # float @@ -148,7 +148,7 @@ def __init__(self): self.document_version = None # int self.metadata_last_updated = None # datetime.datetime - self.uid = None # str + self.uid = None # unicode class NumberArray(object): @@ -163,7 +163,7 @@ def __init__(self): """ super(NumberArray, self).__init__() - self.values = None # str + self.values = None # unicode class OnlineResource(object): @@ -178,10 +178,10 @@ def __init__(self): """ super(OnlineResource, self).__init__() - self.description = None # str - self.linkage = None # str - self.name = None # str - self.protocol = None # str + self.description = None # unicode + self.linkage = None # unicode + self.name = None # unicode + self.protocol = None # unicode class Party(object): @@ -199,10 +199,10 @@ def __init__(self): """ super(Party, self).__init__() - self.address = None # str - self.email = None # str + self.address = None # unicode + self.email = None # unicode self.meta = MinimalMeta() # shared.MinimalMeta - self.name = None # str + self.name = None # unicode self.organisation = None # bool self.url = None # shared.OnlineResource @@ -219,7 +219,7 @@ def __init__(self): """ super(Pid, self).__init__() - self.id = None # str + self.id = None # unicode self.resolution_service = None # shared.OnlineResource @@ -255,9 +255,9 @@ def __init__(self): """ super(StandaloneDocument, self).__init__() - self.long_name = None # str + self.long_name = None # unicode self.meta = Meta() # shared.Meta - self.name = None # str + self.name = None # unicode self.references = [] # shared.Citation self.responsible_parties = [] # shared.Responsibility @@ -311,8 +311,8 @@ def __init__(self): """ super(VocabMember, self).__init__() - self.uri = None # str - self.value = None # str + self.uri = None # unicode + self.value = None # unicode self.vocab = None # shared.Citation @@ -328,7 +328,7 @@ def __init__(self): """ super(CimLink, self).__init__() - self.remote_type = None # str + self.remote_type = None # unicode class IrregularDateset(DatetimeSet): @@ -343,7 +343,7 @@ def __init__(self): """ super(IrregularDateset, self).__init__() - self.date_set = None # str + self.date_set = None # unicode class Meta(MinimalMeta): @@ -359,8 +359,8 @@ def __init__(self): super(Meta, self).__init__() self.metadata_author = None # shared.Party - self.metadata_completeness = None # str - self.metadata_quality = None # str + self.metadata_completeness = None # unicode + self.metadata_quality = None # unicode self.metadata_reviewer = None # shared.Party diff --git a/pyesdoc/ontologies/cim/v2/typeset_for_software_package.py b/pyesdoc/ontologies/cim/v2/typeset_for_software_package.py index 2e4eba4..1f715ea 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_for_software_package.py +++ b/pyesdoc/ontologies/cim/v2/typeset_for_software_package.py @@ -38,14 +38,14 @@ def __init__(self): """ super(ComponentBase, self).__init__() - self.description = None # str + self.description = None # unicode self.development_history = None # software.DevelopmentPath self.documentation = [] # shared.Citation - self.long_name = None # str - self.name = None # str + self.long_name = None # unicode + self.name = None # unicode self.release_date = None # datetime.datetime self.tuning_applied = None # science.Tuning - self.version = None # str + self.version = None # unicode class Composition(object): @@ -63,8 +63,8 @@ def __init__(self): """ super(Composition, self).__init__() - self.couplings = [] # str - self.description = None # str + self.couplings = [] # unicode + self.description = None # unicode class DevelopmentPath(object): @@ -79,11 +79,11 @@ def __init__(self): """ super(DevelopmentPath, self).__init__() - self.consortium_name = None # str + self.consortium_name = None # unicode self.creators = [] # shared.Responsibility self.developed_in_house = None # bool self.funding_sources = [] # shared.Responsibility - self.previous_version = None # str + self.previous_version = None # unicode class EntryPoint(object): @@ -103,7 +103,7 @@ def __init__(self): """ super(EntryPoint, self).__init__() - self.name = None # str + self.name = None # unicode class Gridspec(object): @@ -118,7 +118,7 @@ def __init__(self): """ super(Gridspec, self).__init__() - self.description = None # str + self.description = None # unicode class Variable(object): @@ -136,8 +136,8 @@ def __init__(self): """ super(Variable, self).__init__() - self.description = None # str - self.name = None # str + self.description = None # unicode + self.name = None # unicode self.prognostic = None # bool @@ -183,7 +183,7 @@ def __init__(self): self.dependencies = [] # software.EntryPoint self.grid = None # software.Gridspec self.language = None # software.ProgrammingLanguage - self.license = None # str + self.license = None # unicode self.sub_components = [] # software.SoftwareComponent diff --git a/pyesdoc/ontologies/cim/v2/typeset_meta.py b/pyesdoc/ontologies/cim/v2/typeset_meta.py index ac7f35c..85ebf05 100644 --- a/pyesdoc/ontologies/cim/v2/typeset_meta.py +++ b/pyesdoc/ontologies/cim/v2/typeset_meta.py @@ -105,20 +105,20 @@ # Set type info (name, type, is_required, is_iterative). activity.Activity.type_info = ( - ('canonical_name', str, False, False), - ('description', str, False, False), + ('canonical_name', unicode, False, False), + ('description', unicode, False, False), ('duration', shared.TimePeriod, False, False), - ('keywords', str, False, True), - ('long_name', str, False, False), + ('keywords', unicode, False, True), + ('long_name', unicode, False, False), ('meta', shared.Meta, True, False), - ('name', str, True, False), - ('rationale', str, False, False), + ('name', unicode, True, False), + ('rationale', unicode, False, False), ('references', shared.Citation, False, True), ('responsible_parties', shared.Responsibility, False, True), ) activity.AxisMember.type_info = ( - ('description', str, True, False), + ('description', unicode, True, False), ('index', int, True, False), ('value', float, False, False), ) @@ -145,9 +145,9 @@ ) activity.EnsembleAxis.type_info = ( - ('extra_detail', str, True, False), + ('extra_detail', unicode, True, False), ('member', activity.AxisMember, True, True), - ('short_identifier', str, True, False), + ('short_identifier', unicode, True, False), ('target_requirement', activity.NumericalRequirement, True, False), ) @@ -159,16 +159,16 @@ activity.EnsembleRequirement.type_info = ( ('ensemble_member', activity.NumericalRequirement, False, True), - ('ensemble_type', str, True, False), + ('ensemble_type', unicode, True, False), ('minimum_size', int, True, False), ) activity.ForcingConstraint.type_info = ( - ('additional_constraint', str, False, False), + ('additional_constraint', unicode, False, False), ('category', shared.VocabMember, True, False), ('code', shared.VocabMember, True, False), ('data_link', shared.OnlineResource, False, False), - ('forcing_type', str, True, False), + ('forcing_type', unicode, True, False), ('group', shared.VocabMember, False, False), ('origin', shared.Citation, False, False), ) @@ -211,7 +211,7 @@ activity.Simulation.type_info = ( ('calendar', shared.Calendar, False, False), - ('ensemble_identifier', str, True, False), + ('ensemble_identifier', unicode, True, False), ('parent_simulation', activity.ParentSimulation, False, False), ('part_of_project', activity.Project, True, True), ('primary_ensemble', activity.Ensemble, False, False), @@ -239,10 +239,10 @@ data.Dataset.type_info = ( ('availability', shared.OnlineResource, False, True), - ('description', str, False, False), + ('description', unicode, False, False), ('drs_datasets', drs.DrsPublicationDataset, False, True), ('meta', shared.Meta, True, False), - ('name', str, True, False), + ('name', unicode, True, False), ('produced_by', activity.Simulation, False, False), ('references', shared.Citation, False, True), ('related_to_dataset', data.RelatedData, False, True), @@ -251,20 +251,20 @@ data.RelatedData.type_info = ( ('other_dataset', data.Dataset, True, False), - ('relationship', str, True, False), + ('relationship', unicode, True, False), ) data.VariableCollection.type_info = ( - ('collection_name', str, False, False), - ('variables', str, True, True), + ('collection_name', unicode, False, False), + ('variables', unicode, True, True), ) drs.DrsAtomicDataset.type_info = ( ('ensemble_member', drs.DrsEnsembleIdentifier, True, False), ('geographical_constraint', drs.DrsGeographicalIndicator, False, False), - ('mip_table', str, True, False), + ('mip_table', unicode, True, False), ('temporal_constraint', drs.DrsTemporalIdentifier, False, False), - ('variable_name', str, True, False), + ('variable_name', unicode, True, False), ) drs.DrsEnsembleIdentifier.type_info = ( @@ -274,48 +274,48 @@ ) drs.DrsGeographicalIndicator.type_info = ( - ('bounding_box', str, False, False), - ('operator', str, False, False), - ('spatial_domain', str, False, False), + ('bounding_box', unicode, False, False), + ('operator', unicode, False, False), + ('spatial_domain', unicode, False, False), ) drs.DrsPublicationDataset.type_info = ( - ('activity', str, True, False), - ('experiment', str, True, False), - ('frequency', str, False, False), - ('institute', str, True, False), - ('model', str, True, False), - ('product', str, True, False), - ('realm', str, False, False), + ('activity', unicode, True, False), + ('experiment', unicode, True, False), + ('frequency', unicode, False, False), + ('institute', unicode, True, False), + ('model', unicode, True, False), + ('product', unicode, True, False), + ('realm', unicode, False, False), ('version_number', int, False, False), ) drs.DrsTemporalIdentifier.type_info = ( - ('end', str, False, False), - ('start', str, True, False), - ('suffix', str, False, False), + ('end', unicode, False, False), + ('start', unicode, True, False), + ('suffix', unicode, False, False), ) platform.ComponentPerformance.type_info = ( ('component', software.SoftwareComponent, False, False), - ('component_name', str, True, False), + ('component_name', unicode, True, False), ('cores_used', int, False, False), ('nodes_used', int, False, False), ('speed', float, True, False), ) platform.ComputePool.type_info = ( - ('accelerator_type', str, False, False), + ('accelerator_type', unicode, False, False), ('accelerators_per_node', int, False, False), ('compute_cores_per_node', int, False, False), - ('cpu_type', str, False, False), - ('description', str, False, False), - ('interconnect', str, False, False), + ('cpu_type', unicode, False, False), + ('description', unicode, False, False), + ('interconnect', unicode, False, False), ('memory_per_node', platform.StorageVolume, False, False), - ('model_number', str, False, False), - ('name', str, False, False), + ('model_number', unicode, False, False), + ('name', unicode, False, False), ('number_of_nodes', int, False, False), - ('operating_system', str, False, False), + ('operating_system', unicode, False, False), ) platform.Machine.type_info = ( @@ -324,10 +324,10 @@ platform.Partition.type_info = ( ('compute_pools', platform.ComputePool, True, True), - ('description', str, False, False), + ('description', unicode, False, False), ('institution', shared.Party, True, False), - ('model_number', str, False, False), - ('name', str, True, False), + ('model_number', unicode, False, False), + ('name', unicode, True, False), ('online_documentation', shared.OnlineResource, False, True), ('partition', platform.Partition, False, True), ('storage_pools', platform.StoragePool, False, True), @@ -338,14 +338,14 @@ platform.Performance.type_info = ( ('asypd', float, False, False), ('chsy', float, False, False), - ('compiler', str, False, False), + ('compiler', unicode, False, False), ('coupler_load', float, False, False), ('io_load', float, False, False), ('load_imbalance', float, False, False), ('memory_bloat', float, False, False), ('meta', shared.Meta, True, False), ('model', software.Model, True, False), - ('name', str, False, False), + ('name', unicode, False, False), ('platform', platform.Machine, True, False), ('subcomponent_performance', platform.ComponentPerformance, False, False), ('sypd', float, False, False), @@ -353,29 +353,29 @@ ) platform.StoragePool.type_info = ( - ('description', str, False, False), - ('name', str, True, False), - ('type', str, False, False), + ('description', unicode, False, False), + ('name', unicode, True, False), + ('type', unicode, False, False), ('vendor', shared.Party, False, False), ('volume_available', platform.StorageVolume, True, False), ) platform.StorageVolume.type_info = ( - ('units', str, True, False), + ('units', unicode, True, False), ('volume', int, True, False), ) science.Algorithm.type_info = ( ('diagnostic_variables', data.VariableCollection, False, True), - ('heading', str, True, False), - ('implementation_overview', str, True, False), + ('heading', unicode, True, False), + ('implementation_overview', unicode, True, False), ('prognostic_variables', data.VariableCollection, False, True), ('references', shared.Citation, False, True), ) science.ConservationProperties.type_info = ( ('corrected_conserved_prognostic_variables', data.VariableCollection, False, False), - ('correction_methodology', str, False, False), + ('correction_methodology', unicode, False, False), ('flux_correction_was_used', bool, True, False), ) @@ -385,41 +385,41 @@ ('maximum_vertical_level', float, False, False), ('minimum_vertical_level', float, False, False), ('northern_boundary', float, False, False), - ('region_known_as', str, False, True), + ('region_known_as', unicode, False, True), ('southern_boundary', float, False, False), ('western_boundary', float, False, False), - ('z_units', str, True, False), + ('z_units', unicode, True, False), ) science.GridSummary.type_info = ( ('grid_extent', science.Extent, True, False), - ('grid_layout', str, True, False), - ('grid_type', str, True, False), + ('grid_layout', unicode, True, False), + ('grid_type', unicode, True, False), ) science.Process.type_info = ( ('algorithm_properties', science.Algorithm, False, True), - ('description', str, False, False), + ('description', unicode, False, False), ('detailed_properties', science.ProcessDetail, False, True), - ('implementation_overview', str, True, False), - ('keywords', str, True, False), - ('name', str, True, False), + ('implementation_overview', unicode, True, False), + ('keywords', unicode, True, False), + ('name', unicode, True, False), ('references', shared.Reference, False, True), ('time_step_in_process', float, False, False), ) science.ProcessDetail.type_info = ( - ('content', str, False, False), - ('heading', str, False, False), + ('content', unicode, False, False), + ('heading', unicode, False, False), ('properties', shared.KeyFloat, False, True), - ('selection', str, False, True), - ('vocabulary', str, False, False), + ('selection', unicode, False, True), + ('vocabulary', unicode, False, False), ) science.Resolution.type_info = ( ('equivalent_horizontal_resolution', float, True, False), ('is_adaptive_grid', bool, False, False), - ('name', str, True, False), + ('name', unicode, True, False), ('number_of_levels', int, False, True), ('number_of_xy_gridpoints', int, False, True), ) @@ -428,9 +428,9 @@ ('extra_conservation_properties', science.ConservationProperties, False, False), ('grid', science.GridSummary, False, False), ('meta', shared.Meta, True, False), - ('name', str, True, False), - ('overview', str, False, False), - ('realm', str, False, False), + ('name', unicode, True, False), + ('overview', unicode, False, False), + ('realm', unicode, False, False), ('references', shared.Reference, False, True), ('resolution', science.Resolution, True, False), ('simulates', science.Process, True, True), @@ -438,40 +438,40 @@ ) science.Tuning.type_info = ( - ('description', str, True, False), + ('description', unicode, True, False), ('global_mean_metrics_used', data.VariableCollection, False, False), ('regional_metrics_used', data.VariableCollection, False, False), ('trend_metrics_used', data.VariableCollection, False, False), ) shared.Calendar.type_info = ( - ('cal_type', str, True, False), - ('description', str, False, False), + ('cal_type', unicode, True, False), + ('description', unicode, False, False), ('month_lengths', int, False, True), - ('name', str, False, False), + ('name', unicode, False, False), ) shared.CimLink.type_info = ( - ('remote_type', str, True, False), + ('remote_type', unicode, True, False), ) shared.Cimtext.type_info = ( - ('content', str, True, False), - ('content_type', str, True, False), + ('content', unicode, True, False), + ('content_type', unicode, True, False), ) shared.Citation.type_info = ( - ('abstract', str, False, False), - ('citation_str', str, True, False), - ('context', str, False, False), - ('doi', str, False, False), - ('title', str, False, False), + ('abstract', unicode, False, False), + ('citation_str', unicode, True, False), + ('context', unicode, False, False), + ('doi', unicode, False, False), + ('title', unicode, False, False), ('url', shared.OnlineResource, False, False), ) shared.DateTime.type_info = ( ('offset', bool, False, False), - ('value', str, True, False), + ('value', unicode, True, False), ) shared.DatetimeSet.type_info = ( @@ -479,49 +479,49 @@ ) shared.IrregularDateset.type_info = ( - ('date_set', str, True, False), + ('date_set', unicode, True, False), ) shared.KeyFloat.type_info = ( - ('key', str, True, False), + ('key', unicode, True, False), ('value', float, True, False), ) shared.Meta.type_info = ( ('metadata_author', shared.Party, True, False), - ('metadata_completeness', str, False, False), - ('metadata_quality', str, False, False), + ('metadata_completeness', unicode, False, False), + ('metadata_quality', unicode, False, False), ('metadata_reviewer', shared.Party, False, False), ) shared.MinimalMeta.type_info = ( ('document_version', int, False, False), ('metadata_last_updated', datetime.datetime, True, False), - ('uid', str, True, False), + ('uid', unicode, True, False), ) shared.NumberArray.type_info = ( - ('values', str, True, False), + ('values', unicode, True, False), ) shared.OnlineResource.type_info = ( - ('description', str, False, False), - ('linkage', str, True, False), - ('name', str, True, False), - ('protocol', str, False, False), + ('description', unicode, False, False), + ('linkage', unicode, True, False), + ('name', unicode, True, False), + ('protocol', unicode, False, False), ) shared.Party.type_info = ( - ('address', str, False, False), - ('email', str, False, False), + ('address', unicode, False, False), + ('email', unicode, False, False), ('meta', shared.MinimalMeta, True, False), - ('name', str, False, False), + ('name', unicode, False, False), ('organisation', bool, False, False), ('url', shared.OnlineResource, False, False), ) shared.Pid.type_info = ( - ('id', str, True, False), + ('id', unicode, True, False), ('resolution_service', shared.OnlineResource, True, False), ) @@ -536,14 +536,14 @@ shared.Responsibility.type_info = ( ('party', shared.Party, True, True), - ('role', str, True, False), + ('role', unicode, True, False), ('when', shared.TimePeriod, False, False), ) shared.StandaloneDocument.type_info = ( - ('long_name', str, False, False), + ('long_name', unicode, False, False), ('meta', shared.Meta, True, False), - ('name', str, True, False), + ('name', unicode, True, False), ('references', shared.Citation, False, True), ('responsible_parties', shared.Responsibility, False, True), ) @@ -551,58 +551,58 @@ shared.TimePeriod.type_info = ( ('calendar', shared.Calendar, False, False), ('date', shared.DateTime, False, False), - ('date_type', str, True, False), + ('date_type', unicode, True, False), ('length', int, True, False), - ('units', str, True, False), + ('units', unicode, True, False), ) shared.TimesliceList.type_info = ( ('members', shared.NumberArray, True, False), - ('units', str, True, False), + ('units', unicode, True, False), ) shared.VocabMember.type_info = ( - ('uri', str, False, False), - ('value', str, True, False), + ('uri', unicode, False, False), + ('value', unicode, True, False), ('vocab', shared.Citation, False, False), ) software.ComponentBase.type_info = ( - ('description', str, False, False), + ('description', unicode, False, False), ('development_history', software.DevelopmentPath, False, False), ('documentation', shared.Citation, False, True), - ('long_name', str, False, False), - ('name', str, True, False), + ('long_name', unicode, False, False), + ('name', unicode, True, False), ('release_date', datetime.datetime, False, False), ('tuning_applied', science.Tuning, False, False), - ('version', str, False, False), + ('version', unicode, False, False), ) software.Composition.type_info = ( - ('couplings', str, False, True), - ('description', str, False, False), + ('couplings', unicode, False, True), + ('description', unicode, False, False), ) software.DevelopmentPath.type_info = ( - ('consortium_name', str, False, False), + ('consortium_name', unicode, False, False), ('creators', shared.Responsibility, False, True), ('developed_in_house', bool, True, False), ('funding_sources', shared.Responsibility, False, True), - ('previous_version', str, False, False), + ('previous_version', unicode, False, False), ) software.EntryPoint.type_info = ( - ('name', str, False, False), + ('name', unicode, False, False), ) software.Gridspec.type_info = ( - ('description', str, True, False), + ('description', unicode, True, False), ) software.Model.type_info = ( - ('category', str, True, False), + ('category', unicode, True, False), ('coupled_software_components', software.Model, False, True), - ('coupler', str, False, False), + ('coupler', unicode, False, False), ('extra_conservation_properties', science.ConservationProperties, False, False), ('internal_software_components', software.SoftwareComponent, False, True), ('meta', shared.Meta, True, False), @@ -612,17 +612,17 @@ software.SoftwareComponent.type_info = ( ('composition', software.Composition, False, False), ('connection_points', software.Variable, False, True), - ('coupling_framework', str, False, False), + ('coupling_framework', unicode, False, False), ('dependencies', software.EntryPoint, False, True), ('grid', software.Gridspec, False, False), - ('language', str, False, False), - ('license', str, False, False), + ('language', unicode, False, False), + ('license', unicode, False, False), ('sub_components', software.SoftwareComponent, False, True), ) software.Variable.type_info = ( - ('description', str, False, False), - ('name', str, True, False), + ('description', unicode, False, False), + ('name', unicode, True, False), ('prognostic', bool, True, False), ) diff --git a/pyesdoc/options.py b/pyesdoc/options.py index 4773207..592ca8e 100644 --- a/pyesdoc/options.py +++ b/pyesdoc/options.py @@ -11,6 +11,7 @@ """ +import pyesdoc from pyesdoc.utils import runtime as rt @@ -41,7 +42,7 @@ def set_option(name, value): """ if name not in _OPTIONS: - rt.throw("pyesdoc option {0} is unsupported".format(name)) + raise pyesdoc.InvalidOptionException(name) _OPTIONS[name] = str(value) @@ -56,6 +57,6 @@ def get_option(name): """ if name not in _OPTIONS: - rt.throw("pyesdoc option {0} is unsupported".format(name)) + raise ValueError("pyesdoc option {0} is unsupported".format(name)) return _OPTIONS[name] diff --git a/pyesdoc/publishing.py b/pyesdoc/publishing.py index 604f79b..c6a3a54 100644 --- a/pyesdoc/publishing.py +++ b/pyesdoc/publishing.py @@ -15,6 +15,7 @@ import requests +import pyesdoc from pyesdoc import constants from pyesdoc import options from pyesdoc.serialization import encode, decode @@ -41,64 +42,64 @@ def _assert_doc(doc, msg): """ if doc is None: - rt.throw(msg if msg is not None else "Document instance is null.") + raise ValueError(msg if msg is not None else "Document instance is null.") def _throw_invalid_doc_id(): """Throws an error. """ - rt.throw("Invalid document uid (must be an instance of uuid.UUID).") + raise TypeError("Invalid document uid (must be an instance of uuid.UUID).") def _throw_invalid_doc_version(): """Throws an error. """ - rt.throw("Invalid document version (must be either \ - 'all', 'latest' or an integer.") + raise TypeError("Invalid document version (must be either \ + 'all', 'latest' or an integer.") def _throw_connection_error(): """Throws an error. """ - rt.throw("Could not connect to remote API server.") + raise pyesdoc.WebServiceException("Could not connect to remote API server.") def _throw_not_found_error(): """Throws an error. """ - rt.throw("Could not find remote resource.") + raise pyesdoc.WebServiceException("Could not find remote resource.") def _throw_http_error(): """Throws an error. """ - rt.throw("Invalid HTTP response from remote API server.") + raise pyesdoc.WebServiceException("Invalid HTTP response from remote API server.") def _throw_timeout_error(): """Throws an error. """ - rt.throw("Remote API server connection timed out.") + raise pyesdoc.WebServiceException("Remote API server connection timed out.") def _throw_server_error(resp): """Throws an error. """ - rt.throw("A server side failure has occurred: {0}".format(resp.text)) + raise pyesdoc.WebServiceException("A server side failure has occurred: {0}".format(resp.text)) def _throw_uncontrolled_server_error(resp): """Throws an unknown server error. """ - rt.throw("An uncontrolled server side failure has occurred: {0}".format(resp.text)) + raise pyesdoc.WebServiceException("An uncontrolled server side failure has occurred: {0}".format(resp.text)) def _invoke_api(verb, url, data=None): @@ -194,9 +195,9 @@ def publish(doc): """ # Defensive programming. if doc is None: - rt.throw("Cannot publish null documents.") + raise TypeError("Cannot publish null documents.") if not is_valid(doc): - rt.throw("Cannot publish invalid documents.") + raise ValueError("Cannot publish invalid documents.") # Increment version. doc.meta.version = doc.meta.version + 1 diff --git a/pyesdoc/serialization.py b/pyesdoc/serialization.py index a276064..ab6a81b 100644 --- a/pyesdoc/serialization.py +++ b/pyesdoc/serialization.py @@ -49,7 +49,7 @@ def _assert_decode(target, encoding): """ if target is None: - rt.throw("Documents cannot be decoded from null objects.") + raise ValueError("Documents cannot be decoded from null objects.") if not encoding in _CODECS: raise NotImplementedError('Document decoding is unsupported :: encoding = {0}.'.format(encoding)) @@ -57,7 +57,7 @@ def _assert_decode(target, encoding): if type(target) not in _DECODE_TYPE_WHITELIST[encoding]: err = "Document representation type ({0}) is unsupported, it must be one of {1}." err = err.format(type(target), _DECODE_TYPE_WHITELIST[encoding]) - rt.throw(err) + raise TypeError(err) def decode(target, encoding): @@ -81,10 +81,10 @@ def _assert_encode(target, encoding): """ if target is None: - rt.throw("Cannot encode a null document.") + raise ValueError("Cannot encode a null document.") if type(target) not in ontologies.get_types(): - rt.throw("Unsupported document type: {0}.".format(type(target))) + raise TypeError("Unsupported document type: {0}.".format(type(target))) if not encoding in _CODECS: raise NotImplementedError('Unsupported document encoding :: {0}.'.format(encoding)) diff --git a/pyesdoc/utils/__init__.py b/pyesdoc/utils/__init__.py index 6f10d55..5f9fe68 100644 --- a/pyesdoc/utils/__init__.py +++ b/pyesdoc/utils/__init__.py @@ -11,8 +11,7 @@ """ from pyesdoc.utils import convert -from pyesdoc.utils import functional from pyesdoc.utils import runtime from pyesdoc.utils import runtime as rt -from pyesdoc.utils.config import data as config +from pyesdoc.utils import config diff --git a/pyesdoc/utils/config.py b/pyesdoc/utils/config.py index 4df28a5..a3fc52f 100644 --- a/pyesdoc/utils/config.py +++ b/pyesdoc/utils/config.py @@ -63,45 +63,36 @@ def _init_from_user_home(): return config_path -def _init(): +def init(): """Initializes configuration. """ global data - # Attempt to load config from file system. - for func in ( - _init_from_local_config, - _init_from_user_home, - _init_from_shell_config, - ): - config_path = func() - if config_path: - log("Loading pyesdoc config from: {}".format(config_path)) - break - - # Decode. - if config_path: - data = json_file_to_namedtuple(config_path) - - # Warn - else: - msg = """ + # Escape if config data already initialized. + if data is not None: + return + + # Attempt to load config. + config_path = _init_from_local_config() or \ + _init_from_user_home() or \ + _init_from_shell_config() + + if not config_path: + raise RuntimeError(""" WARNING :: pyesdoc configuration file not found. - If you are running pyesdoc as part of the ES-DOC shell then the config file location should be: + If running pyesdoc within ES-DOC shell the config file location should be: SHELL-HOME/ops/config/pyesdoc.conf. - If you are running pyesdoc as part of the ES-DOC notebook-shell then the config file location should be: + If running pyesdoc within ES-DOC notebook-shell the config file location should be: SHELL-HOME/pyesdoc.conf. - If you are running pyesdoc in standalone mode then the config file location should be: + If running pyesdoc in standalone mode the config file location should be: $HOME/.pyesdoc - If neither of these files exist then: + Otherwise: 1. Download the following default configuration file: - https://raw.githubusercontent.com/ES-DOC/esdoc-shell/master/resources/user/template-pyesdoc.conf + http://bit.ly/1MjRS5n 2. Copy downloaded file to $HOME/.pyesdoc If this problem persists them contact es-doc-support@list.woc.noaa.gov - """ - raise RuntimeError(msg) - + """) -# Auto-initialize. -# _init() + log("Loading pyesdoc config from: {}".format(config_path)) + data = json_file_to_namedtuple(config_path) diff --git a/pyesdoc/utils/convert.py b/pyesdoc/utils/convert.py index 3778ae5..1301dff 100644 --- a/pyesdoc/utils/convert.py +++ b/pyesdoc/utils/convert.py @@ -45,6 +45,8 @@ def str_to_unicode(val): """ if val is None: return unicode() + if isinstance(val, unicode): + return val val = str(val).decode('utf-8').strip() if not len(val): @@ -548,38 +550,36 @@ def csv_file_to_json_file(fp, dest=None): f.write(dict_to_json(csv_file_to_dict(fp))) -def str_to_typed_value(s, type): - """Converts a string to a typed value. +def text_to_typed_value(text, target_type): + """Converts text to a typed value. - :param str s: A string for type conversion. + :param str text: Text to be converted to a typed value. :param class type: Target type. - :returns: A string converted to a typed value. + :returns: A typed value. :rtype: object """ # Encode. - if s is not None: - s = unicode_to_str(s) if isinstance(s, unicode) else str(s) - - # None if empty value. - if s is None or not len(s): - return None + if text is not None: + text = unicode_to_str(text) if isinstance(text, unicode) else str(text) # Decode according to type: # ... date's - if type in (datetime.datetime, datetime.date, datetime.time): - return arrow.get(s).datetime + if target_type in {datetime.datetime, datetime.date, datetime.time}: + return arrow.get(text).datetime # ... uuid's - elif type is uuid.UUID: - return uuid.UUID(s) + elif target_type is uuid.UUID: + return uuid.UUID(text) # ... boolean's - elif type is bool: - return s.lower() in ("yes", "true", "t", "1", "y") + elif target_type is bool: + return text.lower() in {"yes", "true", "t", "1", "y"} + elif target_type is unicode: + return text # ... others else: try: - return type(s) + return target_type(text) # ... exceptions - except Error as e: - print "Scalar decoding error", s, type \ No newline at end of file + except Exception as e: + print "Scalar decoding error", text, target_type diff --git a/pyesdoc/utils/functional.py b/pyesdoc/utils/functional.py deleted file mode 100644 index 3638eda..0000000 --- a/pyesdoc/utils/functional.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -.. module:: functional.py - :copyright: Copyright "Feb 7, 2013", Earth System Documentation - :license: GPL/CeCIL - :platform: Unix, Windows - :synopsis: Set of functional programming utilities for working with collections. - -.. moduleauthor:: Mark Conway-Greenslade - - -""" -def invoke(collection, func): - """Invokes a function over each member of a collection. - - :param iterable collection: A collection of items. - :param function func: A function to be applied to each collection member. - - :returns: Tuple of function results. - :rtype: tuple - - """ - return (func(i) for i in collection) - - -def first(collection, name, value, value_formatter=None): - """Returns first item in collection filtered by attribute name/value. - - :param iterable collection: A collection of items for filtering. - :param str name: Name of an attribute acting as filter target. - :param object value: Value to filter by. - :param function formatter: Value formatting function. - - :returns: First item in collection filtered by attribute name/value. - :rtype: object | None - - """ - filtered = all(collection, name, value, value_formatter) - - return filtered[0] if len(filtered) else None - - -def all(collection, name, value, formatter=None): - """Returns collection filtered by attribute name/value. - - :param iterable collection: A collection of items for filtering. - :param str name: Name of an attribute acting as filter target. - :param object value: Value to filter by. - :param function formatter: Value formatting function. - - :returns: Collection filtered by attribute name/value. - :rtype: iterable - - """ - if formatter: - value = formatter(value) - - def predicate(i): - if hasattr(i, name): - v = getattr(i, name) - if formatter: - v = formatter(v) - - return v == value - else: - return False - - return filter(predicate, collection) diff --git a/pyesdoc/utils/runtime.py b/pyesdoc/utils/runtime.py index 1940c04..f3100fc 100644 --- a/pyesdoc/utils/runtime.py +++ b/pyesdoc/utils/runtime.py @@ -10,11 +10,6 @@ """ -import inspect - -import pyesdoc - - # Set of logging levels. LOG_LEVEL_DEBUG = 'DUBUG' LOG_LEVEL_INFO = 'INFO' @@ -22,236 +17,16 @@ LOG_LEVEL_ERROR = 'ERROR' -def raise_error(msg, err_type=None): - """Helper function to raise a runtime error. - - :param msg: Error message. - :type msg: str - - :param type: Error type. - :type type: class - - """ - if err_type is None: - err_type = pyesdoc.PYESDOC_Exception - - raise err_type(msg) - - -def assert_function(f, msg=None): - """Asserts that a variable is a function. - - :param f: Variable that should be a function pointer. - :type f: function - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - return "Function assertion failure." - - if not inspect.isfunction(f): - throw(get_msg if msg is None else msg) - - -def assert_var(name, value, type, msg=None): - """Asserts that a variable is of the expected type. - - :param name: Variable name. - :type name: str - - :param name: Variable value. - :type value: object - - :param name: Variable type. - :type type: class - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - msg = "Parameter '{0}' is of an invalid type (expected type = {1})." - return msg.format(name, type.__name__) - - if value is None or not isinstance(value, type): - throw(get_msg if msg is None else msg) - - -def assert_optional_var(name, value, type, msg=None): - """Asserts that a variable is of the expected type if it is not None. - - :param name: Variable name. - :type name: str - - :param name: Variable value. - :type value: object - - :param name: Variable type. - :type type: class - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - if value is not None: - assert_var(name, value, type, msg) - - -def assert_iter_item(collection, item, msg=None): - """Asserts that an item is a member of passed collection. - - :param collection: A collection that should contain the specified item. - :type collection: iterable - - :param item: An item that should be a collection member. - :type item: object - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - return "Item not found within collection :: {0}.".format(item) - - assert_iter(collection) - if not item in collection: - throw(get_msg if msg is None else msg) - - -def assert_iter(collection, msg=None): - """Asserts that an item is a an iterable. - - :param collection: A collection that should be iterable. - :type collection: iterable - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - return "Collection is not iterable." - - try: - iter(collection) - except TypeError: - throw(get_msg if msg is None else msg) - - -def assert_typed_iter(collection, type, msg=None): - """Asserts that each collection member is of the expected type. - - :param collection: A collection. - :type collection: iterable - - - :param type: Type that each collection item should sub-class. - :type type: class or None - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - msg = "Collection contains items of an invalid type (expected type = {0})." - return msg.format(type.__name__) - - assert_iter(collection) - if len([i for i in collection if not isinstance(i, type)]) > 0: - throw(get_msg if msg is None else msg) - - -def assert_attr(instance, attr, msg=None): - """Asserts that passed instance has the passed attribute (i.e. is it a duck ?). - - :param instance: An object instance. - :type item: object - - :param attr: Name of attribute that instance should contain. - :type item: str - - :param msg: Error message to output if assertion fails. - :type msg: str or None - - """ - def get_msg(): - return "Attribute {0} is not found.".format(attr) - - assert_var('instance', instance, object) - if not hasattr(instance, attr): - throw(get_msg if msg is None else msg) - - -def assert_doc(name, doc, msg=None): +def assert_doc(doc): """Asserts thay passed variable is a pyesdoc object instance. - :param name: Variable name. - :type name: str - - :param doc: A pyesdoc object instance. - :type doc: object - - :param msg: Error message to output if assertion fails. - :type msg: str or None + :param object doc: A pyesdoc object instance. """ - def get_msg(): - return msg if msg is not None else \ - "{0} is not a pyesdoc type instance".format(name) - - assert_var(name, doc, object, msg=get_msg) - assert_attr(doc, 'meta', msg="Document meta-information is missing") - - -def is_iterable(target): - """Returns a flag indicating whether passed variable is iterable. - - :param target: Varaible being tested whether it is iterable or not. - :type target: object or iterable - - """ - is_iterable = True - try: - iter(target) - except TypeError: - is_iterable = False - - return is_iterable - - -def assert_params(params, rules): - """Performs a set of assertions over a parameter dictionary. - - :param params: Dictionary or input parameters. - :type params: dict - - :param rules: Set of assertion rules. - :type rules: list - - """ - for rule in rules: - # Unpack rule. - name, white_list = rule - - # Assert param is specified. - if not params.has_key(name) or not len(str(params[name])): - throw("Parameter {0} is unspecified.".format(name)) - - # Assert param value is in constrained list. - if len(white_list): - if params[name] not in white_list: - throw("Parameter {0} is invalid.".format(name)) - - -def throw(msg): - """Throws an ES-DOC API error. - - :param msg: Error message. - :type msg: str - - """ - raise_error(msg) + if doc is None or not isinstance(doc, object): + raise TypeError("Document type is unrecognized") + if not hasattr(doc, 'meta'): + raise ValueError('Document has no meta attribute') def log(msg=None, level=LOG_LEVEL_INFO): @@ -305,4 +80,49 @@ def invoke(ctx, actions, error_actions): except Exception as exc: ctx.error = exc for action in error_actions: - action(ctx) \ No newline at end of file + action(ctx) + + +def first(collection, name, value, value_formatter=None): + """Returns first item in collection filtered by attribute name/value. + + :param iterable collection: A collection of items for filtering. + :param str name: Name of an attribute acting as filter target. + :param object value: Value to filter by. + :param function formatter: Value formatting function. + + :returns: First item in collection filtered by attribute name/value. + :rtype: object | None + + """ + filtered = all(collection, name, value, value_formatter) + + return filtered[0] if len(filtered) else None + + +def all(collection, name, value, formatter=None): + """Returns collection filtered by attribute name/value. + + :param iterable collection: A collection of items for filtering. + :param str name: Name of an attribute acting as filter target. + :param object value: Value to filter by. + :param function formatter: Value formatting function. + + :returns: Collection filtered by attribute name/value. + :rtype: iterable + + """ + if formatter: + value = formatter(value) + + def predicate(i): + if hasattr(i, name): + v = getattr(i, name) + if formatter: + v = formatter(v) + + return v == value + else: + return False + + return filter(predicate, collection) diff --git a/pyesdoc/validation/validator.py b/pyesdoc/validation/validator.py index 7c1dd28..58191f6 100644 --- a/pyesdoc/validation/validator.py +++ b/pyesdoc/validation/validator.py @@ -10,7 +10,6 @@ """ -from pyesdoc.utils import runtime as rt from pyesdoc.validation.graph import DocumentValidationGraph diff --git a/setup.py b/setup.py index 7020961..79339e7 100755 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ def _get_version(): install_requires=_REQUIRES, url='https://github.com/ES-DOC/esdoc-py-client', license='GPL', - author='Mark Anthony Conway-Greenslade', + author='Mark A. Greenslade', author_email='momipsl@ipsl.jussieu.fr', packages=find_packages(), # package_dir={'pyesdoc': 'pyesdoc'}, diff --git a/tests/test_archive.py b/tests/test_archive.py index c698418..0aa9faa 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -11,10 +11,6 @@ .. moduleauthor:: Earth System Documentation (ES-DOC) """ -# Module imports. -import nose -import os - import pyesdoc import test_utils as tu @@ -23,32 +19,27 @@ def _test_archive_config(): """Test archive configuration.""" import pyesdoc.archive.config as cfg - tu.assert_path(cfg.DIR_ARCHIVE) - tu.assert_int(cfg.projects, 5) - tu.assert_int(cfg.sources, 4) - tu.assert_int(cfg.projects[0].feeds, 5) - tu.assert_int(cfg.projects[1].feeds, 1) - tu.assert_int(cfg.projects[2].feeds, 1) - tu.assert_int(cfg.projects[3].feeds, 1) - tu.assert_int(cfg.get_project_sources(), 6) + tu.assert_path(cfg.get_directory()) + tu.assert_int(cfg.get_projects(), 6) + tu.assert_int(cfg.get_sources(), 4) + tu.assert_int(cfg.get_projects()[0].feeds, 2) + tu.assert_int(cfg.get_projects()[1].feeds, 1) + tu.assert_int(cfg.get_projects()[2].feeds, 1) + tu.assert_int(cfg.get_projects()[3].feeds, 1) + tu.assert_int(cfg.get_projects()[4].feeds, 1) + tu.assert_int(cfg.get_project_sources(), 7) def _test_archive_doc_dirs(): """Test archive document directories.""" - import pyesdoc.archive.config as cfg - import pyesdoc.archive.io as io - - for managed_dir in io.MANAGED_FOLDERS: - for project, source in cfg.get_project_sources(): - folder = io.get_folder(project, source, managed_dir) - assert os.path.exists(folder.path), folder.path + folders = list(pyesdoc.archive.yield_folders()) + for folder in folders: + assert folder.exists, True def _test_archive_get_counts(): """Test archive document counts.""" - import pyesdoc.archive.io as io - - tu.assert_int(len(io.get_counts()), 43, assert_type=tu.COMPARE_LTE) + tu.assert_int(pyesdoc.archive.get_count(), 37019, assert_type=tu.COMPARE_LTE) def test(): diff --git a/tests/test_factory.py b/tests/test_factory.py index 9ef560a..8428b7a 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -30,14 +30,9 @@ _PROJECT = 'TEST' -def _create_doc(ontology=_CIM, - version=_CIM_V1, - package=_CIM_PACKAGE, - typeof=_CIM_TYPE): +def _create_doc(doc_type=cim.v1.ModelComponent): """Creates a test document.""" - type_key = ".".join([ontology, version, package, typeof]) - - return pyesdoc.create(type_key, _INSTITUTE, _PROJECT) + return pyesdoc.create(doc_type, _INSTITUTE, _PROJECT) def _assert_doc(doc, typeof=None): @@ -47,7 +42,7 @@ def _assert_doc(doc, typeof=None): tu.assert_str(doc.meta.institute, _INSTITUTE.lower()) tu.assert_str(doc.meta.language, pyesdoc.ESDOC_DEFAULT_LANGUAGE) tu.assert_str(doc.meta.project, _PROJECT.lower()) - tu.assert_str(doc.meta.source, _INSTITUTE.lower()) + tu.assert_str(doc.meta.source, pyesdoc.ESDOC_DEFAULT_SOURCE) if typeof is not None: tu.assert_str(doc.meta.type, typeof.type_key) @@ -60,15 +55,6 @@ def _test_create_01(): def _test_create_02(): - """Test creating documents - 2.""" - for ontology, version, package, typeof in pyesdoc.list_types(): - doc = _create_doc(ontology, version, package, typeof) - _assert_doc(doc) - type_key = "{0}.{1}.{2}.{3}".format(ontology, version, package, typeof) - tu.assert_str(doc.__class__.type_key, type_key) - - -def _test_create_03(): """Test creating documents - 3.""" for doc_type in pyesdoc.get_types(): doc = pyesdoc.create(doc_type, institute=_INSTITUTE, project=_PROJECT) @@ -80,7 +66,6 @@ def test(): for func in ( _test_create_01, _test_create_02, - _test_create_03, ): tu.init(func, func.__doc__[5:]) yield func \ No newline at end of file diff --git a/tests/test_general.py b/tests/test_general.py index 4b744c6..77cbe64 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -77,12 +77,12 @@ def test_imports_01(): pyesdoc, pyesdoc.archive, pyesdoc.archive.config, - pyesdoc.archive.io, - pyesdoc.archive.parsers, pyesdoc.constants, pyesdoc.factory, pyesdoc.io, pyesdoc.ontologies, + pyesdoc.ontologies.cim.v1, + pyesdoc.ontologies.cim.v2, pyesdoc.options, pyesdoc.extensions, pyesdoc.extensions.default, @@ -91,7 +91,6 @@ def test_imports_01(): pyesdoc.serialization, pyesdoc.utils, pyesdoc.utils.convert, - pyesdoc.utils.functional, pyesdoc.utils.runtime, pyesdoc.validation, pyesdoc.validation.graph, @@ -160,7 +159,7 @@ def _test_list_types(): """Test listing supported types.""" # supported - all types = pyesdoc.list_types() - tu.assert_int(len(types), 103) + tu.assert_int(len(types), 177) # supported - cim v1 types = pyesdoc.list_types(_CIM, _CIM_V1) diff --git a/tests/test_publishing.py b/tests/test_publishing.py index 2cfcd8d..6ef5a9c 100644 --- a/tests/test_publishing.py +++ b/tests/test_publishing.py @@ -11,10 +11,9 @@ .. moduleauthor:: Earth System Documentation (ES-DOC) """ -import datetime, uuid +import uuid import arrow - import pyesdoc import test_utils as tu @@ -31,7 +30,7 @@ def _create_doc(mod): doc = tu.get_doc(mod) mod.DOC_ID = doc.meta.id = uuid.uuid4() mod.DOC_VERSION = doc.meta.version = 0 - mod.DOC_DATE = doc.meta.create_date = arrow.now().datetime + mod.DOC_DATE = doc.meta.create_date = doc.meta.update_date = arrow.now().datetime return doc @@ -51,6 +50,9 @@ def _test(mod): # Create document. doc = _create_doc(mod) + # for err in pyesdoc.validate(doc): + # print err + # Publish. pyesdoc.publish(doc) mod.DOC_VERSION += 1 diff --git a/tests/test_serialization.py b/tests/test_serialization.py index 95c2972..9d075af 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -28,8 +28,8 @@ def _test(mod, doc, encoding): # Re-encode. as_repr_1 = tu.encode(as_doc_1, encoding) - # TODO - explore why sometimes XML encoding is problematic - # although all good why reencodign in json. + # TODO - explore why sometimes XML encoding is problematic + # although all good when reencoding to json. if len(as_repr) != len(as_repr_1) and encoding == 'xml': as_repr = tu.encode(tu.decode(as_repr, encoding), 'json') as_repr_1 = tu.encode(tu.decode(as_repr_1, encoding), 'json') diff --git a/tests/test_type_cim_v1_activity_ensemble_1.py b/tests/test_type_cim_v1_activity_ensemble_1.py index 2e87787..f09b463 100644 --- a/tests/test_type_cim_v1_activity_ensemble_1.py +++ b/tests/test_type_cim_v1_activity_ensemble_1.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. @@ -58,12 +55,12 @@ def assert_extension_info(ext): :param object ext: Document extension information. """ - tu.assert_str(ext.display_name, "amip") - tu.assert_str(ext.description, "Six element ensemble", True) - tu.assert_str(ext.full_display_name, "CMIP5 Ensemble : MOHC - amip") + tu.assert_str(ext.display_name, u"amip") + tu.assert_str(ext.description, u"Six element ensemble", True) + tu.assert_str(ext.full_display_name, u"CMIP5 Ensemble : MOHC - amip") tu.assert_int(ext.summary_fields, 2) - tu.assert_str(ext.summary_fields[0], "amip") - tu.assert_str(ext.summary_fields[1], "3.3 AMIP and AMIP Ensemble") + tu.assert_str(ext.summary_fields[0], u"amip") + tu.assert_str(ext.summary_fields[1], u"3.3 AMIP and AMIP Ensemble") def _assert_doc_core(doc, is_update): @@ -73,10 +70,9 @@ def _assert_doc_core(doc, is_update): tu.assert_iter(doc.members, 6, cim.v1.EnsembleMember) tu.assert_str(doc.long_name, "3.3 AMIP and AMIP Ensemble") tu.assert_str(doc.short_name, "amip") - tu.assert_iter(doc.types, 1, str) + tu.assert_iter(doc.types, 1) tu.assert_str(doc.types[0], "Initial Condition") - def _assert_doc_member(doc, is_update): """Assert ensemble members information.""" # ... ensemble member id. diff --git a/tests/test_type_cim_v1_activity_ensemble_2.py b/tests/test_type_cim_v1_activity_ensemble_2.py index a4afa5c..3611fff 100644 --- a/tests/test_type_cim_v1_activity_ensemble_2.py +++ b/tests/test_type_cim_v1_activity_ensemble_2.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def _assert_doc_member_change(doc, is_update): """Assert ensemble members information.""" diff --git a/tests/test_type_cim_v1_activity_numerical_experiment.py b/tests/test_type_cim_v1_activity_numerical_experiment.py index 199c057..3412683 100644 --- a/tests/test_type_cim_v1_activity_numerical_experiment.py +++ b/tests/test_type_cim_v1_activity_numerical_experiment.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. @@ -80,16 +77,8 @@ def _assert_doc_requirements(doc, is_update): """Assert experiment requirements.""" tu.assert_iter(doc.requirements, 13, cim.v1.NumericalRequirement) - # Initial condition. - req = doc.requirements[0] - tu.assert_object(req, cim.v1.InitialCondition) - tu.assert_str(req.description, "Initial conditions are from", True) - tu.assert_str(req.id, "ic.003") - tu.assert_str(req.name, "3.3.ic") - tu.assert_str(req.requirement_type, "initialCondition") - # Boundary condition. - req = doc.requirements[1] + req = doc.requirements[0] tu.assert_object(req, cim.v1.BoundaryCondition) tu.assert_str(req.requirement_type, "boundaryCondition") tu.assert_str(req.description, "Imposed changing concentrations", True) @@ -104,6 +93,14 @@ def _assert_doc_requirements(doc, is_update): tu.assert_str(opt.name, "3.3.bc.sls_conc") tu.assert_str(opt.relationship, "XOR") + # Initial condition. + req = doc.requirements[11] + tu.assert_object(req, cim.v1.InitialCondition) + tu.assert_str(req.description, "Initial conditions are from", True) + tu.assert_str(req.id, "ic.003") + tu.assert_str(req.name, "3.3.ic") + tu.assert_str(req.requirement_type, "initialCondition") + # Spatio Temporal Constraint. req = doc.requirements[12] tu.assert_object(req, cim.v1.SpatioTemporalConstraint) diff --git a/tests/test_type_cim_v1_activity_simulation_run.py b/tests/test_type_cim_v1_activity_simulation_run.py index f4b372e..b643c08 100644 --- a/tests/test_type_cim_v1_activity_simulation_run.py +++ b/tests/test_type_cim_v1_activity_simulation_run.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_meta_info(meta): """Asserts a document's meta-information. diff --git a/tests/test_type_cim_v1_data_data_object_1.py b/tests/test_type_cim_v1_data_data_object_1.py index 7149975..cae8930 100644 --- a/tests/test_type_cim_v1_data_data_object_1.py +++ b/tests/test_type_cim_v1_data_data_object_1.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. diff --git a/tests/test_type_cim_v1_data_data_object_2.py b/tests/test_type_cim_v1_data_data_object_2.py index 406c899..a78410b 100644 --- a/tests/test_type_cim_v1_data_data_object_2.py +++ b/tests/test_type_cim_v1_data_data_object_2.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def _assert_doc_core(doc, is_update): """Assert core information.""" diff --git a/tests/test_type_cim_v1_grids_gridspec.py b/tests/test_type_cim_v1_grids_gridspec.py index 2a203bd..e81412c 100644 --- a/tests/test_type_cim_v1_grids_gridspec.py +++ b/tests/test_type_cim_v1_grids_gridspec.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. diff --git a/tests/test_type_cim_v1_misc_document_set.py b/tests/test_type_cim_v1_misc_document_set.py index 0ad524a..21ec1ef 100644 --- a/tests/test_type_cim_v1_misc_document_set.py +++ b/tests/test_type_cim_v1_misc_document_set.py @@ -45,9 +45,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_doc(doc, is_update=False): """Asserts a document. diff --git a/tests/test_type_cim_v1_quality_cim_quality.py b/tests/test_type_cim_v1_quality_cim_quality.py index c326ac8..73fcaf9 100644 --- a/tests/test_type_cim_v1_quality_cim_quality.py +++ b/tests/test_type_cim_v1_quality_cim_quality.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. diff --git a/tests/test_type_cim_v1_shared_platform.py b/tests/test_type_cim_v1_shared_platform.py index 782b8b3..53c4387 100644 --- a/tests/test_type_cim_v1_shared_platform.py +++ b/tests/test_type_cim_v1_shared_platform.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_extension_info(ext): """Asserts a document's extension information. diff --git a/tests/test_type_cim_v1_software_model_component_1.py b/tests/test_type_cim_v1_software_model_component_1.py index f541898..95fc560 100644 --- a/tests/test_type_cim_v1_software_model_component_1.py +++ b/tests/test_type_cim_v1_software_model_component_1.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_meta_info(meta): """Asserts a document's meta-information. diff --git a/tests/test_type_cim_v1_software_model_component_2.py b/tests/test_type_cim_v1_software_model_component_2.py index a8ae1b4..a86e3f6 100644 --- a/tests/test_type_cim_v1_software_model_component_2.py +++ b/tests/test_type_cim_v1_software_model_component_2.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_doc(doc, is_update=False): """Asserts a document. diff --git a/tests/test_type_cim_v1_software_statistical_model_component.py b/tests/test_type_cim_v1_software_statistical_model_component.py index 4d58c0f..c075220 100644 --- a/tests/test_type_cim_v1_software_statistical_model_component.py +++ b/tests/test_type_cim_v1_software_statistical_model_component.py @@ -48,9 +48,6 @@ # Test document author. DOC_AUTHOR = "Metafor Questionnaire" -# Test supported document encodings. -DOC_ENCODINGS_COUNT = 4 - def assert_doc(doc, meta, ext): """Asserts a document. @@ -87,7 +84,7 @@ def assert_doc(doc, meta, ext): assert doc.language is None assert doc.license is None assert doc.long_name == "IPSL-CM5A-LR;atmosphere:LMDZ5A(95x96L39);ocean:NEMOv3.2 (OPA-LIM-PISCES,149x182L31)" - assert doc.previous_version == str() + assert doc.previous_version == unicode() assert doc.release_date == arrow.get('2010', 'YYYY').datetime assert doc.short_name == 'IPSL-CM5A-LR' assert doc.types[0] == 'downscaling' diff --git a/tests/test_types.py b/tests/test_types.py index 1c7abf2..839fddb 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -50,7 +50,6 @@ "DOC_TYPE", "DOC_TYPE_KEY", "DOC_FILE", - "DOC_ENCODINGS_COUNT", "DOC_UID", "DOC_VERSION", "DOC_DATE", diff --git a/tests/test_utils.py b/tests/test_utils.py index 1093abf..68a2946 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -235,7 +235,6 @@ def assert_doc(mod, doc): meta = doc.meta assert_object(meta, cim_v1.DocMetaInfo) assert_str(meta.source, DOCUMENT_SOURCE) - assert_iter(meta.encodings, mod.DOC_ENCODINGS_COUNT, str) if mod.DOC_UID: assert_uuid(meta.id, mod.DOC_UID) if mod.DOC_VERSION: @@ -258,7 +257,6 @@ def assert_doc(mod, doc): ext = doc.ext assert_str(mod.DOC_TYPE_KEY, ext.type, True) assert_str(ext.language, pyesdoc.constants.ESDOC_DEFAULT_LANGUAGE) - assert_iter(ext.encodings, mod.DOC_ENCODINGS_COUNT, str) if hasattr(mod, "assert_extension_info"): mod.assert_extension_info(ext)