Example #1
0
def _get_doc(obj, doc_type):
    """Returns document.

    """
    if ontologies.get_type_key(doc_type) != obj['ontology_type_key']:
        doc_type = ontologies.get_type_from_key(obj['ontology_type_key'])
    if doc_type is None:
        raise ValueError('Decoding type is unrecognized')

    return doc_type(), ontologies.get_decoder_info(doc_type)
Example #2
0
def _create_doc(elem, doc_type):
    """Creates & returns a document to be hydrated from an xml element.

    """
    type_key = elem.get("ontologyTypeKey")
    if type_key and ontologies.get_type_key(doc_type) != type_key:
        doc_type = ontologies.get_type_from_key(type_key)
    if doc_type is None:
        raise ValueError("Decoding type is unrecognized")

    return doc_type(), ontologies.get_decoder_info(doc_type)
def _create_doc(elem, doc_type):
    """Creates & returns a document to be hydrated from an xml element.

    """
    type_key = elem.get('ontologyTypeKey')
    if type_key and ontologies.get_type_key(doc_type) != type_key:
        doc_type = ontologies.get_type_from_key(type_key)
    if doc_type is None:
        raise ValueError('Decoding type is unrecognized')

    return doc_type(), ontologies.get_decoder_info(doc_type)
Example #4
0
def _get_doc(xml, doc_type):
    """Returns document.

    """
    type_key = xml.get('ontologyTypeKey')
    if type_key and ontologies.get_type_key(doc_type) != type_key:
        doc_type = ontologies.get_type_from_key(type_key)
    if doc_type is None:
        raise ValueError('Decoding type is unrecognized')

    return doc_type(), ontologies.get_decoder_info(doc_type)
Example #5
0
def _create_doc(obj, doc_type):
    """Creates & returns a document to be hydrated from a dictionary.

    """
    try:
        obj['meta']
    # ... only DocMetaInfo objects do not have a meta section.
    except KeyError:
        doc_type = ontologies.get_type_from_key('cim.2.shared.DocMetaInfo')
    else:
        if ontologies.get_type_key(doc_type) != obj['meta']['type']:
            doc_type = ontologies.get_type_from_key(obj['meta']['type'])
    finally:
        if doc_type is None:
            raise ValueError('Target decoding type is unrecognized')

    return doc_type(), ontologies.get_decoder_info(doc_type)
Example #6
0
def _create_doc(obj, doc_type):
    """Creates & returns a document to be hydrated from a dictionary.

    """
    try:
        obj['meta']
    # ... only DocMetaInfo objects do not have a meta section.
    except KeyError:
        doc_type = ontologies.get_type_from_key('cim.2.shared.DocMetaInfo')
    else:
        if ontologies.get_type_key(doc_type) != obj['meta']['type']:
            doc_type = ontologies.get_type_from_key(obj['meta']['type'])
    finally:
        if doc_type is None:
            raise ValueError('Target decoding type is unrecognized')

    return doc_type(), ontologies.get_decoder_info(doc_type)