kopia lustrzana https://github.com/hholzgra/maposmatic/
python3 porting modifications
rodzic
902db92003
commit
97565af601
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# coding: utf-8
|
||||
|
||||
# maposmatic, the web front-end of the MapOSMatic city map generation system
|
||||
|
@ -256,6 +256,6 @@ if __name__ == '__main__':
|
|||
|
||||
cleaner.start()
|
||||
daemon.serve()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
l.exception('Fatal error during daemon execution!')
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
import ctypes
|
||||
import datetime
|
||||
import Image
|
||||
from PIL import Image
|
||||
import logging
|
||||
import multiprocessing
|
||||
import os
|
||||
|
@ -203,7 +203,7 @@ class ThreadingJobRenderer:
|
|||
mailer.sendmail(DAEMON_ERRORS_EMAIL_FROM,
|
||||
[admin[1] for admin in ADMINS], msg)
|
||||
l.info("Email notification sent.")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
l.exception("Could not send notification email to the submitter!")
|
||||
|
||||
def run(self):
|
||||
|
@ -285,7 +285,7 @@ class ForkingJobRenderer:
|
|||
mailer.sendmail(DAEMON_ERRORS_EMAIL_FROM,
|
||||
[admin[1] for admin in ADMINS], msg)
|
||||
l.info("Email notification sent.")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
l.exception("Could not send notification email to the submitter!")
|
||||
|
||||
def run(self):
|
||||
|
@ -396,7 +396,7 @@ class JobRenderer(threading.Thread):
|
|||
mailer.sendmail(DAEMON_ERRORS_EMAIL_FROM,
|
||||
[admin[1] for admin in ADMINS], msg)
|
||||
l.info("Email notification sent.")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
l.exception("Could not send notification email to the submitter!")
|
||||
|
||||
|
||||
|
@ -444,7 +444,7 @@ class JobRenderer(threading.Thread):
|
|||
mailer.sendmail(DAEMON_ERRORS_EMAIL_FROM,
|
||||
[admin[1] for admin in ADMINS], msg)
|
||||
l.info("Error report sent.")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
l.exception("Could not send error email to the admins!")
|
||||
|
||||
self._email_submitter(FAILURE_EMAIL_TEMPLATE)
|
||||
|
@ -526,7 +526,7 @@ class JobRenderer(threading.Thread):
|
|||
config.stylesheet = renderer.get_stylesheet_by_name(
|
||||
self.job.stylesheet)
|
||||
config.overlays = []
|
||||
if self.job.overlay:
|
||||
if self.job.overlay:
|
||||
for overlay in self.job.overlay.split(","):
|
||||
config.overlays.append(renderer.get_overlay_by_name(overlay))
|
||||
if self.job.track:
|
||||
|
@ -540,7 +540,7 @@ class JobRenderer(threading.Thread):
|
|||
self.result = RESULT_KEYBOARD_INTERRUPT
|
||||
l.info("Rendering of job #%d interrupted!" % self.job.id)
|
||||
return self.result
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.result = RESULT_PREPARATION_EXCEPTION
|
||||
l.exception("Rendering of job #%d failed (exception occurred during"
|
||||
" data preparation)!" % self.job.id)
|
||||
|
@ -577,7 +577,7 @@ class JobRenderer(threading.Thread):
|
|||
self.result = RESULT_KEYBOARD_INTERRUPT
|
||||
l.info("Rendering of job #%d interrupted!" % self.job.id)
|
||||
return self.result
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.result = RESULT_RENDERING_EXCEPTION
|
||||
l.exception("Rendering of job #%d failed (exception occurred during"
|
||||
" rendering)!" % self.job.id)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
|
||||
# maposmatic, the web front-end of the MapOSMatic city map generation system
|
||||
|
|
|
@ -27,7 +27,7 @@ import django.utils.translation
|
|||
import feedparser
|
||||
import datetime
|
||||
|
||||
from models import MapRenderingJob
|
||||
from .models import MapRenderingJob
|
||||
import www.settings
|
||||
|
||||
from www.maposmatic import gisdb
|
||||
|
@ -108,7 +108,7 @@ def all(request):
|
|||
return {}
|
||||
|
||||
l = django.utils.translation.get_language()
|
||||
if www.settings.PAYPAL_LANGUAGES.has_key(l):
|
||||
if l in www.settings.PAYPAL_LANGUAGES:
|
||||
paypal_lang_code = www.settings.PAYPAL_LANGUAGES[l][0]
|
||||
paypal_country_code = www.settings.PAYPAL_LANGUAGES[l][1]
|
||||
else:
|
||||
|
|
|
@ -166,7 +166,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
stylesheet = cleaned_data.get("stylesheet")
|
||||
overlay_array = []
|
||||
for overlay in cleaned_data.get("overlay"):
|
||||
overlay_array.append(overlay.encode('ascii'))
|
||||
overlay_array.append(overlay.encode('ascii'))
|
||||
overlay = ",".join(overlay_array)
|
||||
|
||||
if cleaned_data.get("paperorientation") == 'landscape':
|
||||
|
@ -202,7 +202,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
|
||||
try:
|
||||
self._check_osm_id(cleaned_data.get("administrative_osmid"))
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
msg = _(u"Error with osm city: %s" % ex)
|
||||
self._errors['administrative_osmid'] \
|
||||
= ErrorList([msg])
|
||||
|
|
|
@ -46,7 +46,7 @@ def get():
|
|||
www.settings.GIS_DATABASE_HOST,
|
||||
www.settings.GIS_DATABASE_PASSWORD,
|
||||
www.settings.GIS_DATABASE_PORT))
|
||||
except psycopg2.OperationalError, e:
|
||||
except psycopg2.OperationalError as e:
|
||||
l.warning("Could not connect to the PostGIS database: %s" %
|
||||
str(e)[:-1])
|
||||
_DB = None
|
||||
|
|
|
@ -126,8 +126,8 @@ def get_pages_list(page, paginator):
|
|||
paginator.num_pages-1, paginator.num_pages]:
|
||||
nav[i] = True
|
||||
|
||||
for i in xrange(1, paginator.num_pages+1):
|
||||
if nav.has_key(i):
|
||||
for i in range(1, paginator.num_pages+1):
|
||||
if i in nav:
|
||||
if last and i - last > 1:
|
||||
page_list.append('...')
|
||||
page_list.append(i)
|
||||
|
@ -135,4 +135,4 @@ def get_pages_list(page, paginator):
|
|||
return page_list
|
||||
|
||||
def generate_nonce(length):
|
||||
return ''.join(random.choice(string.letters) for i in xrange(length))
|
||||
return ''.join(random.choice(string.ascii_letters) for i in range(length))
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('maposmatic', '0010_maprenderingjob_submittermail'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='maprenderingjob',
|
||||
name='status',
|
||||
field=models.IntegerField(choices=[(0, 'Submitted'), (1, 'In progress'), (2, 'Done'), (3, 'Done w/o files'), (4, 'Cancelled')]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='maprenderingjob',
|
||||
name='submittermail',
|
||||
field=models.EmailField(blank=True, max_length=254, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='maprenderingjob',
|
||||
name='track',
|
||||
field=models.FileField(upload_to='upload/tracks/%Y/%m/%d/', blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='maprenderingjob',
|
||||
name='track_bbox_mode',
|
||||
field=models.IntegerField(choices=[(0, 'Keep'), (1, 'Merge'), (2, 'Replace')], default=0),
|
||||
),
|
||||
]
|
|
@ -36,8 +36,8 @@ Most of the credits should go to gthe Nominatim team.
|
|||
from django.utils.translation import ugettext
|
||||
import logging
|
||||
import psycopg2
|
||||
from urllib import urlencode
|
||||
import urllib2
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import Request, urlopen
|
||||
from xml.etree.ElementTree import parse as XMLTree
|
||||
|
||||
import ocitysmap
|
||||
|
@ -58,10 +58,10 @@ def reverse_geo(lat, lon):
|
|||
"""Query the nominatim service for the given lat/long coordinates and
|
||||
returns the reverse geocoded informations."""
|
||||
|
||||
request = urllib2.Request('%s/reverse?%s' %
|
||||
request = Request('%s/reverse?%s' %
|
||||
(NOMINATIM_BASE_URL, urlencode({'lat': lat, 'lon': lon})))
|
||||
request.add_header('User-Agent', NOMINATIM_USER_AGENT)
|
||||
f = urllib2.urlopen(request)
|
||||
f = urlopen(request)
|
||||
|
||||
result = []
|
||||
for place in XMLTree(f).getroot().getchildren():
|
||||
|
@ -114,13 +114,13 @@ def _fetch_xml(query_text, exclude, with_polygons, accept_language):
|
|||
if exclude != '':
|
||||
query_tags['exclude_place_ids'] = exclude
|
||||
|
||||
request = urllib2.Request('%s/search/?%s' %
|
||||
request = Request('%s/search/?%s' %
|
||||
(NOMINATIM_BASE_URL, urlencode(query_tags)))
|
||||
request.add_header('User-Agent', NOMINATIM_USER_AGENT)
|
||||
if accept_language:
|
||||
request.add_header('Accept-Language', accept_language)
|
||||
|
||||
return XMLTree(urllib2.urlopen(request))
|
||||
return XMLTree(urlopen(request))
|
||||
|
||||
def _extract_entries(xml):
|
||||
"""Given a XMLTree object of a Nominatim result, return a (python)
|
||||
|
@ -355,5 +355,5 @@ if __name__ == "__main__":
|
|||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
for city in sys.argv[1:]:
|
||||
print "###### %s:" % city
|
||||
print("###### %s:" % city)
|
||||
pp.pprint(query(city))
|
||||
|
|
|
@ -249,7 +249,7 @@ def api_nominatim(request):
|
|||
try:
|
||||
contents = nominatim.query(squery, exclude, with_polygons=False,
|
||||
accept_language=lang)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.exception("Error querying Nominatim")
|
||||
contents = []
|
||||
|
||||
|
|
227
www/settings.py
227
www/settings.py
|
@ -29,8 +29,8 @@ import os.path
|
|||
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from settings_local import *
|
||||
import logconfig
|
||||
from .settings_local import *
|
||||
from . import logconfig
|
||||
|
||||
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
@ -110,26 +110,26 @@ TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|||
# specified in Django i18n location (all lowercase, with the language and
|
||||
# locale separated by a dash instead of an underscore: pt_BR -> pt-br)
|
||||
LANGUAGES = {
|
||||
"fr": u"Français",
|
||||
"en": u"English",
|
||||
"de": u"Deutsch",
|
||||
"it": u"Italiano",
|
||||
"ca": u"Català",
|
||||
"ru": u"Русский",
|
||||
"ar": u"العربية",
|
||||
"pt-pt": u"Português",
|
||||
"pt-br": u"Português do Brasil",
|
||||
"nb": u"Norwegian Bokmål",
|
||||
"nl": u"Nederlands",
|
||||
"hr": u"Hrvatski",
|
||||
"pl": u"Polski",
|
||||
"es": u"Español",
|
||||
"id": u"Bahasa Indonesia",
|
||||
"tr": u"Türkçe",
|
||||
"ja": u"日本人",
|
||||
"el": u"ελληνικά",
|
||||
"be": u"беларуская",
|
||||
"uk": u"українська",
|
||||
"fr": "Français",
|
||||
"en": "English",
|
||||
"de": "Deutsch",
|
||||
"it": "Italiano",
|
||||
"ca": "Català",
|
||||
"ru": "Русский",
|
||||
"ar": "العربية",
|
||||
"pt-pt": "Português",
|
||||
"pt-br": "Português do Brasil",
|
||||
"nb": "Norwegian Bokmål",
|
||||
"nl": "Nederlands",
|
||||
"hr": "Hrvatski",
|
||||
"pl": "Polski",
|
||||
"es": "Español",
|
||||
"id": "Bahasa Indonesia",
|
||||
"tr": "Türkçe",
|
||||
"ja": "日本人",
|
||||
"el": "ελληνικά",
|
||||
"be": "беларуская",
|
||||
"uk": "українська",
|
||||
}
|
||||
|
||||
# Associate a Django language code with:
|
||||
|
@ -158,107 +158,110 @@ PAYPAL_LANGUAGES = {
|
|||
# filtering the language list based on the country of the city that is
|
||||
# being rendered).
|
||||
MAP_LANGUAGES = {
|
||||
"ca_AD.UTF-8": u"Andorra (CA)",
|
||||
"ar_AE.UTF-8": u"دولة الإمارات العربية المتحدة (AR)",
|
||||
"en_AG": u"Antigua and Barbuda (EN)",
|
||||
"es_AR.UTF-8": u"Argentina (ES)",
|
||||
"de_AT.UTF-8": u"Österreich (DE)",
|
||||
"en_AU.UTF-8": u"Australia (EN)",
|
||||
"nl_BE.UTF-8": u"Koninkrijk België (NL)",
|
||||
"fr_BE.UTF-8": u"Royaume de Belgique (FR)",
|
||||
"de_BE.UTF-8": u"Königreich Belgien (DE)",
|
||||
"ar_BH.UTF-8": u"البحرين (AR)",
|
||||
"be_BY.UTF-8": u"Белару́сь (BY)",
|
||||
"es_BO.UTF-8": u"Bolivia (ES)",
|
||||
"pt_BR.UTF-8": u"Brasil (PT)",
|
||||
"en_BW.UTF-8": u"Botswana (EN)",
|
||||
"en_CA.UTF-8": u"Canada (EN)",
|
||||
"fr_CA.UTF-8": u"Canada (FR)",
|
||||
"de_CH.UTF-8": u"Schweiz (DE)",
|
||||
"fr_CH.UTF-8": u"Suisse (FR)",
|
||||
"it_CH.UTF-8": u"Svizzera (IT)",
|
||||
"el_GR.UTF-8": u"Ελλάδα (GR)",
|
||||
"es_CL.UTF-8": u"Chile (ES)",
|
||||
"es_CR.UTF-8": u"Costa Rica (ES)",
|
||||
"de_DE.UTF-8": u"Deutschland (DE)",
|
||||
"da_DK.UTF-8": u"Danmark (DA)",
|
||||
"en_DK.UTF-8": u"Denmark (EN)",
|
||||
"es_DO.UTF-8": u"República Dominicana (ES)",
|
||||
"ar_DZ.UTF-8": u"الجزائر (AR)",
|
||||
"es_EC.UTF-8": u"Ecuador (ES)",
|
||||
"ar_EG.UTF-8": u"مصر (AR)",
|
||||
"es_ES.UTF-8": u"España (ES)",
|
||||
"ca_ES.UTF-8": u"Espanya (CA)",
|
||||
"ast_ES.UTF-8": u"España (AST)",
|
||||
"fr_FR.UTF-8": u"France (FR)",
|
||||
"ca_FR.UTF-8": u"França (CA)",
|
||||
"en_GB.UTF-8": u"United Kingdom (EN)",
|
||||
"es_GT.UTF-8": u"Guatemala (ES)",
|
||||
"en_HK.UTF-8": u"Hong Kong (EN)",
|
||||
"es_HN.UTF-8": u"Honduras (ES)",
|
||||
"hr_HR.UTF-8": u"Republika Hrvatska",
|
||||
"id_ID.UTF-8": u"Bahasa Indonesia (ID)",
|
||||
"en_IE.UTF-8": u"Ireland (EN)",
|
||||
"en_IN": u"India (EN)",
|
||||
"ar_IQ.UTF-8": u"العراق (AR)",
|
||||
"it_IT.UTF-8": u"Italia (IT)",
|
||||
"ar_JO.UTF-8": u"الأردنّ (AR)",
|
||||
"ar_KW.UTF-8": u"الكويت (AR)",
|
||||
"ar_LB.UTF-8": u"لبنان (AR)",
|
||||
"ja_JP.UTF-8": u"日本人 (JA)",
|
||||
"fr_LU.UTF-8": u"Luxembourg (FR)",
|
||||
"de_LU.UTF-8": u"Luxemburg (DE)",
|
||||
"ar_LY.UTF-8": u"ليبيا (AR)",
|
||||
"ar_MA.UTF-8": u"المملكة المغربية (AR)",
|
||||
"es_MX.UTF-8": u"México (ES)",
|
||||
"en_NG": u"Nigeria (EN)",
|
||||
"es_NI.UTF-8": u"Nicaragua (ES)",
|
||||
"nl_NL.UTF-8": u"Nederland (NL)",
|
||||
"nb_NO.UTF-8": u"Norwegian Bokmål (NO)",
|
||||
"nn_NO.UTF-8": u"Norwegian Nynorsk (NO)",
|
||||
"en_NZ.UTF-8": u"New Zealand (EN)",
|
||||
"ar_OM.UTF-8": u"سلطنة عمان (AR)",
|
||||
"es_PA.UTF-8": u"Panamá (ES)",
|
||||
"es_PE.UTF-8": u"Perú (ES)",
|
||||
"en_PH.UTF-8": u"Philippines (EN)",
|
||||
"pl_PL.UTF-8": u"Rzeczpospolita Polska",
|
||||
"pt_PT.UTF-8": u"Portugal (PT)",
|
||||
"es_PR.UTF-8": u"Puerto Rico (ES)",
|
||||
"es_PY.UTF-8": u"Paraguay (ES)",
|
||||
"ar_QA.UTF-8": u"دولة قطر (AR)",
|
||||
"ru_RU.UTF-8": u"Русский",
|
||||
"ar_SA.UTF-8": u"المملكة العربية السعودية (AR)",
|
||||
"ar_SD.UTF-8": u"السودان (AR)",
|
||||
"en_SG.UTF-8": u"Singapore (EN)",
|
||||
"es_SV.UTF-8": u"El Salvador (ES)",
|
||||
"ar_SY.UTF-8": u"سوريا (AR)",
|
||||
"ar_TN.UTF-8": u"تونس (AR)",
|
||||
"en_US.UTF-8": u"United States (EN)",
|
||||
"es_US.UTF-8": u"Estados Unidos de América (ES)",
|
||||
"uk_UA.UTF-8": u"Україна (UK)",
|
||||
"es_UY.UTF-8": u"Uruguay (ES)",
|
||||
"es_VE.UTF-8": u"Venezuela (ES)",
|
||||
"ar_YE.UTF-8": u"اليَمَن (AR)",
|
||||
"en_ZA.UTF-8": u"South Africa (EN)",
|
||||
"en_ZW.UTF-8": u"Zimbabwe (EN)",
|
||||
"tr_TR.UTF-8": u"Türkçe (TR)",
|
||||
"sk_SK.UTF-8": u"Slovakien (SK)",
|
||||
"ca_AD.UTF-8": "Andorra (CA)",
|
||||
"ar_AE.UTF-8": "دولة الإمارات العربية المتحدة (AR)",
|
||||
"en_AG": "Antigua and Barbuda (EN)",
|
||||
"es_AR.UTF-8": "Argentina (ES)",
|
||||
"de_AT.UTF-8": "Österreich (DE)",
|
||||
"en_AU.UTF-8": "Australia (EN)",
|
||||
"nl_BE.UTF-8": "Koninkrijk België (NL)",
|
||||
"fr_BE.UTF-8": "Royaume de Belgique (FR)",
|
||||
"de_BE.UTF-8": "Königreich Belgien (DE)",
|
||||
"ar_BH.UTF-8": "البحرين (AR)",
|
||||
"be_BY.UTF-8": "Белару́сь (BY)",
|
||||
"es_BO.UTF-8": "Bolivia (ES)",
|
||||
"pt_BR.UTF-8": "Brasil (PT)",
|
||||
"en_BW.UTF-8": "Botswana (EN)",
|
||||
"en_CA.UTF-8": "Canada (EN)",
|
||||
"fr_CA.UTF-8": "Canada (FR)",
|
||||
"de_CH.UTF-8": "Schweiz (DE)",
|
||||
"fr_CH.UTF-8": "Suisse (FR)",
|
||||
"it_CH.UTF-8": "Svizzera (IT)",
|
||||
"el_GR.UTF-8": "Ελλάδα (GR)",
|
||||
"es_CL.UTF-8": "Chile (ES)",
|
||||
"es_CR.UTF-8": "Costa Rica (ES)",
|
||||
"de_DE.UTF-8": "Deutschland (DE)",
|
||||
"da_DK.UTF-8": "Danmark (DA)",
|
||||
"en_DK.UTF-8": "Denmark (EN)",
|
||||
"es_DO.UTF-8": "República Dominicana (ES)",
|
||||
"ar_DZ.UTF-8": "الجزائر (AR)",
|
||||
"es_EC.UTF-8": "Ecuador (ES)",
|
||||
"ar_EG.UTF-8": "مصر (AR)",
|
||||
"es_ES.UTF-8": "España (ES)",
|
||||
"ca_ES.UTF-8": "Espanya (CA)",
|
||||
"ast_ES.UTF-8": "España (AST)",
|
||||
"fr_FR.UTF-8": "France (FR)",
|
||||
"ca_FR.UTF-8": "França (CA)",
|
||||
"en_GB.UTF-8": "United Kingdom (EN)",
|
||||
"es_GT.UTF-8": "Guatemala (ES)",
|
||||
"en_HK.UTF-8": "Hong Kong (EN)",
|
||||
"es_HN.UTF-8": "Honduras (ES)",
|
||||
"hr_HR.UTF-8": "Republika Hrvatska",
|
||||
"id_ID.UTF-8": "Bahasa Indonesia (ID)",
|
||||
"en_IE.UTF-8": "Ireland (EN)",
|
||||
"en_IN": "India (EN)",
|
||||
"ar_IQ.UTF-8": "العراق (AR)",
|
||||
"it_IT.UTF-8": "Italia (IT)",
|
||||
"ar_JO.UTF-8": "الأردنّ (AR)",
|
||||
"ar_KW.UTF-8": "الكويت (AR)",
|
||||
"ar_LB.UTF-8": "لبنان (AR)",
|
||||
"ja_JP.UTF-8": "日本人 (JA)",
|
||||
"fr_LU.UTF-8": "Luxembourg (FR)",
|
||||
"de_LU.UTF-8": "Luxemburg (DE)",
|
||||
"ar_LY.UTF-8": "ليبيا (AR)",
|
||||
"ar_MA.UTF-8": "المملكة المغربية (AR)",
|
||||
"es_MX.UTF-8": "México (ES)",
|
||||
"en_NG": "Nigeria (EN)",
|
||||
"es_NI.UTF-8": "Nicaragua (ES)",
|
||||
"nl_NL.UTF-8": "Nederland (NL)",
|
||||
"nb_NO.UTF-8": "Norwegian Bokmål (NO)",
|
||||
"nn_NO.UTF-8": "Norwegian Nynorsk (NO)",
|
||||
"en_NZ.UTF-8": "New Zealand (EN)",
|
||||
"ar_OM.UTF-8": "سلطنة عمان (AR)",
|
||||
"es_PA.UTF-8": "Panamá (ES)",
|
||||
"es_PE.UTF-8": "Perú (ES)",
|
||||
"en_PH.UTF-8": "Philippines (EN)",
|
||||
"pl_PL.UTF-8": "Rzeczpospolita Polska",
|
||||
"pt_PT.UTF-8": "Portugal (PT)",
|
||||
"es_PR.UTF-8": "Puerto Rico (ES)",
|
||||
"es_PY.UTF-8": "Paraguay (ES)",
|
||||
"ar_QA.UTF-8": "دولة قطر (AR)",
|
||||
"ru_RU.UTF-8": "Русский",
|
||||
"ar_SA.UTF-8": "المملكة العربية السعودية (AR)",
|
||||
"ar_SD.UTF-8": "السودان (AR)",
|
||||
"en_SG.UTF-8": "Singapore (EN)",
|
||||
"es_SV.UTF-8": "El Salvador (ES)",
|
||||
"ar_SY.UTF-8": "سوريا (AR)",
|
||||
"ar_TN.UTF-8": "تونس (AR)",
|
||||
"en_US.UTF-8": "United States (EN)",
|
||||
"es_US.UTF-8": "Estados Unidos de América (ES)",
|
||||
"uk_UA.UTF-8": "Україна (UK)",
|
||||
"es_UY.UTF-8": "Uruguay (ES)",
|
||||
"es_VE.UTF-8": "Venezuela (ES)",
|
||||
"ar_YE.UTF-8": "اليَمَن (AR)",
|
||||
"en_ZA.UTF-8": "South Africa (EN)",
|
||||
"en_ZW.UTF-8": "Zimbabwe (EN)",
|
||||
"tr_TR.UTF-8": "Türkçe (TR)",
|
||||
"sk_SK.UTF-8": "Slovakien (SK)",
|
||||
# "C": _(u"No localization"),
|
||||
}
|
||||
|
||||
MAP_LANGUAGES_LIST = MAP_LANGUAGES.items()
|
||||
MAP_LANGUAGES_LIST.sort(lambda x, y: cmp(x[1], y[1]))
|
||||
# sorted(MAP_LANGUAGES_LIST)
|
||||
sorted(MAP_LANGUAGES_LIST, key=lambda p: p[1])
|
||||
# MAP_LANGUAGES_LIST.sort(lambda x, y: cmp(x[1], y[1]))
|
||||
# "C" must be the last entry
|
||||
MAP_LANGUAGES_LIST.append(("C", _(u"No localization")))
|
||||
# MAP_LANGUAGES_LIST.update(("C", _(u"No localization")))
|
||||
|
||||
# GIS database (read settings from OCitySMap's configuration). The
|
||||
# default port to connect to the database is 5432, which is the
|
||||
# default PostgreSQL port.
|
||||
import ConfigParser
|
||||
gis_config = ConfigParser.SafeConfigParser({'port': '5432'})
|
||||
import configparser
|
||||
gis_config = configparser.SafeConfigParser({'port': '5432'})
|
||||
|
||||
if OCITYSMAP_CFG_PATH is None:
|
||||
OCITYSMAP_CFG_PATH = os.path.expanduser('~/.ocitysmap.conf')
|
||||
with open(OCITYSMAP_CFG_PATH) as fp:
|
||||
with open(OCITYSMAP_CFG_PATH, encoding='utf-8') as fp:
|
||||
gis_config.readfp(fp)
|
||||
GIS_DATABASE_HOST = gis_config.get('datasource', 'host')
|
||||
GIS_DATABASE_USER = gis_config.get('datasource', 'user')
|
||||
|
|
40
www/urls.py
40
www/urls.py
|
@ -29,58 +29,58 @@ from django.conf.urls import patterns, url, include
|
|||
# from django.contrib import admin
|
||||
# admin.autodiscover()
|
||||
|
||||
import maposmatic.feeds
|
||||
import maposmatic.views
|
||||
import settings
|
||||
from .maposmatic import feeds
|
||||
from .maposmatic import views
|
||||
from . import settings
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$',
|
||||
maposmatic.views.index,
|
||||
views.index,
|
||||
name='main'),
|
||||
|
||||
url(r'^new/$',
|
||||
maposmatic.views.new,
|
||||
views.new,
|
||||
name='new'),
|
||||
url(r'^recreate/$',
|
||||
maposmatic.views.recreate,
|
||||
views.recreate,
|
||||
name='recreate'),
|
||||
url(r'^cancel/$',
|
||||
maposmatic.views.cancel,
|
||||
views.cancel,
|
||||
name='cancel'),
|
||||
|
||||
url(r'^maps/(?P<id>\d+)/(?P<nonce>[A-Za-z]{16})$',
|
||||
maposmatic.views.map_full,
|
||||
views.map_full,
|
||||
name='map-by-id-and-nonce'),
|
||||
url(r'^maps/(?P<id>\d+)$',
|
||||
maposmatic.views.map_full,
|
||||
views.map_full,
|
||||
name='map-by-id'),
|
||||
url(r'^maps/$',
|
||||
maposmatic.views.maps,
|
||||
views.maps,
|
||||
name='maps'),
|
||||
|
||||
url(r'^about/$',
|
||||
maposmatic.views.about,
|
||||
views.about,
|
||||
name='about'),
|
||||
url(r'^donate/$',
|
||||
maposmatic.views.donate,
|
||||
views.donate,
|
||||
name='donate'),
|
||||
url(r'^donate-thanks/$',
|
||||
maposmatic.views.donate_thanks,
|
||||
views.donate_thanks,
|
||||
name='donate-thanks'),
|
||||
|
||||
(r'^apis/nominatim/$', maposmatic.views.api_nominatim),
|
||||
(r'^apis/reversegeo/([^/]*)/([^/]*)/$', maposmatic.views.api_nominatim_reverse),
|
||||
(r'^apis/papersize', maposmatic.views.api_papersize),
|
||||
(r'^apis/boundingbox/([^/]*)/$', maposmatic.views.api_bbox),
|
||||
(r'^apis/polygon/([^/]*)/$', maposmatic.views.api_polygon),
|
||||
(r'^apis/nominatim/$', views.api_nominatim),
|
||||
(r'^apis/reversegeo/([^/]*)/([^/]*)/$', views.api_nominatim_reverse),
|
||||
(r'^apis/papersize', views.api_papersize),
|
||||
(r'^apis/boundingbox/([^/]*)/$', views.api_bbox),
|
||||
(r'^apis/polygon/([^/]*)/$', views.api_polygon),
|
||||
|
||||
# Feeds
|
||||
django.VERSION[1] >= 4 and \
|
||||
url(r'^feeds/maps/', maposmatic.feeds.MapsFeed(),
|
||||
url(r'^feeds/maps/', feeds.MapsFeed(),
|
||||
name='rss-feed') or \
|
||||
url(r'^feeds/(?P<url>.*)/$',
|
||||
'django.contrib.syndication.views.feed',
|
||||
{'feed_dict': {'maps': maposmatic.feeds.MapsFeed}},
|
||||
{'feed_dict': {'maps': feeds.MapsFeed}},
|
||||
name='rss-feed'),
|
||||
|
||||
# Internationalization
|
||||
|
|
Ładowanie…
Reference in New Issue