mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +01:00
add missing module
This commit is contained in:
parent
f31a172dcb
commit
e237c4a7e2
1 changed files with 24 additions and 0 deletions
24
src/pycalver/utils.py
Normal file
24
src/pycalver/utils.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# This file is part of the pycalver project
|
||||
# https://github.com/mbarkhau/pycalver
|
||||
#
|
||||
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
|
||||
# SPDX-License-Identifier: MIT
|
||||
import typing as typ
|
||||
import functools
|
||||
|
||||
# NOTE (mb 2020-09-24): The main use of the memo function is
|
||||
# not as a performance optimization, but to reduce logging
|
||||
# spam.
|
||||
|
||||
|
||||
def memo(func: typ.Callable) -> typ.Callable:
|
||||
cache = {}
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args):
|
||||
key = str(args)
|
||||
if key not in cache:
|
||||
cache[key] = func(*args)
|
||||
return cache[key]
|
||||
|
||||
return wrapper
|
||||
Loading…
Add table
Add a link
Reference in a new issue