fix deprecated calls
This commit is contained in:
parent
1655e64e0d
commit
47ee2170ce
5 changed files with 9 additions and 9 deletions
|
@ -43,4 +43,4 @@ class LogConfig(BaseModel):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dictConfig(LogConfig().dict())
|
dictConfig(LogConfig().model_dump())
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
Python representation of the "config.txt" file inside the WebDAV directory.
|
Python representation of the "config.txt" file inside the WebDAV directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import tomllib
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from tomllib import loads as toml_loads
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import tomli_w
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from tomli_w import dump as toml_dump
|
|
||||||
from webdav3.exceptions import RemoteResourceNotFound
|
from webdav3.exceptions import RemoteResourceNotFound
|
||||||
|
|
||||||
from .dav_common import caldav_list
|
from .dav_common import caldav_list
|
||||||
|
@ -119,7 +119,7 @@ class Config(BaseModel):
|
||||||
dav_file = DavFile(SETTINGS.config_path)
|
dav_file = DavFile(SETTINGS.config_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cfg = cls.parse_obj(toml_loads(await dav_file.as_string))
|
cfg = cls.model_validate(tomllib.loads(await dav_file.as_string))
|
||||||
|
|
||||||
except RemoteResourceNotFound:
|
except RemoteResourceNotFound:
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
|
@ -130,7 +130,7 @@ class Config(BaseModel):
|
||||||
cfg.calendar.aggregates["All Events"] = list(await caldav_list())
|
cfg.calendar.aggregates["All Events"] = list(await caldav_list())
|
||||||
|
|
||||||
buffer = BytesIO()
|
buffer = BytesIO()
|
||||||
toml_dump(cfg.dict(), buffer)
|
tomli_w.dump(cfg.model_dump(), buffer)
|
||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
await dav_file.write(buffer.read())
|
await dav_file.write(buffer.read())
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CalEvent(BaseModel):
|
||||||
Compare all properties.
|
Compare all properties.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.dict() == other.dict()
|
return self.model_dump() == other.model_dump()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_vevent(cls, event: Component) -> "CalEvent":
|
def from_vevent(cls, event: Component) -> "CalEvent":
|
||||||
|
@ -101,7 +101,7 @@ class CalEvent(BaseModel):
|
||||||
|
|
||||||
del data["duration"]
|
del data["duration"]
|
||||||
|
|
||||||
return cls.parse_obj(data)
|
return cls.model_validate(data)
|
||||||
|
|
||||||
|
|
||||||
@AsyncTTL(time_to_live=SETTINGS.cache_time, maxsize=SETTINGS.cache_size)
|
@AsyncTTL(time_to_live=SETTINGS.cache_time, maxsize=SETTINGS.cache_size)
|
||||||
|
|
|
@ -57,7 +57,7 @@ class FileNameLister:
|
||||||
async def remote_path(self) -> str:
|
async def remote_path(self) -> str:
|
||||||
cfg = await Config.get()
|
cfg = await Config.get()
|
||||||
|
|
||||||
return str(cfg.dict()[self.path_name])
|
return str(cfg.model_dump()[self.path_name])
|
||||||
|
|
||||||
async def __call__(self) -> Iterator[str]:
|
async def __call__(self) -> Iterator[str]:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -94,7 +94,7 @@ class Settings(BaseSettings):
|
||||||
host="example.com",
|
host="example.com",
|
||||||
username="ovdashboard",
|
username="ovdashboard",
|
||||||
password="secret",
|
password="secret",
|
||||||
).dict()
|
).model_dump()
|
||||||
|
|
||||||
for key in default_dav:
|
for key in default_dav:
|
||||||
# if "webdav" value is not specified, use default
|
# if "webdav" value is not specified, use default
|
||||||
|
|
Loading…
Reference in a new issue