def layouts_variants(self): try: layouts = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Layout", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Layout property") return [""] try: variants = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Variant", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Variant property") variants = [] # returned GVariants are unpacked to tuples with single elements # containing comma-separated values layouts = layouts[0].split(",") if variants: variants = variants[0].split(",") # if there are more layouts than variants, empty strings should be appended diff = len(layouts) - len(variants) variants.extend(diff * [""]) # if there are more variants than layouts, throw the trailing ones away variants = variants[:len(layouts)] # map can be used with multiple lists and works like zipWith (Haskell) return map(join_layout_variant, layouts, variants)
def options(self): try: options = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Options", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Options property") return "" # returned GVariant is unpacked to a tuple with a single element return options[0]
def layouts_variants(self): try: layouts = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Layout", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Layout property") return [""] try: variants = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Variant", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Variant property") variants = [] # returned GVariants are unpacked to tuples with single elements # containing comma-separated values layouts = layouts[0].split(",") if variants: variants = variants[0].split(",") # if there are more layouts than variants, empty strings should be appended diff = len(layouts) - len(variants) variants.extend(diff * [""]) return [ join_layout_variant(layout, variant) for layout, variant in zip(layouts, variants) ]
def layouts_variants(self): try: layouts = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Layout", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Layout property") return [""] try: variants = safe_dbus.get_property_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "X11Variant", self._connection) except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError): # no value for the property log.error("Failed to get the value for the systemd-localed's " "X11Variant property") variants = [] # returned GVariants are unpacked to tuples with single elements # containing comma-separated values layouts = layouts[0].split(",") if variants: variants = variants[0].split(",") # if there are more layouts than variants, empty strings should be appended diff = len(layouts) - len(variants) variants.extend(diff * [""]) return [join_layout_variant(layout, variant) for layout, variant in zip(layouts, variants)]