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