mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Move Item to utils
This commit is contained in:
parent
7d26f7f8fd
commit
41848b2432
2 changed files with 35 additions and 33 deletions
|
|
@ -10,41 +10,9 @@
|
||||||
|
|
||||||
from .. import exceptions
|
from .. import exceptions
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from ..utils.compat import text_type
|
|
||||||
|
|
||||||
|
|
||||||
class Item(object):
|
Item = utils.vobject.Item
|
||||||
|
|
||||||
'''should-be-immutable wrapper class for VCALENDAR (VEVENT, VTODO) and
|
|
||||||
VCARD'''
|
|
||||||
|
|
||||||
uid = None
|
|
||||||
'''Global identifier of the item, across storages, doesn't change after a
|
|
||||||
modification of the item.'''
|
|
||||||
|
|
||||||
raw = None
|
|
||||||
'''Raw content of the item, which vdirsyncer doesn't validate in any
|
|
||||||
way.'''
|
|
||||||
|
|
||||||
hash = None
|
|
||||||
'''Hash of self.raw, used for etags.'''
|
|
||||||
|
|
||||||
ident = None
|
|
||||||
'''Used for generating hrefs and matching up items during synchronization.
|
|
||||||
This is either the UID or the hash of the item's content.'''
|
|
||||||
|
|
||||||
def __init__(self, raw):
|
|
||||||
assert isinstance(raw, text_type)
|
|
||||||
|
|
||||||
for line in raw.splitlines():
|
|
||||||
if line.startswith(u'UID:'):
|
|
||||||
uid = line[4:].strip()
|
|
||||||
if uid:
|
|
||||||
self.uid = uid
|
|
||||||
|
|
||||||
self.raw = raw
|
|
||||||
self.hash = utils.vobject.hash_item(raw)
|
|
||||||
self.ident = self.uid or self.hash
|
|
||||||
|
|
||||||
|
|
||||||
class Storage(object):
|
class Storage(object):
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,40 @@ ICALENDAR_ORIGINAL_ORDER_SUPPORT = \
|
||||||
hasattr(icalendar.caselessdict.CaselessDict, '__reversed__')
|
hasattr(icalendar.caselessdict.CaselessDict, '__reversed__')
|
||||||
|
|
||||||
|
|
||||||
|
class Item(object):
|
||||||
|
|
||||||
|
'''should-be-immutable wrapper class for VCALENDAR (VEVENT, VTODO) and
|
||||||
|
VCARD'''
|
||||||
|
|
||||||
|
uid = None
|
||||||
|
'''Global identifier of the item, across storages, doesn't change after a
|
||||||
|
modification of the item.'''
|
||||||
|
|
||||||
|
raw = None
|
||||||
|
'''Raw content of the item, which vdirsyncer doesn't validate in any
|
||||||
|
way.'''
|
||||||
|
|
||||||
|
hash = None
|
||||||
|
'''Hash of self.raw, used for etags.'''
|
||||||
|
|
||||||
|
ident = None
|
||||||
|
'''Used for generating hrefs and matching up items during synchronization.
|
||||||
|
This is either the UID or the hash of the item's content.'''
|
||||||
|
|
||||||
|
def __init__(self, raw):
|
||||||
|
assert isinstance(raw, text_type)
|
||||||
|
|
||||||
|
for line in raw.splitlines():
|
||||||
|
if line.startswith(u'UID:'):
|
||||||
|
uid = line[4:].strip()
|
||||||
|
if uid:
|
||||||
|
self.uid = uid
|
||||||
|
|
||||||
|
self.raw = raw
|
||||||
|
self.hash = hash_item(raw)
|
||||||
|
self.ident = self.uid or self.hash
|
||||||
|
|
||||||
|
|
||||||
def normalize_item(text, ignore_props=IGNORE_PROPS, use_icalendar=True):
|
def normalize_item(text, ignore_props=IGNORE_PROPS, use_icalendar=True):
|
||||||
try:
|
try:
|
||||||
if not use_icalendar:
|
if not use_icalendar:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue