File size: 642 Bytes
71e71e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import json
import random
from src.model.enums.AssetPath import AssetPath
def get_random_item_from_txt(asset_path: AssetPath) -> str:
"""
Get a random item from a txt file
:param asset_path: The asset path
:return: A random item from the txt file
"""
with open(asset_path) as file:
lines = file.readlines()
return random.choice(lines).strip()
def get_list_from_json(asset_path: AssetPath) -> list[dict]:
"""
Get a list from a json file
:param asset_path: The asset path
:return: A list from the json file
"""
with open(asset_path) as file:
return json.load(file)
|