mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Flake8
This commit is contained in:
parent
aa7d2f3eeb
commit
dce98d2fed
7 changed files with 14 additions and 16 deletions
|
|
@ -31,7 +31,8 @@ class Storage(object):
|
||||||
Terminology:
|
Terminology:
|
||||||
- UID: Global identifier of the item, across storages.
|
- UID: Global identifier of the item, across storages.
|
||||||
- HREF: Per-storage identifier of item, might be UID.
|
- 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'
|
fileext = '.txt'
|
||||||
_repr_attributes = set()
|
_repr_attributes = set()
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ class CaldavStorage(Storage):
|
||||||
:param start_date: Start date of timerange to show, default -inf.
|
:param start_date: Start date of timerange to show, default -inf.
|
||||||
:param end_date: End 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 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 useragent: Default 'vdirsyncer'.
|
||||||
:param _request_func: Function to use for network calls. Same API as
|
:param _request_func: Function to use for network calls. Same API as
|
||||||
requests.request. Useful for tests.
|
requests.request. Useful for tests.
|
||||||
|
|
@ -80,7 +81,7 @@ class CaldavStorage(Storage):
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
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')
|
raise exceptions.StorageError('URL is not a CalDAV collection')
|
||||||
|
|
||||||
def _default_headers(self):
|
def _default_headers(self):
|
||||||
|
|
@ -101,7 +102,8 @@ class CaldavStorage(Storage):
|
||||||
self._session = requests.session()
|
self._session = requests.session()
|
||||||
assert '/' not in item
|
assert '/' not in item
|
||||||
url = self.url + 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
|
@staticmethod
|
||||||
def _check_response(response):
|
def _check_response(response):
|
||||||
|
|
@ -184,8 +186,8 @@ class CaldavStorage(Storage):
|
||||||
.find('{urn:ietf:params:xml:ns:caldav}calendar-data').text
|
.find('{urn:ietf:params:xml:ns:caldav}calendar-data').text
|
||||||
etag = element \
|
etag = element \
|
||||||
.find('{DAV:}propstat') \
|
.find('{DAV:}propstat') \
|
||||||
.find('{DAV:}prop') \
|
.find('{DAV:}prop') \
|
||||||
.find('{DAV:}getetag').text
|
.find('{DAV:}getetag').text
|
||||||
if isinstance(obj, bytes):
|
if isinstance(obj, bytes):
|
||||||
obj = obj.decode(response.encoding)
|
obj = obj.decode(response.encoding)
|
||||||
if isinstance(etag, bytes):
|
if isinstance(etag, bytes):
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ class FilesystemStorage(Storage):
|
||||||
def get(self, href):
|
def get(self, href):
|
||||||
fpath = self._get_filepath(href)
|
fpath = self._get_filepath(href)
|
||||||
with open(fpath, 'rb') as f:
|
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):
|
def has(self, href):
|
||||||
return os.path.isfile(self._get_filepath(href))
|
return os.path.isfile(self._get_filepath(href))
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from vdirsyncer.storage.base import Item, Storage
|
from vdirsyncer.storage.base import Storage
|
||||||
import vdirsyncer.exceptions as exceptions
|
import vdirsyncer.exceptions as exceptions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,7 @@
|
||||||
'''
|
'''
|
||||||
__version__ = '0.1.0'
|
__version__ = '0.1.0'
|
||||||
|
|
||||||
from unittest import TestCase
|
|
||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import shutil
|
|
||||||
from vdirsyncer.storage.base import Item
|
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
|
import vdirsyncer.exceptions as exceptions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def expand_path(p):
|
def expand_path(p):
|
||||||
p = os.path.expanduser(p)
|
p = os.path.expanduser(p)
|
||||||
p = os.path.abspath(p)
|
p = os.path.abspath(p)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue