aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/compat/functools.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2022-12-02 05:21:10 +0800
committerJesús <heckyel@hyperbola.info>2022-12-02 05:21:10 +0800
commiteaeeef9c1d1bedb76fea953c332ef84d53bffe2c (patch)
treec3cb5582247e47fc67c24cd7ff8ea857fb76821e /hypervideo_dl/compat/functools.py
parent1e5a50b71d8f0eae6007bedc329eecb24bb5aba3 (diff)
downloadhypervideo-eaeeef9c1d1bedb76fea953c332ef84d53bffe2c.tar.lz
hypervideo-eaeeef9c1d1bedb76fea953c332ef84d53bffe2c.tar.xz
hypervideo-eaeeef9c1d1bedb76fea953c332ef84d53bffe2c.zip
update from upstream
Diffstat (limited to 'hypervideo_dl/compat/functools.py')
-rw-r--r--hypervideo_dl/compat/functools.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/hypervideo_dl/compat/functools.py b/hypervideo_dl/compat/functools.py
new file mode 100644
index 0000000..ec003ea
--- /dev/null
+++ b/hypervideo_dl/compat/functools.py
@@ -0,0 +1,26 @@
+# flake8: noqa: F405
+from functools import * # noqa: F403
+
+from .compat_utils import passthrough_module
+
+passthrough_module(__name__, 'functools')
+del passthrough_module
+
+try:
+ cache # >= 3.9
+except NameError:
+ cache = lru_cache(maxsize=None)
+
+try:
+ cached_property # >= 3.8
+except NameError:
+ class cached_property:
+ def __init__(self, func):
+ update_wrapper(self, func)
+ self.func = func
+
+ def __get__(self, instance, _):
+ if instance is None:
+ return self
+ setattr(instance, self.func.__name__, self.func(instance))
+ return getattr(instance, self.func.__name__)