mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 08:52:40 +01:00
ae66312d8c
* Add Python linter to github actions * wip * Add back splat_ext * Format files * C++ -> C * format 2 files * split workflow into separate file, line length 120, fix excludes * -l 120 in ci * update black locally and apply formatting changes * pyproject.toject --------- Co-authored-by: Ethan Roseman <ethteck@gmail.com>
22 lines
678 B
Python
22 lines
678 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)
|