Exemplo n.º 1
0
Arquivo: cxe.py Projeto: mgillis/cxe
def load_file(win, f):
    global wx_map
    global schema_filename
    global main_element_name
    global schema

    wx_map = {}

    win.SetStatusText("Parsing XML...")
    try:
        root = cxexml.parse(f)
    except Exception, e:
        error("Unexpected error parsing XML: %s" + e)
        return False
Exemplo n.º 2
0
Arquivo: cxe.py Projeto: mgillis/cxe
    except Exception, e:
        error("Unexpected error parsing XML: %s" + e)
        return False
    
    schema_filename = root.documentElement.getAttribute("xmlns").split(':',1)[-1]

    if schema_filename == "":
        error("No schema!")
        return False
    elif schema_filename[0:1] == "//":
        error("XML has invalid schema filename '%s'." % schema_filename)
        return False

    win.SetStatusText("Loading and parsing schema (%s)..." % schema_filename)

    schema_root = cxexml.parse(os.path.join(win.dirname, schema_filename))

    # determine main element
    main_element_name = re.search('Civ4(.+)s$', root.documentElement.tagName).group(1)

    win.SetStatusText("Loading %ss...\n" % main_element_name)

    schema = SchemaElement.from_xml(schema_root, main_element_name, defns={})

    items = read_objects(schema, root.getElementsByTagName(main_element_name), main_element_name)

    # FIXME ??
    win.listctrl.SetItems(items)

    # make a wx structure based on schema