def METHOD_NAME(keymap_file):
    # keymap files can be downloadeded from
    # https://github.com/qemu/qemu/blob/master/pc-bios/keymaps
    global layout
    try:
        for c in open(keymap_file):
            if len(c.strip()) == 0:
                continue
            if c.startswith("# quirks section start"):
                # Stop at the quirks section
                break
            if c.startswith("#"):
                if "layout" in c and ":" in c:
                    layout = c.split(":")[1].strip()
                continue
            if "map " in c:
                continue
            values = c.strip().split(" ")
            if len(values) >= 2:
                keyname = 'XK_' + values[0]
                keycode = ' '.join(values[1:]).strip()
                if keyname not in x11name_to_atset1:
                    x11name_to_atset1[keyname] = keycode
                else:
                    print("Duplicated atset1 code for x11name '%s': '%s' and '%s'" % (
                    keyname, x11name_to_atset1[keyname], keycode))
    except IOError:
        print(
            "File '%s' does not exist. \nkeymaps can be downloaded from https://github.com/qemu/qemu/tree/master/pc-bios/keymaps" % keymap_file)
        sys.exit(2)