def parse_hints(self, dbus_hints):
     hints = {}
     h = dbus_to_native(dbus_hints)
     for x in ("image-data", "icon_data"):
         try:
             data = h.pop(x)
         except KeyError:
             pass
         else:
             v = parse_image_data(data)
             if v:
                 hints["image-data"] = v
                 break
     if "image-data" not in hints:
         try:
             image_path = h.pop("image-path")
         except KeyError:
             pass
         else:
             v = parse_image_path(image_path)
             if v:
                 hints["image-data"] = v
     for x in ("action-icons", "category", "desktop-entry", "resident",
               "transient", "x", "y", "urgency"):
         v = h.get(x)
         if v is not None:
             hints[x] = v
     log("parse_hints(%s)=%s", dbus_hints, hints)
     return hints
Exemple #2
0
 def test_parse_image_data(self):
     with silence_error(log):
         assert parse_image_data(None) is None
         assert parse_image_data((1, 2, 3)) is None
         assert parse_image_data((1, 2, 3, 4, 5, 6, 7)) is None
     assert parse_image_data(
         (10, 10, 40, True, 32, 4, b"0" * 40 * 10)) is not None
     assert parse_image_data(
         (10, 10, 40, False, 24, 4, b"0" * 40 * 10)) is not None
     assert parse_image_data(
         (10, 10, 30, False, 24, 3, b"0" * 30 * 10)) is not None