class TestMwMarkup(unittest.TestCase):
def test_find_template(self):
- wikitext = u'''== Allgemeines ==
+ wikitext = '''== Allgemeines ==
{{Rodelbahnbox
| Position = 47.309820 N 9.986508 E
| Position oben =
| Forumid = 72
}}
Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
- assert start == wikitext.find(u'{{')
- assert end == wikitext.find(u'}}')+2
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Rodelbahnbox')
+ assert start == wikitext.find('{{')
+ assert end == wikitext.find('}}')+2
def test_TemplateValidator(self):
v = wrpylib.mwmarkup.TemplateValidator()
- value = u'{{Rodelbahnbox | Unbenannt | Position = 47.309820 N 9.986508 E | Aufstieg möglich = Ja }}'
+ value = '{{Rodelbahnbox | Unbenannt | Position = 47.309820 N 9.986508 E | Aufstieg möglich = Ja }}'
title, anonym_params, named_params = v.to_python(value)
- assert title == u'Rodelbahnbox'
- assert anonym_params == [u'Unbenannt']
- assert named_params.keys() == [u'Position', u'Aufstieg möglich']
- assert named_params.values() == ['47.309820 N 9.986508 E', 'Ja']
+ assert title == 'Rodelbahnbox'
+ assert anonym_params == ['Unbenannt']
+ assert list(named_params.keys()) == ['Position', 'Aufstieg möglich']
+ assert list(named_params.values()) == ['47.309820 N 9.986508 E', 'Ja']
value2 = v.from_python((title, anonym_params, named_params))
- assert value2 == u'{{Rodelbahnbox|Unbenannt|Position=47.309820 N 9.986508 E|Aufstieg möglich=Ja}}'
+ assert value2 == '{{Rodelbahnbox|Unbenannt|Position=47.309820 N 9.986508 E|Aufstieg möglich=Ja}}'
v = wrpylib.mwmarkup.TemplateValidator(as_table=True)
value3 = v.from_python((title, anonym_params, named_params))
assert value3 == \
- u'{{Rodelbahnbox\n' + \
- u'| Unbenannt\n' + \
- u'| Position = 47.309820 N 9.986508 E\n' + \
- u'| Aufstieg möglich = Ja\n' + \
- u'}}'
+ '{{Rodelbahnbox\n' + \
+ '| Unbenannt\n' + \
+ '| Position = 47.309820 N 9.986508 E\n' + \
+ '| Aufstieg möglich = Ja\n' + \
+ '}}'
v = wrpylib.mwmarkup.TemplateValidator(strip=False)
title, anonym_params, named_params = v.to_python(value)
- assert title == u'Rodelbahnbox '
- assert anonym_params == [u' Unbenannt ']
- assert named_params.keys() == [u' Position ', u' Aufstieg möglich ']
- assert named_params.values() == [' 47.309820 N 9.986508 E ', ' Ja ']
+ assert title == 'Rodelbahnbox '
+ assert anonym_params == [' Unbenannt ']
+ assert list(named_params.keys()) == [' Position ', ' Aufstieg möglich ']
+ assert list(named_params.values()) == [' 47.309820 N 9.986508 E ', ' Ja ']
def test_split_template(self):
- wikitext = u'''== Allgemeines ==
+ wikitext = '''== Allgemeines ==
{{Rodelbahnbox
| Position = 47.309820 N 9.986508 E
| Position oben =
| Forumid = 72
}}
Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Rodelbahnbox')
template_title, parameters = wrpylib.mwmarkup.split_template(wikitext[start:end])
- assert template_title == u'Rodelbahnbox'
+ assert template_title == 'Rodelbahnbox'
assert len(parameters) == 22
- assert parameters['Position'] == u'47.309820 N 9.986508 E'
- assert parameters['Telefonauskunft'] == u'+43-664-1808482 (Bergkristallhütte)'
- assert parameters['Schwierigkeit'] == u''
+ assert parameters['Position'] == '47.309820 N 9.986508 E'
+ assert parameters['Telefonauskunft'] == '+43-664-1808482 (Bergkristallhütte)'
+ assert parameters['Schwierigkeit'] == ''
def test_create_template(self):
- wikitext = u'''{{Nicetemplate|Red|Bold|Position=Top|Alignment=Right}}'''
+ wikitext = '''{{Nicetemplate|Red|Bold|Position=Top|Alignment=Right}}'''
template_title, parameters = wrpylib.mwmarkup.split_template(wikitext)
- keys = [u'1', u'2', u'Position', u'Alignment']
+ keys = ['1', '2', 'Position', 'Alignment']
values = [parameters[k] for k in keys]
wikitext_generated = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:])
wikitext_table = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:], True)
def test_find_tag(self):
- wikitext = u'This is <tag>my first tag</tag> and <tag>my second tag</tag>.'
- start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tags')
+ wikitext = 'This is <tag>my first tag</tag> and <tag>my second tag</tag>.'
+ start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, 'tags')
assert (start, content, endtag, end) == (None, None, None, None)
- start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag')
+ start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, 'tag')
assert (start, content, endtag, end) == (8, 13, 25, 31)
- start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag', end)
+ start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, 'tag', end)
assert (start, content, endtag, end) == (36, 41, 54, 60)
- wikitext = u'This is <tag myattrib="4"/>.'
- start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag')
+ wikitext = 'This is <tag myattrib="4"/>.'
+ start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, 'tag')
assert (start, content, endtag, end) == (8, None, None, 27)
def test_parse_googlemap(self):
- wikitext = u'''
+ wikitext = '''
<googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
(Parkplatz)47.114958,11.266026
Erster Parkplatz
assert attributes['zoom'] == 15
assert coords == [
(11.266026, 47.114958, 'Parkplatz', 'Erster Parkplatz'),
- (11.266262, 47.114715, 'Gasthaus', u'Alt Bärnbad (Gasthaus)')]
+ (11.266262, 47.114715, 'Gasthaus', 'Alt Bärnbad (Gasthaus)')]
assert paths == [
('6#FF014E9A', [
(11.266262, 47.114715, None, None),
class TestMySqlPython(unittest.TestCase):
def test_datatype_page(self):
result = exec_sql('select page_title, page_restrictions, page_touched from page where page_id = 1321')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.StringType # tinyblob NOT NULL
- assert type(result[2]) == types.StringType # binary(14) NOT NULL
+ assert type(result[0]) == str # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == bytes # tinyblob NOT NULL
+ assert type(result[2]) == bytes # binary(14) NOT NULL
def test_datatype_revision(self):
result = exec_sql('select rev_comment, rev_user_text, rev_timestamp from revision where rev_id = 7586')
- assert type(result[0]) == types.StringType # tinyblob NOT NULL
- assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[2]) == types.StringType # binary(14) NOT NULL
+ assert type(result[0]) == bytes # tinyblob NOT NULL
+ assert type(result[1]) == str # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[2]) == bytes # binary(14) NOT NULL
def test_datatypes_text(self):
result = exec_sql('select old_text, old_flags from text where old_id = 7438')
- assert type(result[0]) == types.StringType # mediumblob NOT NULL
- assert type(result[1]) == types.StringType # tinyblob NOT NULL
+ assert type(result[0]) == bytes # mediumblob NOT NULL
+ assert type(result[1]) == bytes # tinyblob NOT NULL
def test_datatype_user(self):
result = exec_sql('select user_name, user_real_name, user_email from user where user_id = 1')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[2]) == types.UnicodeType # tinytext NOT NULL
- assert result[0] == u'Philipp'
+ assert type(result[0]) == str # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == str # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[2]) == str # tinytext NOT NULL
+ assert result[0] == 'Philipp'
def test_datatype_categorylinks(self):
result = exec_sql('select cl_to, cl_sortkey from categorylinks where cl_from = 609')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.StringType # varbinary(230) NOT NULL
+ assert type(result[0]) == str # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == bytes # varbinary(230) NOT NULL
metadata = schema.MetaData()
tpage = mwdb.page_table(metadata)
page = connect().execute(select([tpage], tpage.c.page_id == 1321)).first()
- assert type(page.page_title) == types.UnicodeType
- assert type(page.page_restrictions) == types.StringType
- assert type(page.page_touched) == types.UnicodeType
+ assert type(page.page_title) == str
+ assert type(page.page_restrictions) == bytes
+ assert type(page.page_touched) == str
def test_datatype_revision(self):
metadata = schema.MetaData()
trevision = mwdb.revision_table(metadata)
revision = connect().execute(select([trevision], trevision.c.rev_id == 7586)).first()
- assert type(revision.rev_comment) == types.UnicodeType
- assert type(revision.rev_user_text) == types.UnicodeType
- assert type(revision.rev_timestamp) == types.UnicodeType
+ assert type(revision.rev_comment) == str
+ assert type(revision.rev_user_text) == str
+ assert type(revision.rev_timestamp) == str
def test_datatypes_text(self):
metadata = schema.MetaData()
ttext = mwdb.text_table(metadata)
text = connect().execute(select([ttext], ttext.c.old_id==7438)).first()
- assert type(text.old_text) == types.UnicodeType
- assert type(text.old_flags) == types.UnicodeType
- assert text.old_flags == u'utf-8'
+ assert type(text.old_text) == str
+ assert type(text.old_flags) == str
+ assert text.old_flags == 'utf-8'
def test_datatype_user(self):
metadata = schema.MetaData()
tuser = mwdb.user_table(metadata)
user = connect().execute(select([tuser], tuser.c.user_id == 1)).first()
- assert type(user.user_name) == types.UnicodeType
- assert type(user.user_real_name) == types.UnicodeType
- assert type(user.user_email) == types.UnicodeType
- assert user.user_name == u'Philipp'
+ assert type(user.user_name) == str
+ assert type(user.user_real_name) == str
+ assert type(user.user_email) == str
+ assert user.user_name == 'Philipp'
def test_datatype_categorylinks(self):
metadata = schema.MetaData()
tcategorylinks = mwdb.categorylinks_table(metadata)
categorylinks = connect().execute(select([tcategorylinks], tcategorylinks.c.cl_from == 609)).first()
- assert type(categorylinks.cl_to) == types.UnicodeType
- assert type(categorylinks.cl_sortkey) == types.UnicodeType
- assert categorylinks.cl_sortkey == u'ALT BÄRNBAD'
+ assert type(categorylinks.cl_to) == str
+ assert type(categorylinks.cl_sortkey) == str
+ assert categorylinks.cl_sortkey == 'ALT BÄRNBAD'
class TestWrMwMarkup(unittest.TestCase):
def test_rodelbahnbox_to_sledrun(self):
- wikitext = u'''== Allgemeines ==
+ wikitext = '''== Allgemeines ==
{{Rodelbahnbox
| Position = 47.309820 N 9.986508 E
| Position oben =
def test_RodelbahnboxDictConverter(self):
v = wrpylib.wrmwmarkup.RodelbahnboxDictConverter()
other = collections.OrderedDict([
- (u'Position', (47.30982, 9.986508)),
- (u'Position oben', (None, None)),
- (u'Höhe oben', 1244),
- (u'Position unten', (None, None)),
- (u'Höhe unten', 806),
- (u'Länge', 5045),
- (u'Schwierigkeit', None),
- (u'Lawinen', 3),
- (u'Betreiber', None),
- (u'Öffentliche Anreise', 6),
- (u'Aufstieg möglich', True),
- (u'Aufstieg getrennt', (0.0, None)),
- (u'Gehzeit', 105),
- (u'Aufstiegshilfe', (False, None)),
- (u'Beleuchtungsanlage', (0.0, None)),
- (u'Beleuchtungstage', (None, None)),
- (u'Rodelverleih', (True, u'Ja')),
- (u'Gütesiegel', None),
- (u'Webauskunft', None),
- (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
- (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
- (u'In Übersichtskarte', True),
- (u'Forumid', 72)])
+ ('Position', (47.30982, 9.986508)),
+ ('Position oben', (None, None)),
+ ('Höhe oben', 1244),
+ ('Position unten', (None, None)),
+ ('Höhe unten', 806),
+ ('Länge', 5045),
+ ('Schwierigkeit', None),
+ ('Lawinen', 3),
+ ('Betreiber', None),
+ ('Öffentliche Anreise', 6),
+ ('Aufstieg möglich', True),
+ ('Aufstieg getrennt', (0.0, None)),
+ ('Gehzeit', 105),
+ ('Aufstiegshilfe', (False, None)),
+ ('Beleuchtungsanlage', (0.0, None)),
+ ('Beleuchtungstage', (None, None)),
+ ('Rodelverleih', (True, 'Ja')),
+ ('Gütesiegel', None),
+ ('Webauskunft', None),
+ ('Telefonauskunft', '+43-664-1808482 (Bergkristallhütte)'),
+ ('Bild', 'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ ('In Übersichtskarte', True),
+ ('Forumid', 72)])
sledrun = v.to_python(other)
assert sledrun.forum_id == 72
other2 = v.from_python(sledrun)
def test_RodelbahnboxValidator(self):
v = wrpylib.wrmwmarkup.RodelbahnboxValidator()
- wikitext = textwrap.dedent(u'''\
+ wikitext = textwrap.dedent('''\
{{Rodelbahnbox
| Position = 47.309820 N 9.986508 E
| Position oben =
sledrun = v.to_python(wikitext)
wikitext2 = v.from_python(sledrun)
assert wikitext == wikitext2
- wikitext = textwrap.dedent(u'''\
+ wikitext = textwrap.dedent('''\
{{Rodelbahnbox
| Position =
| Position oben =
def test_gasthausbox_to_inn(self):
- wikitext = u'''{{Gasthausbox
+ wikitext = '''{{Gasthausbox
| Position = 47.295549 N 9.986970 E
| Höhe = 1250
| Betreiber =
def test_GasthausboxDictConverter(self):
v = wrpylib.wrmwmarkup.GasthausboxDictConverter()
other = collections.OrderedDict([
- (u'Position', (47.295549, 9.986970)),
- (u'Höhe', 1250),
- (u'Betreiber', None),
- (u'Sitzplätze', None),
- (u'Übernachtung', (None, None)),
- (u'Rauchfrei', (True, False)),
- (u'Rodelverleih', (None, None)),
- (u'Handyempfang', u'A1; T-Mobile/Telering'),
- (u'Homepage', u'http://www.bergkristallhuette.com/'),
- (u'E-Mail', u'bergkristallhuette@gmx.at'),
- (u'Telefon', u'+43-664-1808482'),
- (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
- (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
+ ('Position', (47.295549, 9.986970)),
+ ('Höhe', 1250),
+ ('Betreiber', None),
+ ('Sitzplätze', None),
+ ('Übernachtung', (None, None)),
+ ('Rauchfrei', (True, False)),
+ ('Rodelverleih', (None, None)),
+ ('Handyempfang', 'A1; T-Mobile/Telering'),
+ ('Homepage', 'http://www.bergkristallhuette.com/'),
+ ('E-Mail', 'bergkristallhuette@gmx.at'),
+ ('Telefon', '+43-664-1808482'),
+ ('Bild', 'Bergkritsallhütte 2009-02-07.JPG'),
+ ('Rodelbahnen', '[[Bergkristallhütte]]')])
inn = v.to_python(other)
- assert inn.homepage == u'http://www.bergkristallhuette.com/'
+ assert inn.homepage == 'http://www.bergkristallhuette.com/'
other2 = v.from_python(inn)
assert other == other2
def test_GasthausboxValidator(self):
v = wrpylib.wrmwmarkup.GasthausboxValidator()
- wikitext = textwrap.dedent(u'''\
+ wikitext = textwrap.dedent('''\
{{Gasthausbox
| Position = 47.295549 N 9.986970 E
| Höhe = 1250
def test_googlemap_to_wrmap(self):
- wikitext = u'''
+ wikitext = '''
<googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
(Parkplatz)47.114958,11.266026
Erster Parkplatz
assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
assert json['features'][1]['properties']['type'] == 'gasthaus'
- assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
+ assert json['features'][1]['properties']['name'] == 'Alt Bärnbad (Gasthaus)'
assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
assert json['features'][2]['properties']['type'] == 'rodelbahn'
assert json['features'][2]['geometry']['coordinates'] == [
def test_parse_wrmap(self):
- wikitext = u'''
+ wikitext = '''
<wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
<gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
<parkplatz>47.245789 11.238971</parkplatz>
assert json['properties']['width'] == 700
assert json['properties']['height'] == 400
assert json['features'][0]['properties']['type'] == 'gasthaus'
- assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
- assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
+ assert json['features'][0]['properties']['name'] == 'Rosskogelhütte'
+ assert json['features'][0]['properties']['wiki'] == 'Rosskogelhütte'
assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
assert json['features'][1]['properties']['type'] == 'parkplatz'
assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
assert json['features'][2]['properties']['type'] == 'haltestelle'
- assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
+ assert json['features'][2]['properties']['name'] == 'Oberperfuss Rangger Köpfl Lift'
assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
assert json['features'][3]['properties']['type'] == 'rodelbahn'
assert json['features'][3]['geometry']['coordinates'] == [
'geometry': {
'type': 'Point',
'coordinates': [11.190454, 47.240689]},
- 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
+ 'properties': {'type': 'gasthaus', 'name': 'Rosskogelhütte', 'wiki': 'Rosskogelhütte'}
}, {
'type': 'Feature',
'geometry': {
'geometry': {
'type': 'Point',
'coordinates': [11.238283, 47.245711]},
- 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
+ 'properties': {'type': 'haltestelle', 'name': 'Oberperfuss Rangger Köpfl Lift'}
}, {
'type': 'Feature',
'geometry': {
}
wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
- assert wikitext == textwrap.dedent(u'''\
+ assert wikitext == textwrap.dedent('''\
<wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
<gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
v = wrpylib.wrvalidators.OrderedSchema()
v.pre_validators = [formencode.Validator()]
v.chained_validators = [formencode.Validator()]
- v.add_field(u'c', formencode.Validator())
- v.add_field(u'b', formencode.Validator())
- v.add_field(u'a', formencode.Validator())
- v.add_field(u'd', formencode.Validator())
+ v.add_field('c', formencode.Validator())
+ v.add_field('b', formencode.Validator())
+ v.add_field('a', formencode.Validator())
+ v.add_field('d', formencode.Validator())
other = collections.OrderedDict([('d', 'd'), ('b', 'b'), ('a', 'a'), ('c', 'c')])
python = v.to_python(other)
- assert python.keys() == other.keys()
- assert python.values() == other.values()
+ assert list(python.keys()) == list(other.keys())
+ assert list(python.values()) == list(other.values())
other2 = v.from_python(python)
- assert other.keys() == other2.keys()
- assert other.values() == other2.values()
+ assert list(other.keys()) == list(other2.keys())
+ assert list(other.values()) == list(other2.values())
def test_NoneValidator(self):
v = wrpylib.wrvalidators.NoneValidator(wrpylib.wrvalidators.Unicode())
- assert v.to_python(u'') == None
- assert v.from_python(None) == u''
+ assert v.to_python('') == None
+ assert v.from_python(None) == ''
# test_NeinValidator
def test_UnsignedNone(self):
v = wrpylib.wrvalidators.UnsignedNone()
- assert v.to_python(u'42') == 42
- assert v.to_python(u'') == None
- assert v.from_python(42) == u'42'
- assert v.from_python(None) == u''
+ assert v.to_python('42') == 42
+ assert v.to_python('') == None
+ assert v.from_python(42) == '42'
+ assert v.from_python(None) == ''
# test_UnsignedNeinNone
def test_GermanTristateTuple(self):
v = wrpylib.wrvalidators.GermanTristateTuple()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Ja') == (True, False)
- assert v.to_python(u'Nein') == (False, True)
- assert v.to_python(u'Teilweise') == (True, True)
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, True)) == u'Nein'
- assert v.from_python((True, False)) == u'Ja'
- assert v.from_python((True, True)) == u'Teilweise'
+ assert v.to_python('') == (None, None)
+ assert v.to_python('Ja') == (True, False)
+ assert v.to_python('Nein') == (False, True)
+ assert v.to_python('Teilweise') == (True, True)
+ assert v.from_python((None, None)) == ''
+ assert v.from_python((False, True)) == 'Nein'
+ assert v.from_python((True, False)) == 'Ja'
+ assert v.from_python((True, True)) == 'Teilweise'
def test_GermanTristateFloat(self):
v = wrpylib.wrvalidators.GermanTristateFloat()
- assert v.to_python(u'') == None
- assert v.to_python(u'Ja') == 1.0
- assert v.to_python(u'Nein') == 0.0
- assert v.to_python(u'Teilweise') == 0.5
- assert v.from_python(None) == u''
- assert v.from_python(0.0) == u'Nein'
- assert v.from_python(1.0) == u'Ja'
- assert v.from_python(0.5) == u'Teilweise'
+ assert v.to_python('') == None
+ assert v.to_python('Ja') == 1.0
+ assert v.to_python('Nein') == 0.0
+ assert v.to_python('Teilweise') == 0.5
+ assert v.from_python(None) == ''
+ assert v.from_python(0.0) == 'Nein'
+ assert v.from_python(1.0) == 'Ja'
+ assert v.from_python(0.5) == 'Teilweise'
# test_ValueComment
def test_ValueCommentList(self):
v = wrpylib.wrvalidators.ValueCommentList()
- assert v.to_python(u'abc') == [(u'abc', None)]
- assert v.to_python(u'abc def') == [(u'abc def', None)]
- assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
- assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
- assert v.to_python(u'value1 (comment); value2') == [(u'value1', u'comment'), (u'value2', None)]
- assert v.to_python(u'value1 (comment1); value2; value3 (comment3)') == [(u'value1', u'comment1'), (u'value2', None), ('value3', 'comment3')]
- assert v.to_python(u'value1 (comment1); [[link (linkcomment)]] (not easy)') == [(u'value1', u'comment1'), (u'[[link (linkcomment)]]', u'not easy')]
+ assert v.to_python('abc') == [('abc', None)]
+ assert v.to_python('abc def') == [('abc def', None)]
+ assert v.to_python('value (comment)') == [('value', 'comment')]
+ assert v.to_python('value (comment)') == [('value', 'comment')]
+ assert v.to_python('value1 (comment); value2') == [('value1', 'comment'), ('value2', None)]
+ assert v.to_python('value1 (comment1); value2; value3 (comment3)') == [('value1', 'comment1'), ('value2', None), ('value3', 'comment3')]
+ assert v.to_python('value1 (comment1); [[link (linkcomment)]] (not easy)') == [('value1', 'comment1'), ('[[link (linkcomment)]]', 'not easy')]
# test_GenericDateTime
def test_GeoNone(self):
- coord = u'47.076207 N 11.453553 E'
+ coord = '47.076207 N 11.453553 E'
v = wrpylib.wrvalidators.GeoNone()
(lat, lon) = v.to_python(coord)
assert lat == 47.076207
assert lon == 11.453553
- assert v.to_python(u'') == (None, None)
+ assert v.to_python('') == (None, None)
assert v.from_python((lat, lon)) == coord
- assert v.from_python((None, None)) == u''
+ assert v.from_python((None, None)) == ''
# test_MultiGeo
def test_GermanPublicTransport(self):
v = wrpylib.wrvalidators.GermanPublicTransport()
- assert v.to_python(u'') is None
- assert v.to_python(u'Sehr gut') == 1
- assert v.to_python(u'Gut') == 2
- assert v.to_python(u'Mittelmäßig') == 3
- assert v.to_python(u'Schlecht') == 4
- assert v.to_python(u'Nein') == 5
- assert v.to_python(u'Ja') == 6
-
- assert v.from_python(None) == u''
- assert v.from_python(1) == u'Sehr gut'
- assert v.from_python(2) == u'Gut'
- assert v.from_python(3) == u'Mittelmäßig'
- assert v.from_python(4) == u'Schlecht'
- assert v.from_python(5) == u'Nein'
- assert v.from_python(6) == u'Ja'
- assert v.from_python(1l) == u'Sehr gut'
+ assert v.to_python('') is None
+ assert v.to_python('Sehr gut') == 1
+ assert v.to_python('Gut') == 2
+ assert v.to_python('Mittelmäßig') == 3
+ assert v.to_python('Schlecht') == 4
+ assert v.to_python('Nein') == 5
+ assert v.to_python('Ja') == 6
+
+ assert v.from_python(None) == ''
+ assert v.from_python(1) == 'Sehr gut'
+ assert v.from_python(2) == 'Gut'
+ assert v.from_python(3) == 'Mittelmäßig'
+ assert v.from_python(4) == 'Schlecht'
+ assert v.from_python(5) == 'Nein'
+ assert v.from_python(6) == 'Ja'
+ assert v.from_python(1) == 'Sehr gut'
# test_GermanTristateFloatComment
def test_UrlNeinNone(self):
v = wrpylib.wrvalidators.UrlNeinNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
+ assert v.to_python('') == None
+ assert v.to_python('Nein') == 'Nein'
+ assert v.to_python('http://www.höttingeralm.at') == 'http://www.höttingeralm.at'
+ assert v.from_python(None) == ''
+ assert v.from_python('Nein') == 'Nein'
+ assert v.from_python('http://www.höttingeralm.at') == 'http://www.höttingeralm.at'
def test_ValueCommentListNeinLoopNone(self):
v = wrpylib.wrvalidators.ValueCommentListNeinLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
+ assert v.to_python('') == None
+ assert v.to_python('Nein') == 'Nein'
+ assert v.to_python('T-Mobile (gut); A1') == 'T-Mobile (gut); A1'
+ assert v.from_python(None) == ''
+ assert v.from_python('Nein') == 'Nein'
+ assert v.from_python('T-Mobile (gut); A1') == 'T-Mobile (gut); A1'
# test_PhoneNumber
def test_PhoneCommentListNeinLoopNone(self):
v = wrpylib.wrvalidators.PhoneCommentListNeinLoopNone(comments_are_optional=True)
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+ assert v.to_python('') == None
+ assert v.to_python('Nein') == 'Nein'
+ assert v.to_python('+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == '+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+ assert v.from_python(None) == ''
+ assert v.from_python('Nein') == 'Nein'
+ assert v.from_python('+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == '+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
def test_MaskedEmail(self):
v = wrpylib.wrvalidators.MaskedEmail()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'abc.def@example.com') == (u'abc.def@example.com', False)
- assert v.to_python(u'abc.def(at)example.com') == (u'abc.def@example.com', True)
- assert v.from_python((None, None)) == u''
- assert v.from_python((u'abc.def@example.com', False)) == u'abc.def@example.com'
- assert v.from_python((u'abc.def@example.com', True)) == u'abc.def(at)example.com'
+ assert v.to_python('') == (None, None)
+ assert v.to_python('abc.def@example.com') == ('abc.def@example.com', False)
+ assert v.to_python('abc.def(at)example.com') == ('abc.def@example.com', True)
+ assert v.from_python((None, None)) == ''
+ assert v.from_python(('abc.def@example.com', False)) == 'abc.def@example.com'
+ assert v.from_python(('abc.def@example.com', True)) == 'abc.def(at)example.com'
def test_EmailCommentListNeinLoopNone(self):
v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'first@example.com') == u'first@example.com'
- assert v.to_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'first@example.com') == u'first@example.com'
- assert v.from_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
- testvalue = u'abc.def(at)example.com (comment)'
+ assert v.to_python('') == None
+ assert v.to_python('Nein') == 'Nein'
+ assert v.to_python('first@example.com') == 'first@example.com'
+ assert v.to_python('first@example.com (Nur Winter); second@example.com') == 'first@example.com (Nur Winter); second@example.com'
+ assert v.from_python(None) == ''
+ assert v.from_python('Nein') == 'Nein'
+ assert v.from_python('first@example.com') == 'first@example.com'
+ assert v.from_python('first@example.com (Nur Winter); second@example.com') == 'first@example.com (Nur Winter); second@example.com'
+ testvalue = 'abc.def(at)example.com (comment)'
try:
v.to_python(testvalue)
assert False
def test_WikiPageListLoopNone(self):
v = wrpylib.wrvalidators.WikiPageListLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
- assert v.from_python(None) == u''
- assert v.from_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+ assert v.to_python('') == None
+ assert v.to_python('[[Birgitzer Alm]]; [[Kemater Alm]]') == '[[Birgitzer Alm]]; [[Kemater Alm]]'
+ assert v.from_python(None) == ''
+ assert v.from_python('[[Birgitzer Alm]]; [[Kemater Alm]]') == '[[Birgitzer Alm]]; [[Kemater Alm]]'
# test_TupleSecondValidator
def test_BoolUnicodeTupleValidator(self):
v = wrpylib.wrvalidators.BoolUnicodeTupleValidator()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'any text') == (True, u'any text')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'any text')) == u'any text'
+ assert v.to_python('') == (None, None)
+ assert v.to_python('Nein') == (False, None)
+ assert v.to_python('any text') == (True, 'any text')
+ assert v.from_python((None, None)) == ''
+ assert v.from_python((False, None)) == 'Nein'
+ assert v.from_python((True, 'any text')) == 'any text'
def test_GermanLift(self):
v = wrpylib.wrvalidators.GermanLift()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'Sessellift (4 Euro)') == (True, u'Sessellift (4 Euro)')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'Sessellift (4 Euro)')) == u'Sessellift (4 Euro)'
+ assert v.to_python('') == (None, None)
+ assert v.to_python('Nein') == (False, None)
+ assert v.to_python('Sessellift (4 Euro)') == (True, 'Sessellift (4 Euro)')
+ assert v.from_python((None, None)) == ''
+ assert v.from_python((False, None)) == 'Nein'
+ assert v.from_python((True, 'Sessellift (4 Euro)')) == 'Sessellift (4 Euro)'
def test_SledRental(self):
v = wrpylib.wrvalidators.SledRental()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'Ja') == (True, u'Ja')
- assert v.to_python(u'Talstation (nur mit Ticket); Schneealm') == (True, u'Talstation (nur mit Ticket); Schneealm')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'Talstation (nur mit Ticket); Schneealm')) == u'Talstation (nur mit Ticket); Schneealm'
- assert v.from_python((True, u'Ja')) == u'Ja'
+ assert v.to_python('') == (None, None)
+ assert v.to_python('Nein') == (False, None)
+ assert v.to_python('Ja') == (True, 'Ja')
+ assert v.to_python('Talstation (nur mit Ticket); Schneealm') == (True, 'Talstation (nur mit Ticket); Schneealm')
+ assert v.from_python((None, None)) == ''
+ assert v.from_python((False, None)) == 'Nein'
+ assert v.from_python((True, 'Talstation (nur mit Ticket); Schneealm')) == 'Talstation (nur mit Ticket); Schneealm'
+ assert v.from_python((True, 'Ja')) == 'Ja'
def test_RodelbahnboxDictValidator(self):
v = wrpylib.wrvalidators.RodelbahnboxDictValidator()
other = collections.OrderedDict([
- (u'Position', u'47.309820 N 9.986508 E'),
- (u'Position oben', u''),
- (u'Höhe oben', u'1244'),
- (u'Position unten', u''),
- (u'Höhe unten', u'806'),
- (u'Länge', u'5045'),
- (u'Schwierigkeit', u''),
- (u'Lawinen', u'gelegentlich'),
- (u'Betreiber', u''),
- (u'Öffentliche Anreise', u'Ja'),
- (u'Aufstieg möglich', u'Ja'),
- (u'Aufstieg getrennt', u'Nein'),
- (u'Gehzeit', u'105'),
- (u'Aufstiegshilfe', u'Nein'),
- (u'Beleuchtungsanlage', u'Nein'),
- (u'Beleuchtungstage', u''),
- (u'Rodelverleih', u'Ja'),
- (u'Gütesiegel', u''),
- (u'Webauskunft', u''),
- (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
- (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
- (u'In Übersichtskarte', u'Ja'),
- (u'Forumid', u'72')])
+ ('Position', '47.309820 N 9.986508 E'),
+ ('Position oben', ''),
+ ('Höhe oben', '1244'),
+ ('Position unten', ''),
+ ('Höhe unten', '806'),
+ ('Länge', '5045'),
+ ('Schwierigkeit', ''),
+ ('Lawinen', 'gelegentlich'),
+ ('Betreiber', ''),
+ ('Öffentliche Anreise', 'Ja'),
+ ('Aufstieg möglich', 'Ja'),
+ ('Aufstieg getrennt', 'Nein'),
+ ('Gehzeit', '105'),
+ ('Aufstiegshilfe', 'Nein'),
+ ('Beleuchtungsanlage', 'Nein'),
+ ('Beleuchtungstage', ''),
+ ('Rodelverleih', 'Ja'),
+ ('Gütesiegel', ''),
+ ('Webauskunft', ''),
+ ('Telefonauskunft', '+43-664-1808482 (Bergkristallhütte)'),
+ ('Bild', 'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ ('In Übersichtskarte', 'Ja'),
+ ('Forumid', '72')])
python = v.to_python(other, None)
other2 = v.from_python(python, None)
assert other == other2
def test_GasthausboxDictValidator(self):
v = wrpylib.wrvalidators.GasthausboxDictValidator()
other = collections.OrderedDict([
- (u'Position', u'47.295549 N 9.986970 E'),
- (u'Höhe', u'1250'),
- (u'Betreiber', u''),
- (u'Sitzplätze', u''),
- (u'Übernachtung', u''),
- (u'Rauchfrei', u'Nein'),
- (u'Rodelverleih', u''),
- (u'Handyempfang', u'A1; T-Mobile/Telering'),
- (u'Homepage', u'http://www.bergkristallhuette.com/'),
- (u'E-Mail', u'bergkristallhuette@gmx.at'),
- (u'Telefon', u'+43-664-1808482'),
- (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
- (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
+ ('Position', '47.295549 N 9.986970 E'),
+ ('Höhe', '1250'),
+ ('Betreiber', ''),
+ ('Sitzplätze', ''),
+ ('Übernachtung', ''),
+ ('Rauchfrei', 'Nein'),
+ ('Rodelverleih', ''),
+ ('Handyempfang', 'A1; T-Mobile/Telering'),
+ ('Homepage', 'http://www.bergkristallhuette.com/'),
+ ('E-Mail', 'bergkristallhuette@gmx.at'),
+ ('Telefon', '+43-664-1808482'),
+ ('Bild', 'Bergkritsallhütte 2009-02-07.JPG'),
+ ('Rodelbahnen', '[[Bergkristallhütte]]')])
python = v.to_python(other, None)
other2 = v.from_python(python, None)
assert other == other2
def to_title(value):
"""Line 2237 of includes/Title.php says: $this->mTextform = str_replace( '_', ' ', $dbkey );
No check for None because a missing title is an error."""
- return value.replace(u'_', u' ')
+ return value.replace('_', ' ')
(start, end) of the first occurence with start >= 0 and end > start.
(None, None) if the template is not found.
"""
- match = re.search(u"\{\{" + template_title + "\s*(\|[^\}]*)?\}\}", wikitext, re.DOTALL)
+ match = re.search("\{\{" + template_title + "\s*(\|[^\}]*)?\}\}", wikitext, re.DOTALL)
if match is None: return None, None
return match.start(), match.end()
(title, anonym_params, named_params) where title is the template title,
anonym_params is a list of anonymous parameters and named_params is a OrderedDict
of named parameters. Whitespace of the parameters is stripped."""
- if not value.startswith(u'{{'):
- raise formencode.Invalid(u'Template does not start with "{{"', value, state)
- if not value.endswith(u'}}'):
- raise formencode.Invalid(u'Template does not end with "}}"', value, state)
- parts = value[2:-2].split(u'|')
+ if not value.startswith('{{'):
+ raise formencode.Invalid('Template does not start with "{{"', value, state)
+ if not value.endswith('}}'):
+ raise formencode.Invalid('Template does not end with "}}"', value, state)
+ parts = value[2:-2].split('|')
# template name
title = self.strip(parts[0])
if len(title) == 0:
- raise formencode.Invalid(u'Empty template tilte.', value, state)
+ raise formencode.Invalid('Empty template tilte.', value, state)
del parts[0]
# anonymous parameters
anonym_params = []
while len(parts) > 0:
- equalsign_pos = parts[0].find(u'=')
+ equalsign_pos = parts[0].find('=')
if equalsign_pos >= 0: break # named parameter
anonym_params.append(self.strip(parts[0]))
del parts[0]
# named or numbered parameters
named_params = collections.OrderedDict()
while len(parts) > 0:
- equalsign_pos = parts[0].find(u'=')
+ equalsign_pos = parts[0].find('=')
if equalsign_pos < 0:
- raise formencode.Invalid(u'Anonymous parameter after named parameter.', value, state)
- key, sep, value = parts[0].partition(u'=')
+ raise formencode.Invalid('Anonymous parameter after named parameter.', value, state)
+ key, sep, value = parts[0].partition('=')
key = self.strip(key)
if len(key) == 0:
- raise formencode.Invalid(u'Empty key.', value, state)
- if named_params.has_key(key):
- raise formencode.Invalid(u'Duplicate key: "{0}"'.format(key), value, state)
+ raise formencode.Invalid('Empty key.', value, state)
+ if key in named_params:
+ raise formencode.Invalid('Duplicate key: "{0}"'.format(key), value, state)
named_params[key] = self.strip(value)
del parts[0]
where title is the template title, anonym_params is a list of anonymous parameters and
named_params is a dict or OrderedDict of named parameters."""
title, anonym_params, named_params = value
- pipe_char, equal_char, end_char = (u'\n| ', u' = ', u'\n}}') if self.as_table else (u'|', u'=', u'}}')
- parts = [u"{{" + title]
+ pipe_char, equal_char, end_char = ('\n| ', ' = ', '\n}}') if self.as_table else ('|', '=', '}}')
+ parts = ["{{" + title]
parts += anonym_params
as_table_keylen = self.as_table_keylen
if self.as_table and as_table_keylen is None:
- as_table_keylen = max(map(len, named_params.iterkeys()))
- for k, v in named_params.iteritems():
+ as_table_keylen = max(list(map(len, iter(named_params.keys()))))
+ for k, v in named_params.items():
if self.as_table:
k = k.ljust(as_table_keylen)
parts.append((k + equal_char + v).rstrip())
try:
title, anonym_params, named_params = TemplateValidator().to_python(template)
parameters = dict(named_params)
- for i in xrange(len(anonym_params)):
- parameters[unicode(i+1)] = anonym_params[i]
+ for i in range(len(anonym_params)):
+ parameters[str(i+1)] = anonym_params[i]
except formencode.Invalid as e:
raise ValueError(e[0])
return title, parameters
:param as_table: formats the returned template in one row for each parameter
:param as_table_keylen: length of the key field. None for "automatic".
:return: unicode template"""
- named_params = collections.OrderedDict(zip(named_param_keys, named_param_values))
+ named_params = collections.OrderedDict(list(zip(named_param_keys, named_param_values)))
return TemplateValidator(as_table=as_table, as_table_keylen=as_table_keylen).from_python((template_title, anonym_params, named_params))
(None, None, None, None) is returned.
"""
# Find start tag
- regexp_starttag = re.compile(u"<{0}.*?(/?)>".format(tagname), re.DOTALL)
+ regexp_starttag = re.compile("<{0}.*?(/?)>".format(tagname), re.DOTALL)
match_starttag = regexp_starttag.search(wikitext, pos)
if match_starttag is None:
return None, None, None, None
return match_starttag.start(), None, None, match_starttag.end()
# tag with content
- regexp_endtag = re.compile(u'</{0}>'.format(tagname), re.DOTALL)
+ regexp_endtag = re.compile('</{0}>'.format(tagname), re.DOTALL)
match_endtag = regexp_endtag.search(wikitext, match_starttag.end())
if match_endtag is None:
# No closing tag - error in wikitext
def parse_coord(line):
"""Returns (lon, lat, symbol, title). If symbol or text is not present, None is returned."""
- match = re.match(u'\(([^)]+)\) ?([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+), ?(.*)', line)
+ match = re.match('\(([^)]+)\) ?([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+), ?(.*)', line)
if not match is None: return (float(match.group(3)), float(match.group(2)), match.group(1), match.group(4))
- match = re.match(u'\(([^)]+)\) ?([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+)', line)
+ match = re.match('\(([^)]+)\) ?([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+)', line)
if not match is None: return (float(match.group(3)), float(match.group(2)), match.group(1), None)
- match = re.match(u'([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+), ?(.*)', line)
+ match = re.match('([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+), ?(.*)', line)
if not match is None: return (float(match.group(2)), float(match.group(1)), None, match.group(3))
- match = re.match(u'([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+)', line)
+ match = re.match('([0-9]{1,2}\.[0-9]+), ?([0-9]{1,2}\.[0-9]+)', line)
if not match is None: return (float(match.group(2)), float(match.group(1)), None, None)
- return ParseError(u'Could not parse line ' + line)
+ return ParseError('Could not parse line ' + line)
start, content, endtag, end = find_tag(wikitext, 'googlemap')
if start is None:
- raise ParseError(u'<googlemap> tag not found.')
+ raise ParseError('<googlemap> tag not found.')
if content is None:
xml_only = wikitext[start:endtag]
else:
gm = xml.etree.ElementTree.XML(xml_only.encode('UTF8'))
except xml.etree.ElementTree.ParseError as e:
row, column = e.position
- raise ParseError(u"XML parse error in <googlemap ...>.")
+ raise ParseError("XML parse error in <googlemap ...>.")
# parse attributes
attributes = {}
if gm.get(key) is not None:
attributes[key] = int(gm.get(key))
except ValueError as error:
- raise ParseError(u'Error at parsing attribute {0} of <googlemap>: {1}'.format(key, unicode(error)))
+ raise ParseError('Error at parsing attribute {0} of <googlemap>: {1}'.format(key, str(error)))
# parse points and lines
coords = []
# Handle a path
if is_path(line):
- match = re.match(u'([0-9]#[0-9a-fA-F]{8})', line)
+ match = re.match('([0-9]#[0-9a-fA-F]{8})', line)
style = match.group(1)
local_coords = []
while i < len(lines):
coords.append((lon, lat, symbol, title))
continue
- raise ParseError(u'Unknown line syntax: ' + line)
+ raise ParseError('Unknown line syntax: ' + line)
return (attributes, coords, paths)
transaction = connection.begin()
# Query all sled runs
- q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to==u'Rodelbahn'))
+ q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to=='Rodelbahn'))
sledrun_pages = connection.execute(q)
# Original SQL:
# sql = u"select page_id, rev_id, old_id, page_title, old_text, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
start, end, sledrun = wrmwmarkup.rodelbahnbox_to_sledrun(sledrun_page.old_text)
sledrun.page_id = sledrun_page.page_id
sledrun.page_title = sledrun_page.page_title
- sledrun.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==sledrun_page.page_id) & (categorylinks.c.cl_to == u'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
+ sledrun.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==sledrun_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
connection.execute(wrsledruncache.insert(sledrun.__dict__))
except (RuntimeError, formencode.Invalid) as e:
transaction.rollback()
- error_msg = u"Error at sled run '{0}': {1}".format(sledrun_page.page_title, unicode(e))
+ error_msg = "Error at sled run '{0}': {1}".format(sledrun_page.page_title, str(e))
raise UpdateCacheError(error_msg, sledrun_page.page_title, e)
transaction.commit()
transaction = connection.begin()
# Query all inns
- q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to==u'Gasthaus'))
+ q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to=='Gasthaus'))
inn_pages = connection.execute(q)
# Delete all existing entries in wrinncache
start, end, inn = wrmwmarkup.gasthausbox_to_inn(inn_page.old_text)
inn.page_id = inn_page.page_id
inn.page_title = inn_page.page_title
- inn.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==inn_page.page_id) & (categorylinks.c.cl_to == u'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
+ inn.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==inn_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
connection.execute(wrinncache.insert(inn.__dict__))
except (RuntimeError, formencode.Invalid) as e:
transaction.rollback()
- error_msg = u"Error as inn '{0}': {1}".format(inn_page.page_title, unicode(e))
+ error_msg = "Error as inn '{0}': {1}".format(inn_page.page_title, str(e))
raise UpdateCacheError(error_msg, inn_page.page_title, e)
transaction.commit()
transaction = connection.begin()
# Query all sledruns
- q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to==u'Rodelbahn'))
+ q = select([page, categorylinks, revision, text], (page.c.page_latest==revision.c.rev_id) & (text.c.old_id==revision.c.rev_text_id) & (categorylinks.c.cl_from==page.c.page_id) & (categorylinks.c.cl_to=='Rodelbahn'))
sledrun_pages = connection.execute(q)
# Original SQL:
# sql = u"select page_id, rev_id, old_id, page_title, old_text, 'In_Arbeit' in (select cl_to from categorylinks where cl_from=page_id) as under_construction from page, revision, text, categorylinks where page_latest=rev_id and old_id=rev_text_id and cl_from=page_id and cl_to='Rodelbahn' order by page_title"
if properties['type'] in wrmwmarkup.WRMAP_POINT_TYPES:
lon, lat = coordinates
label = properties.get('name')
- point_types = {u'gasthaus': u'hut', u'haltestelle': u'busstop', u'parkplatz': u'carpark', u'achtung': u'warning', u'foto': u'photo', u'verleih': u'rental', u'punkt': u'point'}
+ point_types = {'gasthaus': 'hut', 'haltestelle': 'busstop', 'parkplatz': 'carpark', 'achtung': 'warning', 'foto': 'photo', 'verleih': 'rental', 'punkt': 'point'}
point_type = point_types[properties['type']]
- sql = u'insert into wrmappointcache (page_id, type, point, label) values (%s, %s, POINT(%s, %s), %s)'
+ sql = 'insert into wrmappointcache (page_id, type, point, label) values (%s, %s, POINT(%s, %s), %s)'
connection.execute(sql, (sledrun_page.page_id, point_type, lon, lat, label))
# Paths
elif properties['type'] in wrmwmarkup.WRMAP_LINE_TYPES:
- path_types = {u'rodelbahn': u'sledrun', u'gehweg': u'walkup', u'alternative': u'alternative', u'lift': u'lift', u'anfahrt': u'recommendedcarroute', u'linie': u'line'}
+ path_types = {'rodelbahn': 'sledrun', 'gehweg': 'walkup', 'alternative': 'alternative', 'lift': 'lift', 'anfahrt': 'recommendedcarroute', 'linie': 'line'}
path_type = path_types[properties['type']]
- path = u", ".join(["{0} {1}".format(lon, lat) for lon, lat in coordinates])
- path = u'LineString({0})'.format(path)
- if path_type == u'recommendedcarroute': continue
- sql = u'insert into wrmappathcache (path, page_id, type) values (GeomFromText(%s), %s, %s)'
+ path = ", ".join(["{0} {1}".format(lon, lat) for lon, lat in coordinates])
+ path = 'LineString({0})'.format(path)
+ if path_type == 'recommendedcarroute': continue
+ sql = 'insert into wrmappathcache (path, page_id, type) values (GeomFromText(%s), %s, %s)'
connection.execute(sql, (path, sledrun_page.page_id, path_type))
else:
- raise RuntimeError(u'Unknown feature type {0}'.format(properties['type']))
+ raise RuntimeError('Unknown feature type {0}'.format(properties['type']))
except RuntimeError as e:
- error_msg = u"Error at sledrun '{0}': {1}".format(sledrun_page.page_title, unicode(e))
+ error_msg = "Error at sledrun '{0}': {1}".format(sledrun_page.page_title, str(e))
transaction.rollback()
raise UpdateCacheError(error_msg, sledrun_page.page_title, e)
transaction.commit()
class Sledrun(object):
pass
sledrun = Sledrun()
- for k, v in props.iteritems():
- if k == u'Position': sledrun.position_latitude, sledrun.position_longitude = v
- elif k == u'Position oben': sledrun.top_latitude, sledrun.top_longitude = v
- elif k == u'Höhe oben': sledrun.top_elevation = v
- elif k == u'Position unten': sledrun.bottom_latitude, sledrun.bottom_longitude = v
- elif k == u'Höhe unten': sledrun.bottom_elevation = v
- elif k == u'Länge': sledrun.length = v
- elif k == u'Schwierigkeit': sledrun.difficulty = v
- elif k == u'Lawinen': sledrun.avalanches = v
- elif k == u'Betreiber': sledrun.operator = v
- elif k == u'Öffentliche Anreise': sledrun.public_transport = v
- elif k == u'Aufstieg möglich': sledrun.walkup_possible = v
- elif k == u'Aufstieg getrennt': sledrun.walkup_separate, sledrun.walkup_separate_comment = v
- elif k == u'Gehzeit': sledrun.walkup_time = v
- elif k == u'Aufstiegshilfe': sledrun.lift, sledrun.lift_details = v
- elif k == u'Beleuchtungsanlage': sledrun.night_light, sledrun.night_light_comment = v
- elif k == u'Beleuchtungstage': sledrun.night_light_days, sledrun.night_light_days_comment = v
- elif k == u'Rodelverleih': sledrun.sled_rental, sledrun.sled_rental_comment = v
- elif k == u'Gütesiegel': sledrun.cachet = v
- elif k == u'Webauskunft': sledrun.information_web = v
- elif k == u'Telefonauskunft': sledrun.information_phone = v
- elif k == u'Bild': sledrun.image = v
- elif k == u'In Übersichtskarte': sledrun.show_in_overview = v
- elif k == u'Forumid': sledrun.forum_id = v
+ for k, v in props.items():
+ if k == 'Position': sledrun.position_latitude, sledrun.position_longitude = v
+ elif k == 'Position oben': sledrun.top_latitude, sledrun.top_longitude = v
+ elif k == 'Höhe oben': sledrun.top_elevation = v
+ elif k == 'Position unten': sledrun.bottom_latitude, sledrun.bottom_longitude = v
+ elif k == 'Höhe unten': sledrun.bottom_elevation = v
+ elif k == 'Länge': sledrun.length = v
+ elif k == 'Schwierigkeit': sledrun.difficulty = v
+ elif k == 'Lawinen': sledrun.avalanches = v
+ elif k == 'Betreiber': sledrun.operator = v
+ elif k == 'Öffentliche Anreise': sledrun.public_transport = v
+ elif k == 'Aufstieg möglich': sledrun.walkup_possible = v
+ elif k == 'Aufstieg getrennt': sledrun.walkup_separate, sledrun.walkup_separate_comment = v
+ elif k == 'Gehzeit': sledrun.walkup_time = v
+ elif k == 'Aufstiegshilfe': sledrun.lift, sledrun.lift_details = v
+ elif k == 'Beleuchtungsanlage': sledrun.night_light, sledrun.night_light_comment = v
+ elif k == 'Beleuchtungstage': sledrun.night_light_days, sledrun.night_light_days_comment = v
+ elif k == 'Rodelverleih': sledrun.sled_rental, sledrun.sled_rental_comment = v
+ elif k == 'Gütesiegel': sledrun.cachet = v
+ elif k == 'Webauskunft': sledrun.information_web = v
+ elif k == 'Telefonauskunft': sledrun.information_phone = v
+ elif k == 'Bild': sledrun.image = v
+ elif k == 'In Übersichtskarte': sledrun.show_in_overview = v
+ elif k == 'Forumid': sledrun.forum_id = v
return sledrun
def from_python(self, value, state=None):
"""Converts a sledrun class to a dict of Rodelbahnbox properties. value is a sledrun instance."""
sledrun = value
r = collections.OrderedDict()
- r[u'Position'] = (sledrun.position_latitude, sledrun.position_longitude)
- r[u'Position oben'] = (sledrun.top_latitude, sledrun.top_longitude)
- r[u'Höhe oben'] = sledrun.top_elevation
- r[u'Position unten'] = (sledrun.bottom_latitude, sledrun.bottom_longitude)
- r[u'Höhe unten'] = sledrun.bottom_elevation
- r[u'Länge'] = sledrun.length
- r[u'Schwierigkeit'] = sledrun.difficulty
- r[u'Lawinen'] = sledrun.avalanches
- r[u'Betreiber'] = sledrun.operator
- r[u'Öffentliche Anreise'] = sledrun.public_transport
- r[u'Aufstieg möglich'] = sledrun.walkup_possible
- r[u'Aufstieg getrennt'] = (sledrun.walkup_separate, sledrun.walkup_separate_comment)
- r[u'Gehzeit'] = sledrun.walkup_time
- r[u'Aufstiegshilfe'] = (sledrun.lift, sledrun.lift_details)
- r[u'Beleuchtungsanlage'] = (sledrun.night_light, sledrun.night_light_comment)
- r[u'Beleuchtungstage'] = (sledrun.night_light_days, sledrun.night_light_days_comment)
- r[u'Rodelverleih'] = (sledrun.sled_rental, sledrun.sled_rental_comment)
- r[u'Gütesiegel'] = sledrun.cachet
- r[u'Webauskunft'] = sledrun.information_web
- r[u'Telefonauskunft'] = sledrun.information_phone
- r[u'Bild'] = sledrun.image
- r[u'In Übersichtskarte'] = sledrun.show_in_overview
- r[u'Forumid'] = sledrun.forum_id
+ r['Position'] = (sledrun.position_latitude, sledrun.position_longitude)
+ r['Position oben'] = (sledrun.top_latitude, sledrun.top_longitude)
+ r['Höhe oben'] = sledrun.top_elevation
+ r['Position unten'] = (sledrun.bottom_latitude, sledrun.bottom_longitude)
+ r['Höhe unten'] = sledrun.bottom_elevation
+ r['Länge'] = sledrun.length
+ r['Schwierigkeit'] = sledrun.difficulty
+ r['Lawinen'] = sledrun.avalanches
+ r['Betreiber'] = sledrun.operator
+ r['Öffentliche Anreise'] = sledrun.public_transport
+ r['Aufstieg möglich'] = sledrun.walkup_possible
+ r['Aufstieg getrennt'] = (sledrun.walkup_separate, sledrun.walkup_separate_comment)
+ r['Gehzeit'] = sledrun.walkup_time
+ r['Aufstiegshilfe'] = (sledrun.lift, sledrun.lift_details)
+ r['Beleuchtungsanlage'] = (sledrun.night_light, sledrun.night_light_comment)
+ r['Beleuchtungstage'] = (sledrun.night_light_days, sledrun.night_light_days_comment)
+ r['Rodelverleih'] = (sledrun.sled_rental, sledrun.sled_rental_comment)
+ r['Gütesiegel'] = sledrun.cachet
+ r['Webauskunft'] = sledrun.information_web
+ r['Telefonauskunft'] = sledrun.information_phone
+ r['Bild'] = sledrun.image
+ r['In Übersichtskarte'] = sledrun.show_in_overview
+ r['Forumid'] = sledrun.forum_id
return r
def to_python(self, value, state):
title, anonym_params, named_params = value
if title != self.template_title:
- raise formencode.Invalid(u'Template title has to be "{}".'.format(self.template_title), value, state)
+ raise formencode.Invalid('Template title has to be "{}".'.format(self.template_title), value, state)
if len(anonym_params) > 0:
- raise formencode.Invalid(u'No anonymous parameters are allowed in "{}".'.format(self.template_title), value, state)
+ raise formencode.Invalid('No anonymous parameters are allowed in "{}".'.format(self.template_title), value, state)
return named_params
def from_python(self, value, state):
class RodelbahnboxValidator(wrpylib.wrvalidators.RodelbahnboxDictValidator):
def __init__(self):
wrpylib.wrvalidators.RodelbahnboxDictValidator.__init__(self)
- self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=20), WinterrodelnTemplateDict(u'Rodelbahnbox')]
+ self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=20), WinterrodelnTemplateDict('Rodelbahnbox')]
self.chained_validators = [RodelbahnboxDictConverter()]
Raises a formencode.Invalid exception if the format is not OK or the Rodelbahnbox is not found.
:return: (start, end, sledrun) tuple of the Rodelbahnbox."""
# find Rodelbahnbox
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
- if start is None: raise formencode.Invalid(u"Rodelbahnbox nicht gefunden", wikitext, None)
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Rodelbahnbox')
+ if start is None: raise formencode.Invalid("Rodelbahnbox nicht gefunden", wikitext, None)
# convert to sledrun
if sledrun is None:
class Inn(object):
pass
inn = Inn()
- for k, v in props.iteritems():
- if k == u'Position': inn.position_latitude, inn.position_longitude = v
- elif k == u'Höhe': inn.position_elevation = v
- elif k == u'Betreiber': inn.operator = v
- elif k == u'Sitzplätze': inn.seats = v
- elif k == u'Übernachtung': inn.overnight, inn.overnight_comment = v
- elif k == u'Rauchfrei': inn.nonsmoker_area, inn.smoker_area = v
- elif k == u'Rodelverleih': inn.sled_rental, inn.sled_rental_comment = v
- elif k == u'Handyempfang': inn.mobile_provider = v
- elif k == u'Homepage': inn.homepage = v
- elif k == u'E-Mail': inn.email_list = v
- elif k == u'Telefon': inn.phone_list = v
- elif k == u'Bild': inn.image = v
- elif k == u'Rodelbahnen': inn.sledding_list = v
+ for k, v in props.items():
+ if k == 'Position': inn.position_latitude, inn.position_longitude = v
+ elif k == 'Höhe': inn.position_elevation = v
+ elif k == 'Betreiber': inn.operator = v
+ elif k == 'Sitzplätze': inn.seats = v
+ elif k == 'Übernachtung': inn.overnight, inn.overnight_comment = v
+ elif k == 'Rauchfrei': inn.nonsmoker_area, inn.smoker_area = v
+ elif k == 'Rodelverleih': inn.sled_rental, inn.sled_rental_comment = v
+ elif k == 'Handyempfang': inn.mobile_provider = v
+ elif k == 'Homepage': inn.homepage = v
+ elif k == 'E-Mail': inn.email_list = v
+ elif k == 'Telefon': inn.phone_list = v
+ elif k == 'Bild': inn.image = v
+ elif k == 'Rodelbahnen': inn.sledding_list = v
return inn
def from_python(self, value, state=None):
"""Converts an inn class to a dict of Gasthausbox properties. value is an Inn instance."""
inn = value
r = collections.OrderedDict()
- r[u'Position'] = (inn.position_latitude, inn.position_longitude)
- r[u'Höhe'] = inn.position_elevation
- r[u'Betreiber'] = inn.operator
- r[u'Sitzplätze'] = inn.seats
- r[u'Übernachtung'] = (inn.overnight, inn.overnight_comment)
- r[u'Rauchfrei'] = (inn.nonsmoker_area, inn.smoker_area)
- r[u'Rodelverleih'] = (inn.sled_rental, inn.sled_rental_comment)
- r[u'Handyempfang'] = inn.mobile_provider
- r[u'Homepage'] = inn.homepage
- r[u'E-Mail'] = inn.email_list
- r[u'Telefon'] = inn.phone_list
- r[u'Bild'] = inn.image
- r[u'Rodelbahnen'] = inn.sledding_list
+ r['Position'] = (inn.position_latitude, inn.position_longitude)
+ r['Höhe'] = inn.position_elevation
+ r['Betreiber'] = inn.operator
+ r['Sitzplätze'] = inn.seats
+ r['Übernachtung'] = (inn.overnight, inn.overnight_comment)
+ r['Rauchfrei'] = (inn.nonsmoker_area, inn.smoker_area)
+ r['Rodelverleih'] = (inn.sled_rental, inn.sled_rental_comment)
+ r['Handyempfang'] = inn.mobile_provider
+ r['Homepage'] = inn.homepage
+ r['E-Mail'] = inn.email_list
+ r['Telefon'] = inn.phone_list
+ r['Bild'] = inn.image
+ r['Rodelbahnen'] = inn.sledding_list
return r
class GasthausboxValidator(wrpylib.wrvalidators.GasthausboxDictValidator):
def __init__(self):
wrpylib.wrvalidators.GasthausboxDictValidator.__init__(self)
- self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=17), WinterrodelnTemplateDict(u'Gasthausbox')]
+ self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=17), WinterrodelnTemplateDict('Gasthausbox')]
self.chained_validators = [GasthausboxDictConverter()]
raises a formencode.Invalid exception if the format is not OK or the Gasthausbox is not found.
:return: (start, end, inn) tuple."""
# find Gasthausbox
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Gasthausbox')
- if start is None: raise formencode.Invalid(u"No 'Gasthausbox' found", wikitext, None)
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Gasthausbox')
+ if start is None: raise formencode.Invalid("No 'Gasthausbox' found", wikitext, None)
# convert to inn
if inn is None:
start, end = wrpylib.mwmarkup.find_template(wikitext, template_title)
if start is None: return (None,) * 5
title, params = wrpylib.mwmarkup.split_template(wikitext[start:end])
- lat, lon = wrpylib.wrvalidators.GeoNone().to_python(params[u'1'].strip())
- ele = wrpylib.wrvalidators.UnsignedNone().to_python(params[u'2'].strip())
+ lat, lon = wrpylib.wrvalidators.GeoNone().to_python(params['1'].strip())
+ ele = wrpylib.wrvalidators.UnsignedNone().to_python(params['2'].strip())
return start, end, lat, lon, ele
def create_template_latlon_ele(template_title, lat, lon, ele):
geo = wrpylib.wrvalidators.GeoNone().from_python((lat, lon))
- if len(geo) == 0: geo = u' '
+ if len(geo) == 0: geo = ' '
ele = wrpylib.wrvalidators.UnsignedNone().from_python(ele)
- if len(ele) == 0: ele = u' '
+ if len(ele) == 0: ele = ' '
return wrpylib.mwmarkup.create_template(template_title, [geo, ele])
def find_template_PositionOben(wikitext):
"""Same as find_template_latlon_ele with template '{{Position oben|47.076207 N 11.453553 E|1890}}'"""
- return find_template_latlon_ele(wikitext, u'Position oben')
+ return find_template_latlon_ele(wikitext, 'Position oben')
def create_template_PositionOben(lat, lon, ele):
- return create_template_latlon_ele(u'Position, oben', lat, lon, ele)
+ return create_template_latlon_ele('Position, oben', lat, lon, ele)
def find_template_PositionUnten(wikitext):
"""Same as find_template_latlon_ele with template '{{Position unten|47.076207 N 11.453553 E|1890}}'"""
- return find_template_latlon_ele(wikitext, u'Position unten')
+ return find_template_latlon_ele(wikitext, 'Position unten')
def find_template_unsigned(wikitext, template_title):
start, end = wrpylib.mwmarkup.find_template(wikitext, template_title)
if start is None: return (None,) * 3
title, params = wrpylib.mwmarkup.split_template(wikitext[start:end])
- unsigned_value = wrpylib.wrvalidators.UnsignedNone().to_python(params[u'1'].strip())
+ unsigned_value = wrpylib.wrvalidators.UnsignedNone().to_python(params['1'].strip())
return start, end, unsigned_value
def create_template_unsigned(template_title, unsigned):
unsigned = wrpylib.wrvalidators.UnsignedNone().from_python(unsigned)
- if len(unsigned) == 0: unsigned = u' '
+ if len(unsigned) == 0: unsigned = ' '
return wrpylib.mwmarkup.create_template(template_title, [unsigned])
def find_template_Hoehenunterschied(wikitext):
"""Same as find_template_unsigned with template '{{Höhenunterschied|350}}'"""
- return find_template_unsigned(wikitext, u'Höhenunterschied')
+ return find_template_unsigned(wikitext, 'Höhenunterschied')
def create_template_Hoehenunterschied(ele_diff):
- return create_template_unsigned(u'Höhenunterschied', ele_diff)
+ return create_template_unsigned('Höhenunterschied', ele_diff)
def find_template_Bahnlaenge(wikitext):
"""Same as find_template_unsigned with template '{{Bahnlänge|4500}}'"""
- return find_template_unsigned(wikitext, u'Bahnlänge')
+ return find_template_unsigned(wikitext, 'Bahnlänge')
def create_template_Bahnlaenge(length):
- return create_template_unsigned(u'Bahnlänge', length)
+ return create_template_unsigned('Bahnlänge', length)
def find_template_Gehzeit(wikitext):
"""Same as find_template_unsigned with template '{{Gehzeit|60}}'"""
- return find_template_unsigned(wikitext, u'Gehzeit')
+ return find_template_unsigned(wikitext, 'Gehzeit')
def create_template_Gehzeit(walkup_time):
- return create_template_unsigned(u'Gehzeit', walkup_time)
+ return create_template_unsigned('Gehzeit', walkup_time)
def find_template_Forumlink(wikitext):
"""Same as find_template_unsigned with template '{{Forumlink|26}}'"""
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Forumlink')
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Forumlink')
if start is None: return (None,) * 3
title, params = wrpylib.mwmarkup.split_template(wikitext[start:end])
- forumid = params[u'1'].strip()
- if forumid == u'<nummer einfügen>': unsigned_value = None
+ forumid = params['1'].strip()
+ if forumid == '<nummer einfügen>': unsigned_value = None
else: unsigned_value = wrpylib.wrvalidators.UnsignedNone().to_python(forumid)
return start, end, unsigned_value
# return find_template_unsigned(wikitext, u'Forumlink')
def find_template_Parkplatz(wikitext):
"""Same as find_template_latlon_ele with template '{{Parkplatz|47.076207 N 11.453553 E|1890}}'"""
- return find_template_latlon_ele(wikitext, u'Parkplatz')
+ return find_template_latlon_ele(wikitext, 'Parkplatz')
def find_template_Haltestelle(wikitext):
"""Finds the first occurance of the '{{Haltestelle|Ortsname|Haltestellenname|47.076207 N 11.453553 E|1890}}' template
and returns the tuple (start, end, city, stop, lat, lon, ele) or (None, None, None, None, None, None, None) if the
template was not found. If the template has no valid format, an exception is thrown."""
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Haltestelle')
+ start, end = wrpylib.mwmarkup.find_template(wikitext, 'Haltestelle')
if start is None: return (None,) * 7
title, params = wrpylib.mwmarkup.split_template(wikitext[start:end])
- city = wrpylib.wrvalidators.UnicodeNone().to_python(params[u'1'].strip())
- stop = wrpylib.wrvalidators.UnicodeNone().to_python(params[u'2'].strip())
- lat, lon = wrpylib.wrvalidators.GeoNone().to_python(params[u'3'].strip())
- ele = wrpylib.wrvalidators.UnsignedNone().to_python(params[u'4'].strip())
+ city = wrpylib.wrvalidators.UnicodeNone().to_python(params['1'].strip())
+ stop = wrpylib.wrvalidators.UnicodeNone().to_python(params['2'].strip())
+ lat, lon = wrpylib.wrvalidators.GeoNone().to_python(params['3'].strip())
+ ele = wrpylib.wrvalidators.UnsignedNone().to_python(params['4'].strip())
return start, end, city, stop, lat, lon, ele
for path in paths:
style, entries = path
style = style.lower()
- PATH_TYPES = {u'6#ff014e9a': u'rodelbahn', u'6#ffe98401': u'gehweg', u'6#ff7f7fff': u'alternative', u'3#ff000000': u'lift', u'3#ffe1e100': u'anfahrt'}
- if PATH_TYPES.has_key(style):
+ PATH_TYPES = {'6#ff014e9a': 'rodelbahn', '6#ffe98401': 'gehweg', '6#ff7f7fff': 'alternative', '3#ff000000': 'lift', '3#ffe1e100': 'anfahrt'}
+ if style in PATH_TYPES:
properties = {'type': PATH_TYPES[style]}
else:
properties = {'type': 'line'}
wrong_properties = set(feature.attrib.keys()) - allowed_properties
if len(wrong_properties) > 0:
raise ParseError("The attribute '{}' is not allowed at <{}>.".format(list(wrong_properties)[0], feature.tag))
- if feature.attrib.has_key('farbe'):
+ if 'farbe' in feature.attrib:
if not re.match('#[0-9a-fA-F]{6}$', feature.attrib['farbe']):
raise ParseError('The attribute "farbe" has to have a format like "#a0bb43".')
properties['strokeColor'] = feature.attrib['farbe'] # e.g. #a200b7
- if feature.attrib.has_key('dicke'):
+ if 'dicke' in feature.attrib:
try:
properties['strokeWidth'] = int(feature.attrib['dicke']) # e.g. 6
except ValueError:
# attributes
properties = {}
- for k, v in wrmap_xml.attrib.iteritems():
+ for k, v in wrmap_xml.attrib.items():
if k in ['lat', 'lon']:
try:
properties[k] = float(v)
"""Creates a <wrmap> wikitext from geojson (as python types)."""
wrmap_xml = xml.etree.ElementTree.Element('wrmap')
wrmap_xml.text = '\n\n'
- for k, v in geojson['properties'].iteritems():
+ for k, v in geojson['properties'].items():
if k in ['lon', 'lat']:
wrmap_xml.attrib[k] = '{:.6f}'.format(v)
else:
try:
result = formencode.Schema._convert_to_python(self, value, state)
ordered_result = collections.OrderedDict()
- for key in value.iterkeys():
+ for key in value.keys():
ordered_result[key] = result[key]
for validator in chained_validators:
ordered_result = validator.to_python(ordered_result, state)
try:
result = formencode.Schema._convert_from_python(self, value, state)
ordered_result = collections.OrderedDict()
- for key in value.iterkeys():
+ for key in value.keys():
ordered_result[key] = result[key]
# apply pre_validators
pre = pre_validators[:]
def to_python(self, value, state=None):
self.assert_string(value, state)
- if value == u'': return self.python_none
+ if value == '': return self.python_none
return self.validator.to_python(value, state)
def from_python(self, value, state=None):
- if value == self.python_none: return u''
+ if value == self.python_none: return ''
return self.validator.from_python(value, state)
>>> v.to_python(u'Nein')
u'Nein'
"""
- def __init__(self, validator, python_no=u'Nein'):
+ def __init__(self, validator, python_no='Nein'):
self.validator = validator
self.python_no = python_no
def to_python(self, value, state=None):
self.assert_string(value, state)
- if value == u'Nein': return self.python_no
+ if value == 'Nein': return self.python_no
return self.validator.to_python(value, state)
def from_python(self, value, state=None):
- if value == self.python_no: return u'Nein'
+ if value == self.python_no: return 'Nein'
return self.validator.from_python(value, state)
u'any string' <=> u'any string'"""
def to_python(self, value, state=None):
self.assert_string(value, state)
- return unicode(value)
+ return str(value)
def from_python(self, value, state=None):
- return unicode(value)
+ return str(value)
class UnicodeNone(NoneValidator):
return self.iv.to_python(value, state)
def from_python(self, value, state=None):
- return unicode(value)
+ return str(value)
class UnsignedNone(NoneValidator):
def to_python(self, value, state=None):
self.assert_string(value, state)
- if not self.dict.has_key(value): raise formencode.Invalid("Key not found in dict.", value, state)
+ if value not in self.dict: raise formencode.Invalid("Key not found in dict.", value, state)
return self.dict[value]
def from_python(self, value, state=None):
- for k, v in self.dict.iteritems():
+ for k, v in self.dict.items():
if v == value:
return k
raise formencode.Invalid('Invalid value', value, state)
u'Nein' <=> False
"""
def __init__(self):
- DictValidator.__init__(self, {u'': None, u'Ja': True, u'Nein': False})
+ DictValidator.__init__(self, {'': None, 'Ja': True, 'Nein': False})
class GermanTristateTuple(DictValidator):
u'Teilweise' <=> (True, True)
u'Nein' <=> (False, True)"""
def __init__(self, yes_python = (True, False), no_python = (False, True), partly_python = (True, True), none_python = (None, None)):
- DictValidator.__init__(self, {u'': none_python, u'Ja': yes_python, u'Nein': no_python, u'Teilweise': partly_python})
+ DictValidator.__init__(self, {'': none_python, 'Ja': yes_python, 'Nein': no_python, 'Teilweise': partly_python})
class GermanTristateFloat(GermanTristateTuple):
def to_python(self, value, state=None):
self.assert_string(value, state)
- if value == u'':
+ if value == '':
v = value
c = value
else:
right = value.rfind(')')
if right+1 != len(value):
- if not self.comment_is_optional: raise formencode.Invalid(u'Mandatory comment not present', value, state)
+ if not self.comment_is_optional: raise formencode.Invalid('Mandatory comment not present', value, state)
v = value
- c = u''
+ c = ''
else:
left = value.rfind('(')
- if left < 0: raise formencode.Invalid(u'Invalid format', value, state)
+ if left < 0: raise formencode.Invalid('Invalid format', value, state)
v = value[:left].strip()
c = value[left+1:right].strip()
return self.value_validator.to_python(v, state), self.comment_validator.to_python(c, state)
v = self.value_validator.from_python(value[0], state)
c = self.comment_validator.from_python(value[1], state)
if len(c) > 0:
- if len(v) > 0: return u'%s (%s)' % (v, c)
- else: return u'(%s)' % c
+ if len(v) > 0: return '%s (%s)' % (v, c)
+ else: return '(%s)' % c
return v
def to_python(self, value, state=None):
self.assert_string(value, state)
try: return datetime.datetime.strptime(value, self.date_time_format)
- except ValueError, e: raise formencode.Invalid(str(e), value, state)
+ except ValueError as e: raise formencode.Invalid(str(e), value, state)
def from_python(self, value, state=None):
return value.strftime(self.date_time_format)
"""Formats to coordinates '47.076207 N 11.453553 E' to the (latitude, longitude) tuplet."""
def to_python(self, value, state=None):
self.assert_string(value, state)
- r = re.match(u'(\d+\.\d+) N (\d+\.\d+) E', value)
- if r is None: raise formencode.Invalid(u"Coordinates '%s' have not a format like '47.076207 N 11.453553 E'" % value, value, state)
+ r = re.match('(\d+\.\d+) N (\d+\.\d+) E', value)
+ if r is None: raise formencode.Invalid("Coordinates '%s' have not a format like '47.076207 N 11.453553 E'" % value, value, state)
return (float(r.groups()[0]), float(r.groups()[1]))
def from_python(self, value, state=None):
latitude, longitude = value
- return u'%.6f N %.6f E' % (latitude, longitude)
+ return '%.6f N %.6f E' % (latitude, longitude)
class GeoNone(NoneValidator):
self.assert_string(value, state)
input_format = self.input_format
if not input_format in [self.FORMAT_GUESS, self.FORMAT_GEOCACHING, self.FORMAT_WINTERRODELN, self.FORMAT_GMAPPLUGIN, self.FORMAT_GPX]:
- raise formencode.Invalid(u"input_format %d is not recognized" % input_format, value, state) # Shouldn't it be an other type of runtime error?
+ raise formencode.Invalid("input_format %d is not recognized" % input_format, value, state) # Shouldn't it be an other type of runtime error?
lines = [line.strip() for line in value.split("\n") if len(line.strip()) > 0]
result = []
for line in lines:
if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_GEOCACHING:
- r = re.match(u'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))
continue
if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_WINTERRODELN:
- r = re.match(u'(\d+\.\d+) N (\d+\.\d+) E', line)
+ r = re.match('(\d+\.\d+) N (\d+\.\d+) E', line)
if not r is None:
result.append((float(r.groups()[0]), float(r.groups()[1]), None))
last_input_format = self.FORMAT_WINTERRODELN
continue
if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_GMAPPLUGIN:
- r = re.match(u'(\d+\.\d+), ?(\d+\.\d+)', line)
+ r = re.match('(\d+\.\d+), ?(\d+\.\d+)', line)
if not r is None:
result.append((float(r.groups()[0]), float(r.groups()[1]), None))
last_input_format = self.FORMAT_GMAPPLUGIN
continue
except (ExpatError, IndexError, ValueError): pass
- raise formencode.Invalid(u"Coordinates '%s' have no known format" % line, value, state)
+ raise formencode.Invalid("Coordinates '%s' have no known format" % line, value, state)
return result
for latitude, longitude, height in value:
if output_format == self.FORMAT_GEOCACHING:
degree = latitude
- result.append(u'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(u'%.6f N %.6f E' % (latitude, longitude))
+ result.append('%.6f N %.6f E' % (latitude, longitude))
elif output_format == self.FORMAT_GMAPPLUGIN:
- result.append(u'%.6f, %.6f' % (latitude, longitude))
+ result.append('%.6f, %.6f' % (latitude, longitude))
elif output_format == self.FORMAT_GPX:
- if not height is None: result.append(u'<trkpt lat="%.6f" lon="%.6f"><ele>%.2f</ele></trkpt>' % (latitude, longitude, height))
- else: result.append(u'<trkpt lat="%.6f" lon="%.6f"/>' % (latitude, longitude))
+ if not height is None: result.append('<trkpt lat="%.6f" lon="%.6f"><ele>%.2f</ele></trkpt>' % (latitude, longitude, height))
+ else: result.append('<trkpt lat="%.6f" lon="%.6f"/>' % (latitude, longitude))
else:
- raise formencode.Invalid(u"output_format %d is not recognized" % output_format, value, state) # Shouldn't it be an other type of runtime error?
+ raise formencode.Invalid("output_format %d is not recognized" % output_format, value, state) # Shouldn't it be an other type of runtime error?
return "\n".join(result)
def to_python(self, value, state=None):
self.assert_string(value, state)
- m = re.match(u'^(?:\+(\d+)/)?([\d/]+)(?:-(\d+))?$', value)
+ m = re.match('^(?:\+(\d+)/)?([\d/]+)(?:-(\d+))?$', value)
# This will separate
# u'+43/512/1234567-89' => (u'43', u'512/1234567', u'89')
# u'+43/512/1234/567-89' => (u'43', u'512/1234/567', u'89')
(country, phone, extension) = m.groups()
# Phone
- if phone.find(u'//') > -1 or phone.count('/') == 0: raise formencode.Invalid(self.message('phoneFormat', None) % {'value': value}, value, state)
+ if phone.find('//') > -1 or phone.count('/') == 0: raise formencode.Invalid(self.message('phoneFormat', None) % {'value': value}, value, state)
# Country
if country is None:
if phone[0] != '0': raise formencode.Invalid(self.message('phoneFormat', None) % {'value': value}, value, state)
phone = phone[1:]
- country = unicode(self.default_cc)
+ country = str(self.default_cc)
if extension is None: return '+%s/%s' % (country, phone)
return '+%s/%s-%s' % (country, phone, extension)
u'mittel' <=> 2
u'schwer' <=> 3"""
def __init__(self):
- DictValidator.__init__(self, {u'': None, u'leicht': 1, u'mittel': 2, u'schwer': 3})
+ DictValidator.__init__(self, {'': None, 'leicht': 1, 'mittel': 2, 'schwer': 3})
class GermanAvalanches(DictValidator):
u'gelegentlich' <=> 3
u'häufig' <=> 4"""
def __init__(self):
- DictValidator.__init__(self, {u'': None, u'kaum': 1, u'selten': 2, u'gelegentlich': 3, u'häufig': 4})
+ DictValidator.__init__(self, {'': None, 'kaum': 1, 'selten': 2, 'gelegentlich': 3, 'häufig': 4})
class GermanPublicTransport(DictValidator):
u'Nein' <=> 5
u'Ja' <=> 6"""
def __init__(self):
- DictValidator.__init__(self, {u'': None, u'Sehr gut': 1, u'Gut': 2, u'Mittelmäßig': 3, u'Schlecht': 4, u'Nein': 5, u'Ja': 6})
+ DictValidator.__init__(self, {'': None, 'Sehr gut': 1, 'Gut': 2, 'Mittelmäßig': 3, 'Schlecht': 4, 'Nein': 5, 'Ja': 6})
class GermanTristateFloatComment(ValueComment):
u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel' <=> u'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel'"""
def to_python(self, value, state=None):
self.assert_string(value, state)
- if value == u'': return None
- elif value == u'Nein': return value
- elif value.startswith(u'Tiroler Naturrodelbahn-Gütesiegel '):
+ if value == '': return None
+ elif value == 'Nein': return value
+ elif value.startswith('Tiroler Naturrodelbahn-Gütesiegel '):
p = value.split(" ")
Unsigned().to_python(p[2], state) # check if year can be parsed
if not p[3] in ['leicht', 'mittel', 'schwer']: raise formencode.Invalid("Unbekannter Schwierigkeitsgrad", value, state)
return value
- else: raise formencode.Invalid(u"Unbekanntes Gütesiegel", value, state)
+ else: raise formencode.Invalid("Unbekanntes Gütesiegel", value, state)
def from_python(self, value, state=None):
- if value is None: return u''
- assert value != u''
+ if value is None: return ''
+ assert value != ''
return self.to_python(value, state)
def to_python(self, value, state=None):
self.assert_string(value, state)
v = value
- v = v.replace(u'ä', u'a')
- v = v.replace(u'ö', u'o')
- v = v.replace(u'ü', u'u')
- v = v.replace(u'ß', u'ss')
+ v = v.replace('ä', 'a')
+ v = v.replace('ö', 'o')
+ v = v.replace('ü', 'u')
+ v = v.replace('ß', 'ss')
v = self.urlv.to_python(v, state)
return value
self.validator = formencode.national.InternationalPhoneNumber(default_cc=lambda: default_cc)
def to_python(self, value, state=None):
- return unicode(self.validator.to_python(value, state))
+ return str(self.validator.to_python(value, state))
def from_python(self, value, state=None):
return self.validator.from_python(value, state)
"""
def __init__(self, *args, **kw):
- if not kw.has_key('strip'): kw['strip'] = True
- if not kw.has_key('not_empty'): kw['not_empty'] = False
- if not kw.has_key('if_empty'): kw['if_empty'] = (None, None)
+ if 'strip' not in kw: kw['strip'] = True
+ if 'not_empty' not in kw: kw['not_empty'] = False
+ if 'if_empty' not in kw: kw['if_empty'] = (None, None)
self.at = '(at)'
formencode.FancyValidator.__init__(self, *args, **kw)
def _from_python(self, value, state=None):
email, masked = value
- if email is None: return u''
+ if email is None: return ''
val_email = formencode.validators.Email()
email = val_email.from_python(email, state)
if masked: email = email.replace('@', self.at)
u'Sessellift (Wochenende); Taxi (6 Euro)' <=> (True, u'Sessellift (Wochenende); Taxi (6 Euro)')
"""
def __init__(self):
- BoolUnicodeTupleValidator.__init__(self, Loop(ValueCommentList(DictValidator({u'Sessellift': u'Sessellift', u'Gondel': u'Gondel', u'Linienbus': u'Linienbus', u'Taxi': u'Taxi', u'Sonstige': u'Sonstige'}))))
+ BoolUnicodeTupleValidator.__init__(self, Loop(ValueCommentList(DictValidator({'Sessellift': 'Sessellift', 'Gondel': 'Gondel', 'Linienbus': 'Linienbus', 'Taxi': 'Taxi', 'Sonstige': 'Sonstige'}))))
class SledRental(BoolUnicodeTupleValidator):
class RodelbahnboxDictValidator(OrderedSchema):
"""Takes the fields of the Rodelbahnbox as dict of strings and returns them as dict of appropriet types."""
def __init__(self):
- self.add_field(u'Position', GeoNone()) # '47.583333 N 15.75 E'
- self.add_field(u'Position oben', GeoNone()) # '47.583333 N 15.75 E'
- self.add_field(u'Höhe oben', UnsignedNone()) # '2000'
- self.add_field(u'Position unten', GeoNone()) # '47.583333 N 15.75 E'
- self.add_field(u'Höhe unten', UnsignedNone()) # '1200'
- self.add_field(u'Länge', UnsignedNone()) # 3500
- self.add_field(u'Schwierigkeit', GermanDifficulty()) # 'mittel'
- self.add_field(u'Lawinen', GermanAvalanches()) # 'kaum'
- self.add_field(u'Betreiber', UnicodeNone()) # 'Max Mustermann'
- self.add_field(u'Öffentliche Anreise', GermanPublicTransport()) # 'Mittelmäßig'
- self.add_field(u'Aufstieg möglich', GermanBoolNone()) # 'Ja'
- self.add_field(u'Aufstieg getrennt', GermanTristateFloatComment()) # 'Ja'
- self.add_field(u'Gehzeit', UnsignedNone()) # 90
- self.add_field(u'Aufstiegshilfe', GermanLift()) # 'Gondel (unterer Teil)'
- self.add_field(u'Beleuchtungsanlage', GermanTristateFloatComment())
- self.add_field(u'Beleuchtungstage', UnsignedCommentNone(7)) # '3 (Montag, Mittwoch, Freitag)'
- self.add_field(u'Rodelverleih', SledRental()) # 'Talstation Serlesbahnan'
- self.add_field(u'Gütesiegel', GermanCachet()) # 'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel'
- self.add_field(u'Webauskunft', UrlNeinNone()) # 'http://www.nösslachhütte.at/page9.php'
- self.add_field(u'Telefonauskunft', PhoneCommentListNeinLoopNone(comments_are_optional=False)) # '+43-664-5487520 (Mitterer Alm)'
- self.add_field(u'Bild', UnicodeNone())
- self.add_field(u'In Übersichtskarte', GermanBoolNone())
- self.add_field(u'Forumid', UnsignedNeinNone())
+ self.add_field('Position', GeoNone()) # '47.583333 N 15.75 E'
+ self.add_field('Position oben', GeoNone()) # '47.583333 N 15.75 E'
+ self.add_field('Höhe oben', UnsignedNone()) # '2000'
+ self.add_field('Position unten', GeoNone()) # '47.583333 N 15.75 E'
+ self.add_field('Höhe unten', UnsignedNone()) # '1200'
+ self.add_field('Länge', UnsignedNone()) # 3500
+ self.add_field('Schwierigkeit', GermanDifficulty()) # 'mittel'
+ self.add_field('Lawinen', GermanAvalanches()) # 'kaum'
+ self.add_field('Betreiber', UnicodeNone()) # 'Max Mustermann'
+ self.add_field('Öffentliche Anreise', GermanPublicTransport()) # 'Mittelmäßig'
+ self.add_field('Aufstieg möglich', GermanBoolNone()) # 'Ja'
+ self.add_field('Aufstieg getrennt', GermanTristateFloatComment()) # 'Ja'
+ self.add_field('Gehzeit', UnsignedNone()) # 90
+ self.add_field('Aufstiegshilfe', GermanLift()) # 'Gondel (unterer Teil)'
+ self.add_field('Beleuchtungsanlage', GermanTristateFloatComment())
+ self.add_field('Beleuchtungstage', UnsignedCommentNone(7)) # '3 (Montag, Mittwoch, Freitag)'
+ self.add_field('Rodelverleih', SledRental()) # 'Talstation Serlesbahnan'
+ self.add_field('Gütesiegel', GermanCachet()) # 'Tiroler Naturrodelbahn-Gütesiegel 2009 mittel'
+ self.add_field('Webauskunft', UrlNeinNone()) # 'http://www.nösslachhütte.at/page9.php'
+ self.add_field('Telefonauskunft', PhoneCommentListNeinLoopNone(comments_are_optional=False)) # '+43-664-5487520 (Mitterer Alm)'
+ self.add_field('Bild', UnicodeNone())
+ self.add_field('In Übersichtskarte', GermanBoolNone())
+ self.add_field('Forumid', UnsignedNeinNone())
class GasthausboxDictValidator(OrderedSchema):
"""Takes the fields of the Gasthausbox as dict of strings and returns them as dict of appropriet types."""
def __init__(self):
- self.add_field(u'Position', GeoNone()) # '47.583333 N 15.75 E'
- self.add_field(u'Höhe', UnsignedNone())
- self.add_field(u'Betreiber', UnicodeNone())
- self.add_field(u'Sitzplätze', UnsignedNone())
- self.add_field(u'Übernachtung', BoolUnicodeTupleValidator())
- self.add_field(u'Rauchfrei', GermanTristateTuple())
- self.add_field(u'Rodelverleih', BoolUnicodeTupleValidator())
- self.add_field(u'Handyempfang', ValueCommentListNeinLoopNone())
- self.add_field(u'Homepage', UrlNeinNone())
- self.add_field(u'E-Mail', EmailCommentListNeinLoopNone(allow_masked_email=True))
- self.add_field(u'Telefon', PhoneCommentListNeinLoopNone(comments_are_optional=True))
- self.add_field(u'Bild', UnicodeNone())
- self.add_field(u'Rodelbahnen', WikiPageListLoopNone())
+ self.add_field('Position', GeoNone()) # '47.583333 N 15.75 E'
+ self.add_field('Höhe', UnsignedNone())
+ self.add_field('Betreiber', UnicodeNone())
+ self.add_field('Sitzplätze', UnsignedNone())
+ self.add_field('Übernachtung', BoolUnicodeTupleValidator())
+ self.add_field('Rauchfrei', GermanTristateTuple())
+ self.add_field('Rodelverleih', BoolUnicodeTupleValidator())
+ self.add_field('Handyempfang', ValueCommentListNeinLoopNone())
+ self.add_field('Homepage', UrlNeinNone())
+ self.add_field('E-Mail', EmailCommentListNeinLoopNone(allow_masked_email=True))
+ self.add_field('Telefon', PhoneCommentListNeinLoopNone(comments_are_optional=True))
+ self.add_field('Bild', UnicodeNone())
+ self.add_field('Rodelbahnen', WikiPageListLoopNone())