diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-08-28 17:27:55 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-08-28 17:27:55 +0200 |
commit | 0e757e1d3822a0adeeb086fbf3e56c20cb1bdb40 (patch) | |
tree | 5939da7e0eae26f8d7ca48639230cb47874d90e7 /mensa/logic.py | |
parent | 81f8785b36a11b98e8bf0051e560e4161d6c50dc (diff) | |
download | mensa-0e757e1d3822a0adeeb086fbf3e56c20cb1bdb40.tar.gz mensa-0e757e1d3822a0adeeb086fbf3e56c20cb1bdb40.tar.bz2 mensa-0e757e1d3822a0adeeb086fbf3e56c20cb1bdb40.zip |
Added option for position, radius and distances, more plugins
Diffstat (limited to 'mensa/logic.py')
-rwxr-xr-x | mensa/logic.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/mensa/logic.py b/mensa/logic.py index cae2421..1ae6a96 100755 --- a/mensa/logic.py +++ b/mensa/logic.py @@ -4,13 +4,14 @@ from mensa import base import urllib.error import os import sys +from math import acos, radians, pi, cos, sin from yapsy.PluginManager import PluginManager try: import multiprocessing parallel=True except: parallel = False - + def init_foodsources(): backends = PluginManager() backends.setPluginPlaces([os.path.join(os.path.dirname(os.path.realpath(__file__)),"backends")]) @@ -30,19 +31,22 @@ def init_renderers(): def get_food(restlist=False, no_parallel=False,**options) : foodl = [] + sources = [] + for k,i in base.foodsources.items() : + if restlist and not i.name in restlist : + continue + if options["pos"] and options["rad"] and base.dist(options["pos"], i.pos) > float(options["rad"]) : + continue + sources.append((k,i)) + if parallel and not no_parallel: r = [] - for k,i in base.foodsources.items() : - if restlist and not i.name in restlist : - continue - r.append(i) - + for k,i in sources : + r.append(i) foodl = get_food_parallel(r, ignore_nudelauswahl=True) else : - for k,i in base.foodsources.items() : - if restlist and not i.name in restlist : - continue + for k,i in sources : try : food = i.get_food(ignore_nudelauswahl=True) foodl.append((i, food)) |