mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
ac3fd8d7fc
commit
6f4ff7aab1
7 changed files with 29 additions and 29 deletions
|
|
@ -138,9 +138,9 @@ Supported Storages
|
||||||
CalDAV and CardDAV
|
CalDAV and CardDAV
|
||||||
++++++++++++++++++
|
++++++++++++++++++
|
||||||
|
|
||||||
.. autostorage:: vdirsyncer.storage.dav.CaldavStorage
|
.. autostorage:: vdirsyncer.storage.dav.CalDAVStorage
|
||||||
|
|
||||||
.. autostorage:: vdirsyncer.storage.dav.CarddavStorage
|
.. autostorage:: vdirsyncer.storage.dav.CardDAVStorage
|
||||||
|
|
||||||
Google
|
Google
|
||||||
++++++
|
++++++
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ dav_server = os.environ['DAV_SERVER']
|
||||||
ServerMixin = get_server_mixin(dav_server)
|
ServerMixin = get_server_mixin(dav_server)
|
||||||
|
|
||||||
|
|
||||||
class DavStorageTests(ServerMixin, StorageTests):
|
class DAVStorageTests(ServerMixin, StorageTests):
|
||||||
dav_server = dav_server
|
dav_server = dav_server
|
||||||
|
|
||||||
def test_dav_broken_item(self, s):
|
def test_dav_broken_item(self, s):
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ import requests.exceptions
|
||||||
from tests import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE
|
from tests import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE
|
||||||
|
|
||||||
from vdirsyncer import exceptions
|
from vdirsyncer import exceptions
|
||||||
from vdirsyncer.storage.dav import CaldavStorage
|
from vdirsyncer.storage.dav import CalDAVStorage
|
||||||
|
|
||||||
from . import DavStorageTests, dav_server
|
from . import DAVStorageTests, dav_server
|
||||||
from .. import format_item
|
from .. import format_item
|
||||||
|
|
||||||
|
|
||||||
class TestCaldavStorage(DavStorageTests):
|
class TestCalDAVStorage(DAVStorageTests):
|
||||||
storage_class = CaldavStorage
|
storage_class = CalDAVStorage
|
||||||
|
|
||||||
@pytest.fixture(params=['VTODO', 'VEVENT'])
|
@pytest.fixture(params=['VTODO', 'VEVENT'])
|
||||||
def item_type(self, request):
|
def item_type(self, request):
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from vdirsyncer.storage.dav import CarddavStorage
|
from vdirsyncer.storage.dav import CardDAVStorage
|
||||||
|
|
||||||
from . import DavStorageTests
|
from . import DAVStorageTests
|
||||||
|
|
||||||
|
|
||||||
class TestCarddavStorage(DavStorageTests):
|
class TestCardDAVStorage(DAVStorageTests):
|
||||||
storage_class = CarddavStorage
|
storage_class = CardDAVStorage
|
||||||
|
|
||||||
@pytest.fixture(params=['VCARD'])
|
@pytest.fixture(params=['VCARD'])
|
||||||
def item_type(self, request):
|
def item_type(self, request):
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ DISCOVERY_CACHE_VERSION = 1
|
||||||
class _StorageIndex(object):
|
class _StorageIndex(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._storages = dict(
|
self._storages = dict(
|
||||||
caldav='vdirsyncer.storage.dav.CaldavStorage',
|
caldav='vdirsyncer.storage.dav.CalDAVStorage',
|
||||||
carddav='vdirsyncer.storage.dav.CarddavStorage',
|
carddav='vdirsyncer.storage.dav.CardDAVStorage',
|
||||||
filesystem='vdirsyncer.storage.filesystem.FilesystemStorage',
|
filesystem='vdirsyncer.storage.filesystem.FilesystemStorage',
|
||||||
http='vdirsyncer.storage.http.HttpStorage',
|
http='vdirsyncer.storage.http.HttpStorage',
|
||||||
singlefile='vdirsyncer.storage.singlefile.SingleFileStorage',
|
singlefile='vdirsyncer.storage.singlefile.SingleFileStorage',
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ class CardDiscover(Discover):
|
||||||
_well_known_uri = '/.well-known/carddav'
|
_well_known_uri = '/.well-known/carddav'
|
||||||
|
|
||||||
|
|
||||||
class DavSession(object):
|
class DAVSession(object):
|
||||||
'''
|
'''
|
||||||
A helper class to connect to DAV servers.
|
A helper class to connect to DAV servers.
|
||||||
'''
|
'''
|
||||||
|
|
@ -345,7 +345,7 @@ class DavSession(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class DavStorage(Storage):
|
class DAVStorage(Storage):
|
||||||
|
|
||||||
__doc__ = '''
|
__doc__ = '''
|
||||||
:param url: Base URL or an URL to a collection.
|
:param url: Base URL or an URL to a collection.
|
||||||
|
|
@ -367,8 +367,8 @@ class DavStorage(Storage):
|
||||||
get_multi_data_query = None
|
get_multi_data_query = None
|
||||||
# The Discover subclass to use
|
# The Discover subclass to use
|
||||||
discovery_class = None
|
discovery_class = None
|
||||||
# The DavSession class to use
|
# The DAVSession class to use
|
||||||
session_class = DavSession
|
session_class = DAVSession
|
||||||
|
|
||||||
_repr_attributes = ('username', 'url')
|
_repr_attributes = ('username', 'url')
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ class DavStorage(Storage):
|
||||||
|
|
||||||
self.session, kwargs = \
|
self.session, kwargs = \
|
||||||
self.session_class.init_and_remaining_args(**kwargs)
|
self.session_class.init_and_remaining_args(**kwargs)
|
||||||
super(DavStorage, self).__init__(**kwargs)
|
super(DAVStorage, self).__init__(**kwargs)
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
__init__.__signature__ = inspect.signature(session_class.__init__)
|
__init__.__signature__ = inspect.signature(session_class.__init__)
|
||||||
|
|
@ -659,7 +659,7 @@ class DavStorage(Storage):
|
||||||
# a PROPFIND to see if the value got actually set.
|
# a PROPFIND to see if the value got actually set.
|
||||||
|
|
||||||
|
|
||||||
class CaldavStorage(DavStorage):
|
class CalDAVStorage(DAVStorage):
|
||||||
|
|
||||||
__doc__ = '''
|
__doc__ = '''
|
||||||
CalDAV.
|
CalDAV.
|
||||||
|
|
@ -688,7 +688,7 @@ class CaldavStorage(DavStorage):
|
||||||
:param item_types: Kind of items to show. The default, the empty list, is
|
:param item_types: Kind of items to show. The default, the empty list, is
|
||||||
to show all. This depends on particular features on the server, the
|
to show all. This depends on particular features on the server, the
|
||||||
results are not validated.
|
results are not validated.
|
||||||
''' + DavStorage.__doc__
|
''' + DAVStorage.__doc__
|
||||||
|
|
||||||
storage_name = 'caldav'
|
storage_name = 'caldav'
|
||||||
fileext = '.ics'
|
fileext = '.ics'
|
||||||
|
|
@ -710,14 +710,14 @@ class CaldavStorage(DavStorage):
|
||||||
|
|
||||||
get_multi_data_query = '{urn:ietf:params:xml:ns:caldav}calendar-data'
|
get_multi_data_query = '{urn:ietf:params:xml:ns:caldav}calendar-data'
|
||||||
|
|
||||||
_property_table = dict(DavStorage._property_table)
|
_property_table = dict(DAVStorage._property_table)
|
||||||
_property_table.update({
|
_property_table.update({
|
||||||
'color': ('calendar-color', 'http://apple.com/ns/ical/'),
|
'color': ('calendar-color', 'http://apple.com/ns/ical/'),
|
||||||
})
|
})
|
||||||
|
|
||||||
def __init__(self, start_date=None, end_date=None,
|
def __init__(self, start_date=None, end_date=None,
|
||||||
item_types=(), **kwargs):
|
item_types=(), **kwargs):
|
||||||
super(CaldavStorage, self).__init__(**kwargs)
|
super(CalDAVStorage, self).__init__(**kwargs)
|
||||||
if not isinstance(item_types, (list, tuple)):
|
if not isinstance(item_types, (list, tuple)):
|
||||||
raise exceptions.UserError('item_types must be a list.')
|
raise exceptions.UserError('item_types must be a list.')
|
||||||
|
|
||||||
|
|
@ -761,7 +761,7 @@ class CaldavStorage(DavStorage):
|
||||||
timefilter=timefilter)
|
timefilter=timefilter)
|
||||||
else:
|
else:
|
||||||
if start is not None and end is not None:
|
if start is not None and end is not None:
|
||||||
for x in CaldavStorage._get_list_filters(('VTODO', 'VEVENT'),
|
for x in CalDAVStorage._get_list_filters(('VTODO', 'VEVENT'),
|
||||||
start, end):
|
start, end):
|
||||||
yield x
|
yield x
|
||||||
|
|
||||||
|
|
@ -779,7 +779,7 @@ class CaldavStorage(DavStorage):
|
||||||
# instead?
|
# instead?
|
||||||
#
|
#
|
||||||
# See https://github.com/dmfs/tasks/issues/118 for backstory.
|
# See https://github.com/dmfs/tasks/issues/118 for backstory.
|
||||||
for x in DavStorage.list(self):
|
for x in DAVStorage.list(self):
|
||||||
yield x
|
yield x
|
||||||
|
|
||||||
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
@ -811,11 +811,11 @@ class CaldavStorage(DavStorage):
|
||||||
yield href, etag
|
yield href, etag
|
||||||
|
|
||||||
|
|
||||||
class CarddavStorage(DavStorage):
|
class CardDAVStorage(DAVStorage):
|
||||||
|
|
||||||
__doc__ = '''
|
__doc__ = '''
|
||||||
CardDAV.
|
CardDAV.
|
||||||
''' + DavStorage.__doc__
|
''' + DAVStorage.__doc__
|
||||||
|
|
||||||
storage_name = 'carddav'
|
storage_name = 'carddav'
|
||||||
fileext = '.vcf'
|
fileext = '.vcf'
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ except ImportError:
|
||||||
have_oauth2 = False
|
have_oauth2 = False
|
||||||
|
|
||||||
|
|
||||||
class GoogleSession(dav.DavSession):
|
class GoogleSession(dav.DAVSession):
|
||||||
def __init__(self, token_file, client_id, client_secret, url=None):
|
def __init__(self, token_file, client_id, client_secret, url=None):
|
||||||
# Required for discovering collections
|
# Required for discovering collections
|
||||||
if url is not None:
|
if url is not None:
|
||||||
|
|
@ -101,7 +101,7 @@ GOOGLE_PARAMS_DOCS = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
class GoogleCalendarStorage(dav.CaldavStorage):
|
class GoogleCalendarStorage(dav.CalDAVStorage):
|
||||||
__doc__ = '''Google calendar.
|
__doc__ = '''Google calendar.
|
||||||
|
|
||||||
Please refer to :storage:`caldav` regarding
|
Please refer to :storage:`caldav` regarding
|
||||||
|
|
@ -142,7 +142,7 @@ class GoogleCalendarStorage(dav.CaldavStorage):
|
||||||
__init__._traverse_superclass = base.Storage
|
__init__._traverse_superclass = base.Storage
|
||||||
|
|
||||||
|
|
||||||
class GoogleContactsStorage(dav.CarddavStorage):
|
class GoogleContactsStorage(dav.CardDAVStorage):
|
||||||
__doc__ = '''Google contacts.
|
__doc__ = '''Google contacts.
|
||||||
|
|
||||||
.. note:: Google's CardDAV implementation is allegedly a disaster in terms
|
.. note:: Google's CardDAV implementation is allegedly a disaster in terms
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue