This commit is contained in:
Markus Unterwaditzer 2014-03-01 21:42:21 +01:00
parent aa7d2f3eeb
commit dce98d2fed
7 changed files with 14 additions and 16 deletions

View file

@ -146,7 +146,7 @@ def _main(env, file_cfg):
sys.exit(1)
a = storage_instance_from_config(all_storages[a])
b = storage_instance_from_config(all_storages[b])
def x(a=a, b=b, pair_name=pair_name):
cli_logger.debug('Syncing {}'.format(pair_name))
status = load_status(general['status_path'], pair_name)

View file

@ -31,7 +31,8 @@ class Storage(object):
Terminology:
- UID: Global identifier of the item, across storages.
- HREF: Per-storage identifier of item, might be UID.
- ETAG: Checksum of item, or something similar that changes when the object does
- ETAG: Checksum of item, or something similar that changes when the
object does.
'''
fileext = '.txt'
_repr_attributes = set()

View file

@ -39,7 +39,8 @@ class CaldavStorage(Storage):
:param start_date: Start date of timerange to show, default -inf.
:param end_date: End date of timerange to show, default +inf.
:param verify: Verify SSL certificate, default True.
:param auth: Authentication method, from {'basic', 'digest'}, default 'basic'.
:param auth: Authentication method, from {'basic', 'digest'}, default
'basic'.
:param useragent: Default 'vdirsyncer'.
:param _request_func: Function to use for network calls. Same API as
requests.request. Useful for tests.
@ -80,7 +81,7 @@ class CaldavStorage(Storage):
headers=headers
)
response.raise_for_status()
if 'DAV' not in response.headers or 'calendar-access' not in response.headers['DAV']:
if 'calendar-access' not in response.headers.get('DAV', ''):
raise exceptions.StorageError('URL is not a CalDAV collection')
def _default_headers(self):
@ -101,7 +102,8 @@ class CaldavStorage(Storage):
self._session = requests.session()
assert '/' not in item
url = self.url + item
return self._session.request(method, url, data=data, headers=headers, **self._settings)
return self._session.request(method, url, data=data, headers=headers,
**self._settings)
@staticmethod
def _check_response(response):
@ -184,8 +186,8 @@ class CaldavStorage(Storage):
.find('{urn:ietf:params:xml:ns:caldav}calendar-data').text
etag = element \
.find('{DAV:}propstat') \
.find('{DAV:}prop') \
.find('{DAV:}getetag').text
.find('{DAV:}prop') \
.find('{DAV:}getetag').text
if isinstance(obj, bytes):
obj = obj.decode(response.encoding)
if isinstance(etag, bytes):

View file

@ -45,7 +45,8 @@ class FilesystemStorage(Storage):
def get(self, href):
fpath = self._get_filepath(href)
with open(fpath, 'rb') as f:
return Item(f.read().decode(self.encoding)), os.path.getmtime(fpath)
return (Item(f.read().decode(self.encoding)),
os.path.getmtime(fpath))
def has(self, href):
return os.path.isfile(self._get_filepath(href))

View file

@ -8,7 +8,7 @@
'''
import datetime
from vdirsyncer.storage.base import Item, Storage
from vdirsyncer.storage.base import Storage
import vdirsyncer.exceptions as exceptions

View file

@ -8,14 +8,7 @@
'''
__version__ = '0.1.0'
from unittest import TestCase
import os
import tempfile
import shutil
from vdirsyncer.storage.base import Item
from vdirsyncer.storage.filesystem import FilesystemStorage
from vdirsyncer.storage.memory import MemoryStorage
from vdirsyncer.storage.caldav import CaldavStorage
import vdirsyncer.exceptions as exceptions

View file

@ -9,6 +9,7 @@
import os
def expand_path(p):
p = os.path.expanduser(p)
p = os.path.abspath(p)