mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Simplify some statements
This commit is contained in:
parent
6da84c7881
commit
9677cf9812
8 changed files with 19 additions and 24 deletions
|
|
@ -64,6 +64,7 @@ extend-select = [
|
|||
"E",
|
||||
"I",
|
||||
"RSE",
|
||||
"SIM",
|
||||
"TID",
|
||||
"UP",
|
||||
"W",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import datetime
|
||||
from textwrap import dedent
|
||||
|
||||
|
|
@ -30,11 +31,9 @@ class TestCalDAVStorage(DAVStorageTests):
|
|||
async def test_doesnt_accept_vcard(self, item_type, get_storage_args):
|
||||
s = self.storage_class(item_types=(item_type,), **await get_storage_args())
|
||||
|
||||
try:
|
||||
# Most storages hard-fail, but xandikos doesn't.
|
||||
with contextlib.suppress(exceptions.Error, aiohttp.ClientResponseError):
|
||||
await s.upload(format_item(VCARD_TEMPLATE))
|
||||
except (exceptions.Error, aiohttp.ClientResponseError):
|
||||
# Most storages hard-fail, but xandikos doesn't.
|
||||
pass
|
||||
|
||||
assert not await aiostream.stream.list(s.list())
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ import pytest
|
|||
class ServerMixin:
|
||||
@pytest.fixture
|
||||
def get_storage_args(self, slow_create_collection, aio_connector, request):
|
||||
if "item_type" in request.fixturenames:
|
||||
if request.getfixturevalue("item_type") == "VTODO":
|
||||
# Fastmail has non-standard support for TODOs
|
||||
# See https://github.com/pimutils/vdirsyncer/issues/824
|
||||
pytest.skip("Fastmail has non-standard VTODO support.")
|
||||
if (
|
||||
"item_type" in request.fixturenames
|
||||
and request.getfixturevalue("item_type") == "VTODO"
|
||||
):
|
||||
# Fastmail has non-standard support for TODOs
|
||||
# See https://github.com/pimutils/vdirsyncer/issues/824
|
||||
pytest.skip("Fastmail has non-standard VTODO support.")
|
||||
|
||||
async def inner(collection="test"):
|
||||
args = {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class CombinedStorage(Storage):
|
|||
storage_name = "http_and_singlefile"
|
||||
|
||||
def __init__(self, url, path, *, connector, **kwargs):
|
||||
if kwargs.get("collection", None) is not None:
|
||||
if kwargs.get("collection") is not None:
|
||||
raise ValueError
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
|
|
|||
|
|
@ -642,10 +642,7 @@ class SyncMachine(RuleBasedStateMachine):
|
|||
|
||||
errors = []
|
||||
|
||||
if with_error_callback:
|
||||
error_callback = errors.append
|
||||
else:
|
||||
error_callback = None
|
||||
error_callback = errors.append if with_error_callback else None
|
||||
|
||||
try:
|
||||
# If one storage is read-only, double-sync because changes don't
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ async def request(
|
|||
logger.debug("=" * 20)
|
||||
logger.debug(f"{method} {url}")
|
||||
logger.debug(kwargs.get("headers", {}))
|
||||
logger.debug(kwargs.get("data", None))
|
||||
logger.debug(kwargs.get("data"))
|
||||
logger.debug("Sending request...")
|
||||
|
||||
assert isinstance(kwargs.get("data", b""), bytes)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import datetime
|
||||
import logging
|
||||
import urllib.parse as urlparse
|
||||
|
|
@ -217,10 +218,8 @@ class Discover:
|
|||
|
||||
async def find_collections(self):
|
||||
rv = None
|
||||
try:
|
||||
with contextlib.suppress(aiohttp.ClientResponseError, exceptions.Error):
|
||||
rv = await aiostream.stream.list(self._find_collections_impl(""))
|
||||
except (aiohttp.ClientResponseError, exceptions.Error):
|
||||
pass
|
||||
|
||||
if rv:
|
||||
return rv
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
import os
|
||||
|
|
@ -65,9 +66,7 @@ class FilesystemStorage(Storage):
|
|||
def _validate_collection(cls, path):
|
||||
if not os.path.isdir(path):
|
||||
return False
|
||||
if os.path.basename(path).startswith("."):
|
||||
return False
|
||||
return True
|
||||
return not os.path.basename(path).startswith(".")
|
||||
|
||||
@classmethod
|
||||
async def create_collection(cls, collection, **kwargs):
|
||||
|
|
@ -205,10 +204,8 @@ class FilesystemStorage(Storage):
|
|||
|
||||
fpath = os.path.join(self.path, key)
|
||||
if value is None:
|
||||
try:
|
||||
with contextlib.suppress(OSError):
|
||||
os.remove(fpath)
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
with atomic_write(fpath, mode="wb", overwrite=True) as f:
|
||||
f.write(value.encode(self.encoding))
|
||||
|
|
|
|||
Loading…
Reference in a new issue