diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-05-18 09:56:54 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-05-18 09:56:54 +0200 |
commit | fc432ae39c8477c380de84761a211c690548350a (patch) | |
tree | db8a1a6ed6acc580a2bf6269f5f1d98727d0513c /modules | |
parent | f95b596818a9ade81f9010b25923d0804a0c4469 (diff) | |
download | curunir-fc432ae39c8477c380de84761a211c690548350a.tar curunir-fc432ae39c8477c380de84761a211c690548350a.zip |
Fixed mensa module and exception handling
Diffstat (limited to 'modules')
-rw-r--r-- | modules/__init__.py | 2 | ||||
-rw-r--r-- | modules/mensa.py | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/modules/__init__.py b/modules/__init__.py index 403bbc9..4dc1972 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -1,3 +1,5 @@ +import traceback + class ModuleBase: def __init__(self, manager): self.manager = manager diff --git a/modules/mensa.py b/modules/mensa.py index 9ff4bcb..5faa956 100644 --- a/modules/mensa.py +++ b/modules/mensa.py @@ -44,12 +44,18 @@ class Module(ModuleBase): data = match.group(1) r = re.compile(r'.*?<tr[^>]*>(.*?)</tr>', re.DOTALL) - match = r.match(data) - if not match: - return False - mealstr = match.group(1) + r2 = re.compile(r'(?:.*?<td[^>]*>(.*?)</td>){4}', re.DOTALL) + + mealstr = '' + pos = 0 + while not r2.match(mealstr): + match = r.match(data, pos) + if not match: + return False + mealstr = match.group(1) + pos = match.end() - match = r.match(data, match.end()) + match = r.match(data, pos) if not match: return False pricestr = match.group(1) |