fix #715 (Main Component is missing when only recurrence id exists) with balrok's patch
This commit is contained in:
@@ -225,6 +225,7 @@ def visit_time_ranges(vobject_item: vobject.base.Component, child_name: str,
|
|||||||
def get_children(components: Iterable[vobject.base.Component]) -> Iterator[
|
def get_children(components: Iterable[vobject.base.Component]) -> Iterator[
|
||||||
Tuple[vobject.base.Component, bool, List[date]]]:
|
Tuple[vobject.base.Component, bool, List[date]]]:
|
||||||
main = None
|
main = None
|
||||||
|
rec_main = None
|
||||||
recurrences = []
|
recurrences = []
|
||||||
for comp in components:
|
for comp in components:
|
||||||
if hasattr(comp, "recurrence_id") and comp.recurrence_id.value:
|
if hasattr(comp, "recurrence_id") and comp.recurrence_id.value:
|
||||||
@@ -232,11 +233,14 @@ def visit_time_ranges(vobject_item: vobject.base.Component, child_name: str,
|
|||||||
if comp.rruleset:
|
if comp.rruleset:
|
||||||
# Prevent possible infinite loop
|
# Prevent possible infinite loop
|
||||||
raise ValueError("Overwritten recurrence with RRULESET")
|
raise ValueError("Overwritten recurrence with RRULESET")
|
||||||
|
rec_main = comp
|
||||||
yield comp, True, []
|
yield comp, True, []
|
||||||
else:
|
else:
|
||||||
if main is not None:
|
if main is not None:
|
||||||
raise ValueError("Multiple main components")
|
raise ValueError("Multiple main components")
|
||||||
main = comp
|
main = comp
|
||||||
|
if main is None and len(recurrences) == 1:
|
||||||
|
main = rec_main
|
||||||
if main is None:
|
if main is None:
|
||||||
raise ValueError("Main component missing")
|
raise ValueError("Main component missing")
|
||||||
yield main, False, recurrences
|
yield main, False, recurrences
|
||||||
|
|||||||
Reference in New Issue
Block a user