Files
OpenMensa-Parser-STW-Potsdam/stw_potsdam/config.py
T
Kai Fabian 5adf85ab65 feature/metafeeds: Support for canteen meta feeds and index feed (#2)
* feature/metafeeds: Restructured API, splitted menu and meta feed

* feature/metafeeds: add field 'key' to Canteen

* feature/metafeeds: added helper function for reverse urls

* feature/metafeeds: added menu feed url to meta feed

* feature/metafeeds: added missing test

(added: testing meta feed rendering in retrievaltest)

* feature/metafeeds: added feed index page

* whitespace fix

* feature/metafeeds: added alias urls

* feature/metafeeds: moved meta feed default url

* feature/metafeeds: moved index generation to views

* feature/metafeeds: inlined builder instance creation

* feature/metafeeds: removed unused 'menu' parameter

* feature/metafeeds: replaced 'reverse' module with Flask's url_for

* feature/metafeeds: removed unused import

* feature/metafeeds: removed unused function parameters

* feature/metafeeds: moved menu feed url generation to views.py

* feature/metafeeds: cleanup debug prints

removing debug prints that should never have been committed.
2018-10-22 09:16:14 +02:00

31 lines
798 B
Python

# -*- encoding: utf-8 -*-
import ConfigParser
import io
import os
from functools import partial
from canteen import Canteen
def _get_config(filename):
config = ConfigParser.SafeConfigParser()
path = os.path.join('stw_potsdam', filename)
with io.open(path, encoding='utf-8') as f:
config.readfp(f)
return config
def _parse_canteen(config, canteen_name):
get = partial(config.get, canteen_name)
return Canteen(key=canteen_name,
name=get('name'),
street=get('street'),
city=get('city'),
id=get('id'),
chash=get('cHash'))
def read_canteen_config():
config = _get_config('canteens.ini')
return {name: _parse_canteen(config, name) for name in config.sections()}