INNER CODE UNIT · Python

sort_layouts

Julow/Unexpected-Keyboard · gen_layouts.py:36

def sort_layouts(layouts):
    layouts = dict(layouts)
    head = [ (lid, layouts.pop(lid)) for lid in FIRST_LAYOUTS ]
    return head + sorted(layouts.items())

# Write the XML arrays used in the preferences.
def generate_arrays(out, layouts):
    def mk_array(tag, name, strings_items):
        elem = XML.Element(tag, name=name)
        for s in strings_items:
            item = XML.Element("item")
            item.text = s
            elem.append(item)
        return elem
    system_item = [ ("system", "@string/pref_layout_e_system") ]
    custom_item = [ ("custom", "@string/pref_layout_e_custom") ]
    values_items, entries_items = zip(*(system_item + layouts + custom_item)) # unzip
    ids_items = map(lambda s: "@xml/%s" % s if s not in ["system", "custom"] else "-1", values_items)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…