mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-01 10:05:50 +00:00
Stricter validation of items
This commit is contained in:
parent
d2f7d9a227
commit
087312adb5
2 changed files with 6 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ class Item(object):
|
|||
|
||||
'''should-be-immutable wrapper class for VCALENDAR and VCARD'''
|
||||
|
||||
def __init__(self, raw):
|
||||
def __init__(self, raw, needs_uid=True):
|
||||
assert isinstance(raw, utils.text_type)
|
||||
raw = raw.splitlines()
|
||||
self.uid = None
|
||||
|
|
@ -23,6 +23,10 @@ class Item(object):
|
|||
for line in raw:
|
||||
if line.startswith(u'UID:'):
|
||||
self.uid = line[4:].strip()
|
||||
|
||||
if needs_uid and self.uid is None:
|
||||
raise ValueError('Item has not uid.')
|
||||
|
||||
self.raw = u'\n'.join(raw)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ def split_collection(text):
|
|||
item.extend(timezone)
|
||||
item.append(line)
|
||||
if item_type != u'VTIMEZONE':
|
||||
yield Item(u'\n'.join(item))
|
||||
yield Item(u'\n'.join(item), needs_uid=False)
|
||||
item = []
|
||||
item_type = None
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue