25 lines
765 B
Python
25 lines
765 B
Python
"""Usage: python convert.py <free-exercise-db checkout> [output folder]
|
|||
|
|
|
||
|
|
The output folder defaults to the app's assets/exercises.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import collections
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from exercise_import import run
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
sys.exit(__doc__)
|
||
|
|
source = Path(sys.argv[1])
|
||
|
|
output = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(__file__).resolve().parents[2] / "assets" / "exercises"
|
||
|
|
exercises = run(source, output)
|
||
|
|
modes = collections.Counter(e["mode"] for e in exercises)
|
||
|
|
size = sum(f.stat().st_size for f in (output / "images").glob("*.webp"))
|
||
|
|
print(f"{len(exercises)} Exercises ({dict(modes)}), images {size / 1_000_000:.1f} MB -> {output}")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|