mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Some minor optimizations and stricter validation.
This commit is contained in:
parent
11adeaff86
commit
d3abff9ff7
1 changed files with 13 additions and 5 deletions
|
|
@ -130,15 +130,23 @@ def split_collection(text, inline=(u'VTIMEZONE',),
|
||||||
assert isinstance(text, text_type)
|
assert isinstance(text, text_type)
|
||||||
collections = icalendar.cal.Component.from_ical(text, multiple=True)
|
collections = icalendar.cal.Component.from_ical(text, multiple=True)
|
||||||
assert collections
|
assert collections
|
||||||
|
collection_name = None
|
||||||
|
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
items = collection.subcomponents
|
items = collection.subcomponents
|
||||||
|
if collection_name is None:
|
||||||
|
collection_name = collection.name
|
||||||
|
|
||||||
if collection.name in wrap_items_with:
|
if collection_name in wrap_items_with:
|
||||||
start = u'BEGIN:{}'.format(collection.name)
|
start = u'BEGIN:{}'.format(collection_name)
|
||||||
end = u'END:{}'.format(collection.name)
|
end = u'END:{}'.format(collection_name)
|
||||||
else:
|
else:
|
||||||
start = end = u''
|
start = end = u''
|
||||||
|
|
||||||
|
if collection.name != collection.name:
|
||||||
|
raise ValueError('Different types of components at top-level. '
|
||||||
|
'Expected {}, got {}.'
|
||||||
|
.format(collection_name, collection.name))
|
||||||
|
|
||||||
inlined_items, normal_items = \
|
inlined_items, normal_items = \
|
||||||
split_sequence(items, lambda item: item.name in inline)
|
split_sequence(items, lambda item: item.name in inline)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue