Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
nocturnos
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nt-s committed May 25, 2017
1 parent 237a8c7 commit a30f992
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions centros.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
dire = re.compile(r"^\s*Dirección:", re.MULTILINE | re.UNICODE | re.DOTALL)
coord = re.compile(r"&xIni=([\d\.]+)&yIni=([\d\.]+)")
minusculas = re.compile(r"[a-z]")
nocturno = re.compile(r".*\bnocturno\b.*")

datos = {}
tipos_des = {}
Expand Down Expand Up @@ -85,6 +86,7 @@ def get_data1(ctr):
data["INFO"] = gestiona_madrid + ctr
tipos_des[data["TIPO"]]=data["tlGenericoExt"].capitalize()
data["COD"] = ctr
data["NOCTURNO"] = [get_text(n.findParent("tr").find("td")) for n in soup.findAll(text=nocturno)]
return data


Expand Down Expand Up @@ -158,10 +160,16 @@ def get_data2(ctr):
kml.document.name = "Matemáticas - Madrid"

style_dificultad = simplekml.Style()
style_dificultad.iconstyle.icon.href = 'http://maps.google.com/mapfiles/ms/micons/red.png'
style_dificultad.iconstyle.color = simplekml.Color.red
style_dificultad.labelstyle.color = simplekml.Color.red
style_dificultad.iconstyle.icon.href = 'http://maps.google.com/mapfiles/ms/micons/red.png'

kml.document.style = style_dificultad

style_nocturno = simplekml.Style()
style_nocturno.iconstyle.color = simplekml.Color.grey
style_nocturno.iconstyle.icon.href = 'http://maps.google.com/mapfiles/ms/micons/grey.png'

kml.document.style = style_nocturno

for t in tipos:
folder = kml.newfolder(name=t)
Expand All @@ -175,14 +183,20 @@ def get_data2(ctr):
pnt = folder.newpoint(name=data["nombre"], coords=[data["coord"]])
pnt.description = textwrap.dedent(
'''
Código: %s<br/>
<b>%s</b> %s<br/>
Dirección: %s<br/>
URL: %s<br/>
DAT: %s<br/>
INFO: %s
''' % (data["COD"], data["direccion"], data["URL"], data["DAT"], data["INFO"])
''' % (data["COD"], data["DAT"], data["direccion"], data["URL"], data["INFO"])
).strip()
if data["COD"] in dificultad:
pnt.style = style_dificultad
pnt.description = pnt.description + "<br/>Centro de especial dificultad"
ntn=data.get("NOCTURNO", [])
if len(ntn)>0:
pnt.style = style_nocturno
pnt.description = pnt.description + "<br/>Nocturno en:"
for n in ntn:
pnt.description = pnt.description + "<br/>"+n

kml.save("centros.kml")

0 comments on commit a30f992

Please sign in to comment.