2021-08-09 15:26:06 +00:00
|
|
|
"""The Zapp runtime manifest API."""
|
|
|
|
|
2021-08-29 21:07:56 +00:00
|
|
|
import json
|
2021-08-09 15:26:06 +00:00
|
|
|
from copy import deepcopy
|
|
|
|
from importlib.resources import open_text
|
|
|
|
|
2021-08-29 21:07:56 +00:00
|
|
|
|
|
|
|
def once(f):
|
|
|
|
singleton = object()
|
|
|
|
state = singleton
|
|
|
|
|
|
|
|
def helper(*args, **kwargs):
|
|
|
|
nonlocal state
|
|
|
|
if state is singleton:
|
|
|
|
state = f(*args, **kwargs)
|
|
|
|
return state
|
|
|
|
|
|
|
|
return helper
|
|
|
|
|
|
|
|
|
|
|
|
def copied(f):
|
|
|
|
def helper(*args, **kwargs):
|
|
|
|
val = f(*args, **kwargs)
|
|
|
|
return deepcopy(val)
|
|
|
|
|
|
|
|
return helper
|
2021-08-09 15:26:06 +00:00
|
|
|
|
|
|
|
|
2021-08-29 21:07:56 +00:00
|
|
|
@copied
|
|
|
|
@once
|
2021-08-09 15:26:06 +00:00
|
|
|
def manifest():
|
|
|
|
"""Return (a copy) of the runtime manifest."""
|
|
|
|
|
2021-08-29 21:07:56 +00:00
|
|
|
with open_text("zapp", "manifest.json") as fp:
|
|
|
|
return json.load(fp)
|
2021-08-09 15:26:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["manifest"]
|