valderman / mat

What's for lunch today around Grönsakstorget, Gothenburg?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mat!

"What's for lunch" script for restaurants around Grönsakstorget, Gothenburg

Usage

./mat.py -p <plugin directory>

If no plugin directory is specified, $HOME/.mat is used if it exists. If it doesn't, ./plugins is used instead.

Dependencies

  • For everything: algebraic-data-types
  • For restaurants with PDF menus (Bee): PyMuPDF
  • For restaurants with JSON "menus" (Jinx): json
  • For all other restaurants: bs4
  • To build website: Pandoc

Troubleshooting

  • Not all restaurants show up!
    • Make sure you have installed all the above dependencies (using pip install <dependency> or similar).
    • Some plugins don't support menus for other dates than today.

Supported restaurants

Generating an HTML menu

To generate a styled and somewhat interactive HTML menu, use mat.py and Pandoc with the provided wrapper script:

./build-site.sh

Contributing

Is your favourite restaurant missing? File a bug report or submit a pull request!

Plugin API

Plugins need to export two functions:

  • name(), returning the name of the restaurant as a string, and
  • food(api, date), returning a list of Food objects representing the restaurants offerings on the given date.

Food objects are created using the function api.food(dish, dish_description). Description may be None.

For convenience, api also contains the following:

  • soup: reexport of bs4.BeautifulSoup if available, otherwise None
  • pdf: reexport of fitz from PyMuPDF if available, otherwise None
  • json: reexport of json from json if available, otherwise None
  • requests: reexport of requests
  • is_today(date): returns True if date is today's date
  • is_current_week(date): returns True if date is in the current week
  • is_weekday(date): returns True if date is a weekday (ignoring holidays)

About

What's for lunch today around Grönsakstorget, Gothenburg?

License:MIT License


Languages

Language:Python 65.3%Language:JavaScript 17.9%Language:CSS 7.9%Language:Shell 3.0%Language:Dockerfile 3.0%Language:HTML 2.9%