nicer imports
This commit is contained in:
parent
77ee7c22e3
commit
955aadfc86
1 changed files with 8 additions and 6 deletions
|
@ -1,13 +1,15 @@
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import caldav
|
from caldav import DAVClient as CalDAVclient
|
||||||
from webdav3 import client as WebDAVclient
|
from caldav import Principal as CalDAVPrincipal
|
||||||
|
from webdav3.client import Client as WebDAVclient
|
||||||
|
from webdav3.client import Resource as WebDAVResource
|
||||||
|
|
||||||
from .async_helpers import run_in_executor
|
from .async_helpers import run_in_executor
|
||||||
from .settings import SETTINGS
|
from .settings import SETTINGS
|
||||||
|
|
||||||
_WEBDAV_CLIENT = WebDAVclient.Client({
|
_WEBDAV_CLIENT = WebDAVclient({
|
||||||
"webdav_hostname": SETTINGS.webdav_url,
|
"webdav_hostname": SETTINGS.webdav_url,
|
||||||
"webdav_login": SETTINGS.dav_username,
|
"webdav_login": SETTINGS.dav_username,
|
||||||
"webdav_password": SETTINGS.dav_password,
|
"webdav_password": SETTINGS.dav_password,
|
||||||
|
@ -15,7 +17,7 @@ _WEBDAV_CLIENT = WebDAVclient.Client({
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def webdav_resource(remote_path: Any) -> WebDAVclient.Resource:
|
def webdav_resource(remote_path: Any) -> WebDAVResource:
|
||||||
return _WEBDAV_CLIENT.resource(remote_path)
|
return _WEBDAV_CLIENT.resource(remote_path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,12 +26,12 @@ def webdav_list(remote_path: str) -> list:
|
||||||
return _WEBDAV_CLIENT.list(remote_path)
|
return _WEBDAV_CLIENT.list(remote_path)
|
||||||
|
|
||||||
|
|
||||||
_CALDAV_CLIENT = caldav.DAVClient(
|
_CALDAV_CLIENT = CalDAVclient(
|
||||||
url=SETTINGS.caldav_url,
|
url=SETTINGS.caldav_url,
|
||||||
username=SETTINGS.dav_username,
|
username=SETTINGS.dav_username,
|
||||||
password=SETTINGS.dav_password,
|
password=SETTINGS.dav_password,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def caldav_principal() -> caldav.Principal:
|
def caldav_principal() -> CalDAVPrincipal:
|
||||||
return _CALDAV_CLIENT.principal()
|
return _CALDAV_CLIENT.principal()
|
||||||
|
|
Loading…
Reference in a new issue