Browse Source

fix comparison of category prop

Fabian Peter Hammerle 4 years ago
parent
commit
6a40835fee
1 changed files with 14 additions and 3 deletions
  1. 14 3
      ics2vdir/__init__.py

+ 14 - 3
ics2vdir/__init__.py

@@ -28,8 +28,9 @@ _LOGGER = logging.getLogger(__name__)
 
 
 def _event_prop_equal(prop_a, prop_b) -> bool:
-    if isinstance(prop_a, icalendar.prop.vDDDTypes):
-        return vars(prop_a) == vars(prop_b)
+    if isinstance(prop_a, (icalendar.prop.vDDDTypes, icalendar.prop.vCategory)):
+        # pylint: disable=unidiomatic-typecheck
+        return type(prop_a) == type(prop_b) and vars(prop_a) == vars(prop_b)
     return prop_a == prop_b
 
 
@@ -37,7 +38,17 @@ def _events_equal(event_a: icalendar.cal.Event, event_b: icalendar.cal.Event) ->
     for key, prop_a in event_a.items():
         if key == "DTSTAMP":
             continue
-        if not _event_prop_equal(prop_a, event_b[key]):
+        prop_b = event_b[key]
+        if not _event_prop_equal(prop_a, prop_b):
+            _LOGGER.debug(
+                "%s/%s: %r(%r) != %r(%r)",
+                event_a["UID"],
+                key,
+                prop_a,
+                vars(prop_a),
+                prop_b,
+                vars(prop_b),
+            )
             return False
     return True