#!/usr/bin/python2.6
-# -*- coding: iso-8859-15 -*-
-
import logging
from pylons import request, response, session, url, tmpl_context as c
c.validation_hints = hints
c.validation_ok = len([hint for hint in hints if hint.level > 1]) == 0
session['wrgpx'] = gpx
- if c.validation_ok: session['flash'] = "Die Datei '%s' ist eine gültige GPX 1.1 Datei und entspricht zusätzlich den Winterrodeln Anforderungen (WRGPX). :-)" % gpxfile.filename
- else: session['flash'] = " Die Datei '%s' ist zwar eine gültige GPX 1.1 Datei, entspricht aber nicht den zusätzlichen Winterrodeln-Anforderungen. :-(" % gpxfile.filename
+ if c.validation_ok: session['flash'] = "Die Datei '%s' ist eine gültige GPX 1.1 Datei und entspricht zusätzlich den Winterrodeln Anforderungen (WRGPX). :-)" % gpxfile.filename
+ else: session['flash'] = " Die Datei '%s' ist zwar eine gültige GPX 1.1 Datei, entspricht aber nicht den zusätzlichen Winterrodeln-Anforderungen. :-(" % gpxfile.filename
except etree.XMLSyntaxError as e:
c.validation_exception = e
c.validation_hints = []
c.validation_ok = False
- session['flash'] = "Die Datei '%s' ist keine gültige GPX 1.1 Datei. :-(" % gpxfile.filename
+ session['flash'] = "Die Datei '%s' ist keine gültige GPX 1.1 Datei. :-(" % gpxfile.filename
c.validated = True
c.filename = gpxfile.filename
else:
#!/usr/bin/python2.6
-# -*- coding: iso-8859-15 -*-
"""This file contains "validators" that convert between string and python (database) representation
of properties used in the "Rodelbahnbox" and "Gasthausbox".
The "to_python" method has to get a unicode argument.
FORMAT_NONE = -1 # indicates missing formats
# Valid for input_format and output_format
- FORMAT_GEOCACHING = 1 # e.g. "N 47° 13.692 E 011° 25.535"
+ FORMAT_GEOCACHING = 1 # e.g. "N 47° 13.692 E 011° 25.535"
FORMAT_WINTERRODELN = 2 # e.g. "47.222134 N 11.467211 E"
FORMAT_GMAPPLUGIN = 3 # e.g. "47.232922, 11.452239"
FORMAT_GPX = 4 # e.g. "<trkpt lat="47.181289" lon="11.408827"><ele>1090.57</ele></trkpt>"
result = []
for line in lines:
if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_GEOCACHING:
- r = re.match('N ?(\d+)° ?(\d+\.\d+) +E ?(\d+)° ?(\d+\.\d+)', line)
+ r = re.match('N ?(\d+)° ?(\d+\.\d+) +E ?(\d+)° ?(\d+\.\d+)', line)
if not r is None:
g = r.groups()
result.append((float(g[0]) + float(g[1])/60, float(g[2]) + float(g[3])/60, None))
for latitude, longitude, height in value:
if output_format == self.FORMAT_GEOCACHING:
degree = latitude
- result.append('N %02d° %02.3f E %03d° %02.3f' % (latitude, latitude % 1 * 60, longitude, longitude % 1 * 60))
+ result.append('N %02d° %02.3f E %03d° %02.3f' % (latitude, latitude % 1 * 60, longitude, longitude % 1 * 60))
elif output_format == self.FORMAT_WINTERRODELN:
result.append('%.6f N %.6f E' % (latitude, longitude))
u'kaum' <=> 1
u'selten' <=> 2
u'gelegentlich' <=> 3
- u'häufig' <=> 4"""
+ u'häufig' <=> 4"""
def __init__(self):
- DictValidator.__init__(self, {'': None, 'kaum': 1, 'selten': 2, 'gelegentlich': 3, 'häufig': 4})
+ DictValidator.__init__(self, {'': None, 'kaum': 1, 'selten': 2, 'gelegentlich': 3, 'häufig': 4})
class GermanPublicTransport(DictValidator):
u'' <=> None
u'Sehr gut' <=> 1
u'Gut' <=> 2
- u'Mittelmäßig' <=> 3
+ u'Mittelmäßig' <=> 3
u'Schlecht' <=> 4
u'Nein' <=> 5
u'Ja' <=> 6"""
def __init__(self):
- DictValidator.__init__(self, {'': None, 'Sehr gut': 1, 'Gut': 2, 'Mittelmäßig': 3, 'Schlecht': 4, 'Nein': 5, 'Ja': 6})
+ DictValidator.__init__(self, {'': None, 'Sehr gut': 1, 'Gut': 2, 'Mittelmäßig': 3, 'Schlecht': 4, 'Nein': 5, 'Ja': 6})
class GermanTristateFloatComment(ValueComment):
class GermanCachet(formencode.FancyValidator):
- """Converts a "Gütesiegel":
+ """Converts a "Gütesiegel":
u'' <=> None
u'Nein' <=> 'Nein'
- u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel' <=> u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel'"""
+ u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel' <=> u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel'"""
def to_python(self, value):
self.assert_string(value, None)
if value == '': return None
elif value == 'Nein': return value
- elif value.startswith('Tiroler Naturrodelbahn-Gütesiegel '):
+ elif value.startswith('Tiroler Naturrodelbahn-Gütesiegel '):
p = value.split(" ")
Unsigned().to_python(p[2]) # check if year can be parsed
if not p[3] in ['leicht', 'mittel', 'schwer']: raise formencode.Invalid("Unbekannter Schwierigkeitsgrad", value, None)
return value
- else: raise formencode.Invalid("Unbekanntes Gütesiegel", value, None)
+ else: raise formencode.Invalid("Unbekanntes Gütesiegel", value, None)
def from_python(self, value):
if value == None: return ''
def to_python(self, value):
self.assert_string(value, None)
v = value
- v = v.replace('ä', 'a')
- v = v.replace('ö', 'o')
- v = v.replace('ü', 'u')
- v = v.replace('ß', 'ss')
+ v = v.replace('ä', 'a')
+ v = v.replace('ö', 'o')
+ v = v.replace('ü', 'u')
+ v = v.replace('ß', 'ss')
v = self.urlv.to_python(v)
return value
u'' <=> (None, None)
u'Nein' <=> (False, None)
u'Sessellift <=> (True, u'Sessellift')
- u'Gondel (nur bis zur Hälfte)' <=> (True, u'Gondel (nur bis zur Hälfte)')
+ u'Gondel (nur bis zur Hälfte)' <=> (True, u'Gondel (nur bis zur Hälfte)')
u'Sessellift; Taxi' <=> (True, u'Sessellift; Taxi')
u'Sessellift (Wochenende); Taxi (6 Euro)' <=> (True, u'Sessellift (Wochenende); Taxi (6 Euro)')
"""