eskp.py
changeset 1053 878b81ffb8f7
parent 1040 ee422f2e89c1
child 1056 cdd6167a71de
equal deleted inserted replaced
1052:4fae7e615b2b 1053:878b81ffb8f7
    47         with codecs.open(filename, 'r', 'utf-8') as f:
    47         with codecs.open(filename, 'r', 'utf-8') as f:
    48             rst_data = f.read()
    48             rst_data = f.read()
    49         content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body']
    49         content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body']
    50     return content
    50     return content
    51 
    51 
       
    52 def get_html_content(filename, overrides=None):
       
    53     html_content = u""
       
    54     filename = os.path.join(ESKP_PATH, filename)
       
    55     if os.path.isfile(filename):
       
    56         with codecs.open(filename, 'r', 'utf-8') as f:
       
    57             html_content = f.read()
       
    58 
       
    59     return html_content
    52 
    60 
    53 def get_newest_date():
    61 def get_newest_date():
    54     getdates = get_valid_dates(FILES)
    62     getdates = get_valid_dates(FILES)
    55     newest_date = getdates[-1]
    63     newest_date = getdates[-1]
    56 
    64 
   277 
   285 
   278 @app.route("/ozoneloss/uvmap")
   286 @app.route("/ozoneloss/uvmap")
   279 def ozoneloss_uvmap():
   287 def ozoneloss_uvmap():
   280     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvmap.rst")
   288     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvmap.rst")
   281     content = get_content(filename)
   289     content = get_content(filename)
   282     return render_template("/ozoneloss_uvmap.html", act="ozoneloss/uvmap", content=content)
   290 
       
   291     htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html")
       
   292     html_content = get_html_content(htmlfile)
       
   293     return render_template("/ozoneloss_uvmap.html", act="ozoneloss/uvmap", content=content,
       
   294                            html_content=html_content)
   283 
   295 
   284 
   296 
   285 @app.route("/ozoneloss/vpsc")
   297 @app.route("/ozoneloss/vpsc")
   286 def ozoneloss_vpsc():
   298 def ozoneloss_vpsc():
   287     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_vpsc.rst")
   299     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_vpsc.rst")
   289     return render_template("/ozoneloss_vpsc.html", act="ozoneloss/vpsc", content=content)
   301     return render_template("/ozoneloss_vpsc.html", act="ozoneloss/vpsc", content=content)
   290 
   302 
   291 
   303 
   292 @app.route("/ozoneloss/uvi", methods=['GET'])
   304 @app.route("/ozoneloss/uvi", methods=['GET'])
   293 def ozoneloss_uvi():
   305 def ozoneloss_uvi():
   294     # XXX check 'POST' does not work
       
   295     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   306     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   296     content = get_content(filename)
   307     content = get_content(filename)
       
   308     htmlfile = os.path.join("templates", get_locale(), "html", "ozoneloss_uvi_form.html")
       
   309     html_content = get_html_content(htmlfile)
       
   310     htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html")
       
   311     html_table = get_html_content(htmlfile)
   297 
   312 
   298     lat = 50.
   313     lat = 50.
   299     o3offset = 50.
   314     o3offset = 50.
   300     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, o3offset)
   315     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, o3offset)
       
   316     button_text = _("Graph anzeigen")
   301 
   317 
   302     return render_template('ozoneloss_uvi.html', act="ozoneloss/uvi", content=content, figname=figname,
   318     return render_template('ozoneloss_uvi.html', act="ozoneloss/uvi", content=content, figname=figname,
   303                            alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"))
   319                            alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"),
       
   320                                  html_content=html_content, html_table=html_table, button_text=button_text)
   304 
   321 
   305 
   322 
   306 @app.route("/ozoneloss/uvi_graph", methods=['POST'])
   323 @app.route("/ozoneloss/uvi_graph", methods=['POST'])
   307 def ozoneloss_uvi_graph():
   324 def ozoneloss_uvi_graph():
   308     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   325     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   309     content = get_content(filename)
   326     content = get_content(filename)
       
   327     htmlfile = os.path.join("templates", get_locale(), "html", "ozoneloss_uvi_form.html")
       
   328     html_content = get_html_content(htmlfile)
       
   329     htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html")
       
   330     html_table = get_html_content(htmlfile)
   310 
   331 
   311     latstr = request.form['Gradzahl']
   332     latstr = request.form['Gradzahl']
   312     o3offsetstr = request.form['Dobson-Unit']
   333     o3offsetstr = request.form['Dobson-Unit']
   313 
   334 
   314     latstr2 = latstr.replace(u'\xb0', '')
   335     latstr2 = latstr.replace(u'\xb0', '')
   319     if latstr2.endswith(u'S'):
   340     if latstr2.endswith(u'S'):
   320         latstr2 = latstr2.replace(u'S', '')
   341         latstr2 = latstr2.replace(u'S', '')
   321         lat = -float(latstr2)
   342         lat = -float(latstr2)
   322 
   343 
   323     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, float(o3offsetstr))
   344     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, float(o3offsetstr))
       
   345     button_text = _("Graph anzeigen")
   324 
   346 
   325     return render_template('graph.html', act="ozoneloss_uvi_graph", content=content, figname=figname,
   347     return render_template('graph.html', act="ozoneloss_uvi_graph", content=content, figname=figname,
   326                            o3offsetstr=o3offsetstr, latstr=latstr)
   348                            alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"),
       
   349                            o3offsetstr=o3offsetstr, latstr=latstr, html_content=html_content,
       
   350                            html_table=html_table, button_text=button_text)
   327 
   351 
   328 @app.route("/ozoneloss/decadal")
   352 @app.route("/ozoneloss/decadal")
   329 def ozoneloss_decadal():
   353 def ozoneloss_decadal():
   330     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_decadal.rst")
   354     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_decadal.rst")
   331     content = get_content(filename)
   355     content = get_content(filename)
Impressum Datenschutzerklärung