1
0
Fork 0

Generate api data on each push (#10609)

* add new qmk generate-api command, to generate a complete set of API data.

* Generate api data and push it to the keyboard repo

* fix typo

* Apply suggestions from code review

Co-authored-by: Joel Challis <git@zvecr.com>

* fixup api workflow

* remove file-changes-action

* use a more mainstream github action

* fix yaml error

* Apply suggestions from code review

Co-authored-by: Erovia <Erovia@users.noreply.github.com>

* more uniform date handling

* make flake8 happy

* Update lib/python/qmk/decorators.py

Co-authored-by: Erovia <Erovia@users.noreply.github.com>

Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
This commit is contained in:
Zach White 2020-10-25 14:48:44 -07:00 committed by GitHub
parent 8ef82c466e
commit 0c42f91f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 399 additions and 127 deletions

View file

@ -2,6 +2,7 @@
"""
import functools
from pathlib import Path
from time import monotonic
from milc import cli
@ -84,3 +85,38 @@ def automagic_keymap(func):
return func(*args, **kwargs)
return wrapper
def lru_cache(timeout=10, maxsize=128, typed=False):
"""Least Recently Used Cache- cache the result of a function.
Args:
timeout
How many seconds to cache results for.
maxsize
The maximum size of the cache in bytes
typed
When `True` argument types will be taken into consideration, for example `3` and `3.0` will be treated as different keys.
"""
def wrapper_cache(func):
func = functools.lru_cache(maxsize=maxsize, typed=typed)(func)
func.expiration = monotonic() + timeout
@functools.wraps(func)
def wrapped_func(*args, **kwargs):
if monotonic() >= func.expiration:
func.expiration = monotonic() + timeout
func.cache_clear()
return func(*args, **kwargs)
wrapped_func.cache_info = func.cache_info
wrapped_func.cache_clear = func.cache_clear
return wrapped_func
return wrapper_cache