mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +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'''
|
'''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)
|
assert isinstance(raw, utils.text_type)
|
||||||
raw = raw.splitlines()
|
raw = raw.splitlines()
|
||||||
self.uid = None
|
self.uid = None
|
||||||
|
|
@ -23,6 +23,10 @@ class Item(object):
|
||||||
for line in raw:
|
for line in raw:
|
||||||
if line.startswith(u'UID:'):
|
if line.startswith(u'UID:'):
|
||||||
self.uid = line[4:].strip()
|
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)
|
self.raw = u'\n'.join(raw)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ def split_collection(text):
|
||||||
item.extend(timezone)
|
item.extend(timezone)
|
||||||
item.append(line)
|
item.append(line)
|
||||||
if item_type != u'VTIMEZONE':
|
if item_type != u'VTIMEZONE':
|
||||||
yield Item(u'\n'.join(item))
|
yield Item(u'\n'.join(item), needs_uid=False)
|
||||||
item = []
|
item = []
|
||||||
item_type = None
|
item_type = None
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue