Fixed some regex
This commit is contained in:
parent
e2d0643db1
commit
13cb883085
20
fetch.py
20
fetch.py
@ -32,12 +32,24 @@ if __name__ == '__main__':
|
||||
diclist[index][element] = re.sub("<br.{0,2}>", "\n", diclist[index][element]) # Replace <br>, <br /> and <br/> by \n
|
||||
# Make a the area
|
||||
for area in diclist:
|
||||
# Polygons
|
||||
if "polygone" in area["zone"] or "Polygone" in area["zone"]:
|
||||
lst = re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .) ?\/ ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .)", area["zone"])
|
||||
# Case insensitive
|
||||
area["zone"] = area["zone"].lower()
|
||||
if "polygones" in area["zone"]:
|
||||
lst = []
|
||||
tmp = re.compile("zone . : .*").split(area["zone"])
|
||||
for polygon in tmp:
|
||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .) ?\/ ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .)", area["zone"]))
|
||||
area["zone"] = lst
|
||||
del lst
|
||||
elif "cercle" in area["zone"] or "Cercle" in area["zone"]:
|
||||
del tmp
|
||||
# Polygons
|
||||
elif "polygone" in area["zone"]:
|
||||
lst = []
|
||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”|\'\') ?.) ?\/ ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”|\'\') ?.)", area["zone"]))
|
||||
area["zone"] = lst
|
||||
del lst
|
||||
# Circles
|
||||
elif "cercle" in area["zone"]:
|
||||
lst = [()]
|
||||
lst[0] = re.search(r"(.{6}) .{0,5}?(\d{1,3},?\d{0,2} ?.{1,2}) .{1,35} ?(\d{3}° \d{1,2}' \d{1,2}” .) ?\/ ?(\d{1,3}° \d{1,2}' \d{1,2}” .)", area["zone"], re.S).groups()
|
||||
area["zone"] = lst
|
||||
|
Loading…
Reference in New Issue
Block a user