mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-31 09:55:55 +00:00
Use cached_property from the stdlib
Our local implementation preceded the one in the stdlib, but we no longer support versions of Python which do not ship it.
This commit is contained in:
parent
ed88406aec
commit
aab70e9fb0
4 changed files with 4 additions and 21 deletions
|
|
@ -4,6 +4,7 @@ import json
|
|||
import os
|
||||
import string
|
||||
from configparser import RawConfigParser
|
||||
from functools import cached_property
|
||||
from itertools import chain
|
||||
from typing import IO
|
||||
from typing import Any
|
||||
|
|
@ -11,7 +12,6 @@ from typing import Generator
|
|||
|
||||
from vdirsyncer import PROJECT_HOME
|
||||
from vdirsyncer import exceptions
|
||||
from vdirsyncer.utils import cached_property
|
||||
from vdirsyncer.utils import expand_path
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import logging
|
|||
import urllib.parse as urlparse
|
||||
import xml.etree.ElementTree as etree
|
||||
from abc import abstractmethod
|
||||
from functools import cached_property
|
||||
from inspect import getfullargspec
|
||||
from inspect import signature
|
||||
|
||||
|
|
@ -390,7 +391,7 @@ class DAVSession:
|
|||
self.url = url.rstrip("/") + "/"
|
||||
self.connector = connector
|
||||
|
||||
@utils.cached_property
|
||||
@cached_property
|
||||
def parsed_url(self):
|
||||
return urlparse.urlparse(self.url)
|
||||
|
||||
|
|
|
|||
|
|
@ -145,24 +145,6 @@ def checkfile(path, create=False) -> None:
|
|||
raise exceptions.CollectionNotFound(f"File {path} does not exist.")
|
||||
|
||||
|
||||
class cached_property:
|
||||
"""A read-only @property that is only evaluated once. Only usable on class
|
||||
instances' methods.
|
||||
"""
|
||||
|
||||
def __init__(self, fget, doc=None):
|
||||
self.__name__ = fget.__name__
|
||||
self.__module__ = fget.__module__
|
||||
self.__doc__ = doc or fget.__doc__
|
||||
self.fget = fget
|
||||
|
||||
def __get__(self, obj, cls):
|
||||
if obj is None: # pragma: no cover
|
||||
return self
|
||||
obj.__dict__[self.__name__] = result = self.fget(obj)
|
||||
return result
|
||||
|
||||
|
||||
def href_safe(ident, safe=SAFE_UID_CHARS):
|
||||
return not bool(set(ident) - set(safe))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
from functools import cached_property
|
||||
from itertools import chain
|
||||
from itertools import tee
|
||||
|
||||
from .utils import cached_property
|
||||
from .utils import uniq
|
||||
|
||||
IGNORE_PROPS = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue