Ejemplo n.º 1
0
def xml_get_history(root, replaced=False):
    data = {}
    keywords = ["added", "updated", "deprecated"]
    if replaced:
        keywords.append("replaced")
        if root.get("ReplacedByField") is not None:
            data["replacement"] = root.get("ReplacedByField")
    for keyword in keywords:
        version = FixVersion.create_from_xml_attrs(root.attrib, keyword)
        if version is not None:
            data[keyword] = version.data
    if root.get("issue"):
        data["issues"] = [root.get("issue")]
    return filter_none(data)
Ejemplo n.º 2
0
def transform_unified_repository_v1(root: Element, phrases: Element):
    abbreviations = xml_to_abbreviations(root.find("abbreviations"))
    categories = xml_to_categories(root.find("categories"))
    components = xml_to_components(root.find("components"))
    datatypes = xml_to_datatypes(root.find("datatypes"))
    fields = xml_to_fields(root.find("fields"))
    messages = xml_to_messages(root.find("messages"))
    sections = xml_to_sections(root.find("sections"))
    fix_version = FixVersion.create_from_xml_attrs(root.attrib, "version").data
    phrases = xml_to_docs_definitions(phrases)
    # Embed docstrings into elements.
    embed_docs(abbreviations, phrases)
    embed_docs(categories, phrases)
    embed_docs(components, phrases)
    embed_docs(datatypes, phrases)
    embed_docs(fields, phrases)
    embed_docs(messages, phrases)
    embed_docs(sections, phrases)
    # No other embeddings to worry about. The Unified FIX Repository contains
    # hierarchial data already.
    return {
        "meta": {
            "schema": "1",
            "version": fix_version,
            "copyright":
            "Copyright (c) FIX Protocol Limited, all rights reserved",
            "fix2dict": {
                "version": __version__,
                "legal": LEGAL_INFO,
                "md5": "",
                "command": " ".join(sys.argv),
                "timestamp": iso8601_utc(),
            },
        },
        "abbreviations": abbreviations,
        "datatypes": datatypes,
        "sections": sections,
        "categories": categories,
        "fields": fields,
        "components": components,
        "messages": messages,
    }
Ejemplo n.º 3
0
def transform_orchestra_v1(root: Element):
    abbreviations = xml_to_abbreviations(root.find("abbreviations"))
    categories = xml_to_categories(root.find("categories"))
    components = xml_to_components(root.find("components"))
    datatypes = xml_to_datatypes(root.find("datatypes"))
    enums = xml_to_enums(root.finds("codesets"))  # FIXME
    fields = xml_to_fields(root.find("fields"))
    messages = xml_to_messages(root.find("messages"))
    sections = xml_to_sections(root.find("sections"))
    fix_version = FixVersion.create_from_xml_attrs(root.attrib, "version").data
    return {
        "meta": meta_v1(fix_version),
        "abbreviations": abbreviations,
        "datatypes": datatypes,
        "sections": sections,
        "categories": categories,
        "fields": fields,
        "components": components,
        "messages": messages,
    }
Ejemplo n.º 4
0
def xml_string_to_version(data, prefix):
    return FixVersion.create_from_xml_attrs(
        ElementTree.fromstring(data).attrib, prefix).data