mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Lazy-load component in item
This commit is contained in:
parent
bdbfc360ff
commit
325304c50f
1 changed files with 6 additions and 3 deletions
|
|
@ -14,12 +14,15 @@ class Item(object):
|
|||
def __init__(self, raw, component=None):
|
||||
assert isinstance(raw, str), type(raw)
|
||||
self._raw = raw
|
||||
if component is not None:
|
||||
self.__dict__['_component'] = component
|
||||
|
||||
@cached_property
|
||||
def _component(self):
|
||||
try:
|
||||
self._component = component or \
|
||||
native.parse_component(self.raw.encode('utf-8'))
|
||||
return native.parse_component(self.raw.encode('utf-8'))
|
||||
except exceptions.VobjectParseError:
|
||||
self._component = None
|
||||
return None
|
||||
|
||||
def with_uid(self, new_uid):
|
||||
if not self._component:
|
||||
|
|
|
|||
Loading…
Reference in a new issue