Replace cached_property with the stdlib one

This commit is contained in:
Simon Conseil
2021-10-15 12:34:29 +02:00
parent b4f7be2199
commit 441388cf8f
3 changed files with 2 additions and 23 deletions

View File

@@ -33,6 +33,7 @@ import random
import sys
from collections import defaultdict
from datetime import datetime
from functools import cached_property
from itertools import cycle
from os.path import isfile, join, splitext
from urllib.parse import quote as url_quote
@@ -46,7 +47,6 @@ from .image import get_exif_tags, get_image_metadata, get_size, process_image
from .settings import Status, get_thumb
from .utils import (
Devnull,
cached_property,
check_or_create_dir,
copy,
get_mime,

View File

@@ -34,11 +34,11 @@ See :ref:`compatibility with the encrypt plugin <compatibility-with-encrypt>`.
import logging
import os
import zipfile
from functools import cached_property
from os.path import isfile, join
from sigal import signals
from sigal.gallery import Album
from sigal.utils import cached_property
logger = logging.getLogger(__name__)

View File

@@ -119,24 +119,3 @@ def is_valid_html5_video(ext):
def get_mime(ext):
"""Returns mime type for extension."""
return VIDEO_MIMES[ext]
class cached_property:
"""A property that is only computed once per instance and then replaces
itself with an ordinary attribute. Deleting the attribute resets the
property.
Source:
https://github.com/pydanny/cached-property (BSD Licensed)
https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
"""
def __init__(self, func):
self.__doc__ = getattr(func, '__doc__')
self.func = func
def __get__(self, obj, cls):
if obj is None:
return self
value = obj.__dict__[self.func.__name__] = self.func(obj)
return value