GithubHelp home page GithubHelp logo

chk1 / stw2openmensa Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 27 KB

Convert canteen meal data from Studentenwerk Münster XML to OpenMensa Feed v2 XML format

Home Page: http://openmensa.org/#14/51.9646/7.6159

License: MIT License

Python 100.00%
canteen parser xml openmensa

stw2openmensa's Introduction

stw2openmensa

Deprecation notice

From 2016 to August 2020, Studierendenwerk Münster provided meal data as XML files (see the discussion here) but they have since stopped. Canteen data is now only available via the "My Mensa" platform.

If want to use the canteen data in a machine readable format and are looking for an alternative, take a look at the mymensa2openmensa project (see issue #15).

About

stw2openmensa is a Python script that converts canteen meal data from Studierendenwerk Münster XML to OpenMensa Feed v2 XML format.

Installation

Configuration

config.py contains a few settings that you can change, the most important being output_dir where the output data will be written to.

Quick start

Install dependencies and run the script.

pip install -r requirements.txt
python parser.py

Using virtualenv

Prepare your virtual environment:

sudo pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
deactivate

Activate your virtual environment and run the parser:

source venv/bin/activate
python parser.py
deactivate

Cronjob example using virtualenv:

Executes monday through saturday at 07:00

0 7 * * 1-6 /home/you/mensaparser/venv/bin/python /home/you/mensaparser/parser.py

Todo

  • Better checks for when a canteen is closed for the day (see issue #4)

License

Code in this repository is licensed under the MIT license.

stw2openmensa's People

Contributors

chk1 avatar gfranco93 avatar hija avatar localh0rzd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stw2openmensa's Issues

Strip spaces from meal classification

CI throws a (caught) error for Python 3.x tests:

Processing "mensa_steinfurt.xml" Conversion of "mensa_steinfurt.xml" failed: 'vgn '
Traceback (most recent call last):
  File "parser.py", line 208, in <module>
    status = StudentenwerkToOpenmensa(config.BASE_URL, config.OUT_DIR, config.USER_AGENT, filename)
  File "parser.py", line 152, in StudentenwerkToOpenmensa
    for foodicon in foodicons:
  File "parser.py", line 70, in <lambda>
    fis = map(lambda x: config.CLASSIFICATION[x.lower()], fis)
KeyError: 'vgn '

vgn should be vgn (without spaces) to match an item in the classification list

https://github.com/chk1/stw2openmensa/blob/master/config.py#L68

Code change somewhere here https://github.com/chk1/stw2openmensa/blob/master/parser.py#L69

Studierendenwerk stopped providing XML data (Aasee parser stopped working)

Hey everyone,

I recently realized the parser for the Aasee canteen in Münster stopped working.

I got in touch with the canteen and they said, they indeed stopped to provide the XML. But they provide an HTML you could use to parse the meals. They send me this link: https://muenster.my-mensa.de/essen.php?v=5326049&hyp=1&lang=de&mensa=aasee#aasee_tag_2020231

So far I didn't implement a parser for openmensa, but if none of you is working on it, I would give it a try.

Cheers.

Auto create output directory?

I think, the output directory should be automatically created if it does not exist yet since this would make the project a little bit simpler to use. Is there a reason this has not been implemented?

Otherwise, I could do it :)

Parsing Inhaltsstoffe

Funktioniert nicht korrekt bei:

Westfälischer Sauerbraten (I) mit Kartoffelklößen (3,G,I,)
GIANT BURGER mit Salat, Tomate und Sauerrahm (A,C,F,G,I,J.K)
Gemüselasagne mit Kräutersauce (C,G,I,Alk)

Info "Geschlossen" aber hat ein Menü = Invalid XML

Menü vom STW Münster, Mensa Aasee, 21.12.2018:

image

image

Ausgabe des Parsers validiert nicht:

$ xmllint --noout mensa_aasee.xml --schema open-mensa-v2.xsd
mensa_aasee.xml:2: element category: Schemas validity error : Element '{http://openmensa.org/open-mensa-v2}category': This element is not expected.
mensa_aasee.xml:2: element category: Schemas validity error : Element '{http://openmensa.org/open-mensa-v2}category': This element is not expected.
mensa_aasee.xml:2: element category: Schemas validity error : Element '{http://openmensa.org/open-mensa-v2}category': This element is not expected.

Problem: <category>-Tag neben <closed/>-Tag

    <day date="2018-12-21">
      <closed/>
      <category name="Menü 1">
        <meal>
          <name>VEGAN: Gebackene Samosas mit Gemüsefüllung auf Chilisauce</name>
          <note>Vegan</note>
          <note>Enthält Allergene: glutenhaltiges Getreide, Sesam, Soja</note>
          <price role="student">2.30</price>
          <price role="employee">3.40</price>
          <price role="other">4.15</price>
        </meal>
      </category>
   ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.