def page_systems(): oec = app.oec p = [] debugtxt = "" fields = ["namelink"] filters = [] if "filters" in request.args: listfilters = request.args.getlist("filters") for filter in listfilters: if filter in oec_filters.titles: filters.append(filter) if "fields" in request.args: listfields = request.args.getlist("fields") for field in listfields: if field in oec_fields.titles and field != "namelink": fields.append(field) else: fields += [ "mass", "radius", "massEarth", "radiusEarth", "numberofplanets", "numberofstars" ] lastfilename = "" tablecolour = 0 for xmlPair in oec.planets: if oec_filters.isFiltered(xmlPair, filters): continue system, planet, star, filename = xmlPair if lastfilename != filename: lastfilename = filename tablecolour = not tablecolour d = {} d["fields"] = [tablecolour] for field in fields: d["fields"].append( oec_fields.render(xmlPair, field, editbutton=False)) p.append(d) return render_template( "systems.html", columns=[oec_fields.titles[field] for field in fields], planets=p, available_fields=oec_fields.titles, available_filters=oec_filters.titles, fields=fields, filters=filters, debugtxt=debugtxt)
def page_systems(): oec = app.oec p = [] debugtxt = "" fields = ["namelink"] filters = [] if "filters" in request.args: listfilters = request.args.getlist("filters") for filter in listfilters: if filter in oec_filters.titles: filters.append(filter) if "fields" in request.args: listfields = request.args.getlist("fields") for field in listfields: if field in oec_fields.titles and field!="namelink": fields.append(field) else: fields += ["mass","radius","massEarth","radiusEarth","numberofplanets","numberofstars"] lastfilename = "" tablecolour = 0 for xmlPair in oec.planets: if oec_filters.isFiltered(xmlPair,filters): continue system,planet,star,filename = xmlPair if lastfilename!=filename: lastfilename = filename tablecolour = not tablecolour d = {} d["fields"] = [tablecolour] for field in fields: d["fields"].append(oec_fields.render(xmlPair,field,editbutton=False)) p.append(d) return render_template("systems.html", columns=[oec_fields.titles[field] for field in fields], planets=p, available_fields=oec_fields.titles, available_filters=oec_filters.titles, fields=fields, filters=filters, debugtxt=debugtxt)
def page_planet(planetname): oec = app.oec try: xmlPair = oec.planetXmlPairs[planetname] except: abort(404) system,planet,star,filename = xmlPair planets=system.findall(".//planet") stars=system.findall(".//star") systemtable = [] for row in ["systemname","systemalternativenames","rightascension","declination","distance","distancelightyears","numberofstars","numberofplanets"]: systemtable.append((oec_fields.titles[row],oec_fields.render(xmlPair,row))) planettable = [] planettablefields = [] for row in ["name","alternativenames","description","lists","mass","massEarth","radius","radiusEarth","period","semimajoraxis","eccentricity","temperature","discoverymethod","discoveryyear","lastupdate"]: planettablefields.append(oec_fields.titles[row]) rowdata = [] for p in planets: rowdata.append(oec_fields.render((system,p,star,filename),row)) if len(set(rowdata)) <= 1 and row!="name" and rowdata[0]!=notAvailableString: # all fields identical: rowdata = rowdata[0] planettable.append(rowdata) startable = [] startablefields = [] for row in ["starname","staralternativenames","starmass","starradius","starage","starmetallicity","startemperature","starspectraltype","starmagV"]: startablefields.append(oec_fields.titles[row]) rowdata = [] for s in stars: rowdata.append(oec_fields.render((system,planet,s,filename),row)) if len(set(rowdata)) <= 1 and row!="starname" and rowdata[0]!=notAvailableString: # all fields identical: rowdata = rowdata[0] startable.append(rowdata) references = [] contributors = [] try: with open(oec.OEC_META_PATH+filename, 'rt') as f: root = ET.parse(f).getroot() for l in root.findall(".//link"): references.append(l.text) for c in root.findall(".//contributor"): contributors.append((c.attrib["commits"],c.attrib["email"],c.text)) except IOError: pass vizsize = visualizations.size(xmlPair) vizhabitable = visualizations.habitable(xmlPair) vizarchitecture = visualizations.textArchitecture(system) return render_template("planet.html", system=system, planet=planet, filename=filename, planetname=planetname, vizsize=vizsize, vizhabitable=vizhabitable, architecture=vizarchitecture, systemname=oec_fields.render(xmlPair,"systemname"), systemtable=systemtable, image=(oec_fields.render(xmlPair,"image"),oec_fields.render(xmlPair,"imagedescription")), planettablefields=planettablefields, planettable=planettable, startablefields=startablefields, startable=startable, references=references, contributors=contributors, systemcategory=oec_fields.render(xmlPair,"systemcategory"), )
def page_planet(planetname): oec = app.oec try: xmlPair = oec.planetXmlPairs[planetname] except: abort(404) system,planet,star,filename = xmlPair planets=system.findall(".//planet") stars=system.findall(".//star") systemtable = [] for row in ["systemname","systemalternativenames","rightascension","declination","distance","distancelightyears","numberofstars","numberofplanets"]: systemtable.append((oec_fields.titles[row],oec_fields.render(xmlPair,row))) planettable = [] planettablefields = [] for row in ["name","alternativenames","description","lists","mass","massEarth","radius","radiusEarth","period","semimajoraxis","eccentricity","temperature","discoverymethod","discoveryyear","lastupdate"]: planettablefields.append(oec_fields.titles[row]) rowdata = [] for p in planets: rowdata.append(oec_fields.render((system,p,star,filename),row)) if len(set(rowdata)) <= 1 and row!="name" and rowdata[0]!=notAvailableString: # all fields identical: rowdata = rowdata[0] planettable.append(rowdata) startable = [] startablefields = [] for row in ["starname","staralternativenames","starmass","starradius","starage","starmetallicity","startemperature","starspectraltype","starmagV"]: startablefields.append(oec_fields.titles[row]) rowdata = [] for s in stars: rowdata.append(oec_fields.render((system,planet,s,filename),row)) if len(set(rowdata)) <= 1 and row!="starname" and rowdata[0]!=notAvailableString: # all fields identical: rowdata = rowdata[0] startable.append(rowdata) references = [] contributors = [] with open(oec.OEC_META_PATH+filename, 'rt') as f: root = ET.parse(f).getroot() for l in root.findall(".//link"): references.append(l.text) for c in root.findall(".//contributor"): contributors.append((c.attrib["commits"],c.attrib["email"],c.text)) vizsize = visualizations.size(xmlPair) vizhabitable = visualizations.habitable(xmlPair) vizarchitecture = visualizations.textArchitecture(system) return render_template("planet.html", system=system, planet=planet, filename=filename, planetname=planetname, vizsize=vizsize, vizhabitable=vizhabitable, architecture=vizarchitecture, systemname=oec_fields.render(xmlPair,"systemname"), systemtable=systemtable, image=(oec_fields.render(xmlPair,"image"),oec_fields.render(xmlPair,"imagedescription")), planettablefields=planettablefields, planettable=planettable, startablefields=startablefields, startable=startable, references=references, contributors=contributors, systemcategory=oec_fields.render(xmlPair,"systemcategory"), )