papermario/tools/build/common.py
Ethan Roseman 4f77ffbc3e
more pal funcs & npc sprites improvement (#1079)
* cod changes and fixes for npc sprites

* 6 mo

* Cleanup
2023-07-10 14:57:27 +09:00

25 lines
690 B
Python

from functools import lru_cache
from itertools import zip_longest
import os
from pathlib import Path
from typing import Tuple
ASSETS_DIR = (
Path(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
/ "assets"
)
@lru_cache(maxsize=None)
def get_asset_path(asset: Path, asset_stack: Tuple[Path, ...]) -> Path:
for sdir in asset_stack:
potential_path = ASSETS_DIR / sdir / asset
if potential_path.exists():
return potential_path
raise FileNotFoundError(f"Could not find asset {asset}")
def iter_in_groups(iterable, n, fillvalue=None):
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)