r2mods/data/items.py

20 lines
465 B
Python
Raw Normal View History

2024-10-05 08:43:51 +00:00
#!/usr/bin/env python3
from typing import Callable
import csv
import pathlib
def repo_root_impure():
cwd = pathlib.Path.cwd()
return cwd.parent if cwd.name == "data" else cwd
def _item_list_f():
return repo_root_impure().joinpath("data", "list_items.txt")
def item_list(fpath: Callable[[], pathlib.Path] = _item_list_f):
"""
This is evil :(
"""
with open(fpath(), "r") as f:
return [line.strip().split(']')[1] for line in f]