mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix some imports
This commit is contained in:
parent
38e89cea55
commit
bb579a8879
14 changed files with 64 additions and 51 deletions
|
|
@ -6,14 +6,15 @@
|
||||||
:copyright: (c) 2014 Markus Unterwaditzer
|
:copyright: (c) 2014 Markus Unterwaditzer
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from vdirsyncer.storage.base import Item
|
|
||||||
import vdirsyncer.exceptions as exceptions
|
|
||||||
from vdirsyncer.utils import text_type
|
|
||||||
from .. import assert_item_equals
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from .. import assert_item_equals
|
||||||
|
import vdirsyncer.exceptions as exceptions
|
||||||
|
from vdirsyncer.storage.base import Item
|
||||||
|
from vdirsyncer.utils import text_type
|
||||||
|
|
||||||
|
|
||||||
class StorageTests(object):
|
class StorageTests(object):
|
||||||
item_template = u'UID:{uid}\nX-SOMETHING:{r}'
|
item_template = u'UID:{uid}\nX-SOMETHING:{r}'
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from vdirsyncer.utils import urlparse
|
|
||||||
|
|
||||||
from werkzeug.test import Client
|
from werkzeug.test import Client
|
||||||
from werkzeug.wrappers import BaseResponse as WerkzeugResponse
|
from werkzeug.wrappers import BaseResponse as WerkzeugResponse
|
||||||
|
|
||||||
|
from vdirsyncer.utils import urlparse
|
||||||
|
|
||||||
|
|
||||||
RADICALE_SCHEMA = '''
|
RADICALE_SCHEMA = '''
|
||||||
create table collection (
|
create table collection (
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,19 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
|
||||||
import pytest
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import requests.exceptions
|
||||||
|
|
||||||
from .. import StorageTests
|
from .. import StorageTests
|
||||||
import vdirsyncer.exceptions as exceptions
|
import vdirsyncer.exceptions as exceptions
|
||||||
from vdirsyncer.storage.base import Item
|
from vdirsyncer.storage.base import Item
|
||||||
from vdirsyncer.storage.dav import CaldavStorage, CarddavStorage
|
from vdirsyncer.storage.dav import CaldavStorage, CarddavStorage
|
||||||
import vdirsyncer.exceptions
|
|
||||||
import requests
|
|
||||||
import requests.exceptions
|
|
||||||
|
|
||||||
|
|
||||||
dav_server = os.environ.get('DAV_SERVER', '').strip() or 'radicale'
|
dav_server = os.environ.get('DAV_SERVER', '').strip() or 'radicale'
|
||||||
|
|
@ -239,7 +240,7 @@ class TestCaldavStorage(DavStorageTests):
|
||||||
|
|
||||||
monkeypatch.setattr('requests.sessions.Session.request', request)
|
monkeypatch.setattr('requests.sessions.Session.request', request)
|
||||||
|
|
||||||
with pytest.raises(vdirsyncer.exceptions.StorageError):
|
with pytest.raises(exceptions.StorageError):
|
||||||
self.storage_class(**args)
|
self.storage_class(**args)
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,12 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import pytest
|
|
||||||
import os
|
import os
|
||||||
from vdirsyncer.storage.filesystem import FilesystemStorage
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from . import StorageTests
|
from . import StorageTests
|
||||||
|
from vdirsyncer.storage.filesystem import FilesystemStorage
|
||||||
|
|
||||||
|
|
||||||
class TestFilesystemStorage(StorageTests):
|
class TestFilesystemStorage(StorageTests):
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,10 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from vdirsyncer.storage.http import HttpStorage, split_collection
|
|
||||||
from requests import Response
|
from requests import Response
|
||||||
|
|
||||||
|
from vdirsyncer.storage.http import HttpStorage, split_collection
|
||||||
|
|
||||||
|
|
||||||
def test_split_collection_timezones():
|
def test_split_collection_timezones():
|
||||||
items = [
|
items = [
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from vdirsyncer.storage.memory import MemoryStorage
|
|
||||||
from . import StorageTests
|
from . import StorageTests
|
||||||
|
from vdirsyncer.storage.memory import MemoryStorage
|
||||||
|
|
||||||
|
|
||||||
class TestMemoryStorage(StorageTests):
|
class TestMemoryStorage(StorageTests):
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,12 @@
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from . import assert_item_equals, normalize_item
|
||||||
|
import vdirsyncer.exceptions as exceptions
|
||||||
from vdirsyncer.storage.base import Item
|
from vdirsyncer.storage.base import Item
|
||||||
from vdirsyncer.storage.memory import MemoryStorage
|
from vdirsyncer.storage.memory import MemoryStorage
|
||||||
from vdirsyncer.sync import sync
|
from vdirsyncer.sync import sync
|
||||||
from . import assert_item_equals, normalize_item
|
|
||||||
import vdirsyncer.exceptions as exceptions
|
|
||||||
|
|
||||||
|
|
||||||
def empty_storage(x):
|
def empty_storage(x):
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,19 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
from vdirsyncer.sync import sync
|
|
||||||
from vdirsyncer.utils import expand_path, split_dict, parse_options
|
|
||||||
from vdirsyncer.storage import storage_names
|
|
||||||
import vdirsyncer.log as log
|
|
||||||
import vdirsyncer.exceptions as exceptions
|
|
||||||
import argvard
|
import argvard
|
||||||
|
|
||||||
|
from .storage import storage_names
|
||||||
|
from .sync import sync
|
||||||
|
from .utils import expand_path, parse_options, split_dict
|
||||||
|
|
||||||
|
import vdirsyncer.exceptions as exceptions
|
||||||
|
import vdirsyncer.log as log
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ConfigParser import RawConfigParser
|
from ConfigParser import RawConfigParser
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from .dav import CaldavStorage
|
from .dav import CarddavStorage, CaldavStorage
|
||||||
from .dav import CarddavStorage
|
|
||||||
from .filesystem import FilesystemStorage
|
from .filesystem import FilesystemStorage
|
||||||
from .http import HttpStorage
|
from .http import HttpStorage
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,17 @@
|
||||||
:copyright: (c) 2014 Markus Unterwaditzer, Christian Geier and contributors
|
:copyright: (c) 2014 Markus Unterwaditzer, Christian Geier and contributors
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from .base import Storage, Item
|
|
||||||
from .http import prepare_auth, prepare_verify, USERAGENT
|
|
||||||
from .. import exceptions
|
|
||||||
from .. import log
|
|
||||||
from ..utils import request, get_password, urlparse
|
|
||||||
import requests
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from .base import Item, Storage
|
||||||
|
from .http import prepare_auth, prepare_verify, USERAGENT
|
||||||
|
|
||||||
|
from .. import exceptions, log, utils
|
||||||
|
|
||||||
|
|
||||||
dav_logger = log.get(__name__)
|
dav_logger = log.get(__name__)
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ class DavStorage(Storage):
|
||||||
super(DavStorage, self).__init__(**kwargs)
|
super(DavStorage, self).__init__(**kwargs)
|
||||||
|
|
||||||
if username and not password:
|
if username and not password:
|
||||||
password = get_password(username, url)
|
password = utils.get_password(username, url)
|
||||||
|
|
||||||
self._settings = {
|
self._settings = {
|
||||||
'verify': prepare_verify(verify),
|
'verify': prepare_verify(verify),
|
||||||
|
|
@ -69,9 +70,9 @@ class DavStorage(Storage):
|
||||||
|
|
||||||
url = url.rstrip('/') + '/'
|
url = url.rstrip('/') + '/'
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
url = urlparse.urljoin(url, collection)
|
url = utils.urlparse.urljoin(url, collection)
|
||||||
self.url = url.rstrip('/') + '/'
|
self.url = url.rstrip('/') + '/'
|
||||||
self.parsed_url = urlparse.urlparse(self.url)
|
self.parsed_url = utils.urlparse.urlparse(self.url)
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
|
|
||||||
headers = self._default_headers()
|
headers = self._default_headers()
|
||||||
|
|
@ -103,7 +104,7 @@ class DavStorage(Storage):
|
||||||
ssl_verify=kwargs.get('verify', True)
|
ssl_verify=kwargs.get('verify', True)
|
||||||
)
|
)
|
||||||
for c in d.discover():
|
for c in d.discover():
|
||||||
collection = urlparse.urljoin(url, c['href'])
|
collection = utils.urlparse.urljoin(url, c['href'])
|
||||||
if collection.startswith(url):
|
if collection.startswith(url):
|
||||||
collection = collection[len(url):]
|
collection = collection[len(url):]
|
||||||
collection = collection.rstrip('/')
|
collection = collection.rstrip('/')
|
||||||
|
|
@ -114,9 +115,9 @@ class DavStorage(Storage):
|
||||||
def _normalize_href(self, href):
|
def _normalize_href(self, href):
|
||||||
'''Normalize the href to be a path only relative to hostname and
|
'''Normalize the href to be a path only relative to hostname and
|
||||||
schema.'''
|
schema.'''
|
||||||
x = urlparse.urljoin(self.url, href)
|
x = utils.urlparse.urljoin(self.url, href)
|
||||||
assert x.startswith(self.url)
|
assert x.startswith(self.url)
|
||||||
return urlparse.urlsplit(x).path
|
return utils.urlparse.urlsplit(x).path
|
||||||
|
|
||||||
def _get_href(self, uid):
|
def _get_href(self, uid):
|
||||||
return self._normalize_href(super(DavStorage, self)._get_href(uid))
|
return self._normalize_href(super(DavStorage, self)._get_href(uid))
|
||||||
|
|
@ -127,8 +128,8 @@ class DavStorage(Storage):
|
||||||
if self._session is None:
|
if self._session is None:
|
||||||
self._session = requests.session()
|
self._session = requests.session()
|
||||||
url = self.parsed_url.scheme + '://' + self.parsed_url.netloc + path
|
url = self.parsed_url.scheme + '://' + self.parsed_url.netloc + path
|
||||||
return request(method, url, data=data, headers=headers,
|
return utils.request(method, url, data=data, headers=headers,
|
||||||
session=self._session, **self._settings)
|
session=self._session, **self._settings)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _check_response(response):
|
def _check_response(response):
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,12 @@
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from vdirsyncer.storage.base import Storage, Item
|
|
||||||
|
from .base import Item, Storage
|
||||||
import vdirsyncer.exceptions as exceptions
|
import vdirsyncer.exceptions as exceptions
|
||||||
from vdirsyncer.utils import expand_path, text_type
|
|
||||||
import vdirsyncer.log as log
|
import vdirsyncer.log as log
|
||||||
|
from vdirsyncer.utils import expand_path, text_type
|
||||||
|
|
||||||
logger = log.get(__name__)
|
logger = log.get(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
from .base import Storage, Item
|
|
||||||
from vdirsyncer.utils import expand_path, get_password, request, urlparse, \
|
from .base import Item, Storage
|
||||||
text_type
|
from ..utils import expand_path, get_password, request, text_type, urlparse
|
||||||
|
|
||||||
USERAGENT = 'vdirsyncer'
|
USERAGENT = 'vdirsyncer'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import random
|
import random
|
||||||
from vdirsyncer.storage.base import Storage
|
|
||||||
import vdirsyncer.exceptions as exceptions
|
import vdirsyncer.exceptions as exceptions
|
||||||
|
from vdirsyncer.storage.base import Storage
|
||||||
|
|
||||||
|
|
||||||
def _get_etag():
|
def _get_etag():
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,9 @@
|
||||||
'''
|
'''
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import vdirsyncer.exceptions as exceptions
|
from . import exceptions, log
|
||||||
import vdirsyncer.log
|
|
||||||
from .utils import iteritems, itervalues
|
from .utils import iteritems, itervalues
|
||||||
sync_logger = vdirsyncer.log.get(__name__)
|
sync_logger = log.get(__name__)
|
||||||
|
|
||||||
|
|
||||||
def prepare_list(storage, href_to_status):
|
def prepare_list(storage, href_to_status):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue