Source code for

"""Provides data related to food."""
import typing as t

from mimesis.providers.base import BaseDataProvider

__all__ = ["Food"]

[docs]class Food(BaseDataProvider): """Class for generating data related to food.""" class Meta: name = "food" datafile = f"{name}.json" def _choice_from(self, key: str) -> str: """Choice random element.""" data: t.List[str] = self.extract([key]) return self.random.choice(data)
[docs] def vegetable(self) -> str: """Get a random vegetable. :return: Vegetable name. :Example: Tomato. """ return self._choice_from("vegetables")
[docs] def fruit(self) -> str: """Get a random fruit or berry. :return: Fruit name. :Example: Banana. """ return self._choice_from("fruits")
[docs] def dish(self) -> str: """Get a random dish. :return: Dish name. :Example: Ratatouille. """ return self._choice_from("dishes")
[docs] def spices(self) -> str: """Get a random spices or herbs. :return: Spices or herbs. :Example: Anise. """ return self._choice_from("spices")
[docs] def drink(self) -> str: """Get a random drink. :return: Alcoholic drink. :Example: Vodka. """ return self._choice_from("drinks")