projects
/
weather.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use regex for alert content smart filter
[weather.git]
/
weather.py
diff --git
a/weather.py
b/weather.py
index
17a0e12
..
62f73da
100644
(file)
--- a/
weather.py
+++ b/
weather.py
@@
-336,10
+336,11
@@
def get_alert(
if alert:
if verbose: return alert
else:
if alert:
if verbose: return alert
else:
- if alert.find("\nNATIONAL WEATHER SERVICE") == -1:
- muted = False
- else:
+ import re
+ if re.search(r"\nNational Weather Service", alert):
muted = True
muted = True
+ else:
+ muted = False
lines = alert.split("\n")
import time
# TODO: make this offset configurable
lines = alert.split("\n")
import time
# TODO: make this offset configurable
@@
-360,7
+361,7
@@
def get_alert(
if line.startswith("Expires:") \
and "Expires:" + valid_time > line:
return ""
if line.startswith("Expires:") \
and "Expires:" + valid_time > line:
return ""
- if muted and line.startswith("N
ATIONAL WEATHER SERVICE
"):
+ if muted and line.startswith("N
ational Weather Service
"):
muted = False
line = ""
elif line == "&&":
muted = False
line = ""
elif line == "&&":
@@
-1239,7
+1240,7
@@
def gecos(formatted):
return tuple(coordinates)
def correlate():
return tuple(coordinates)
def correlate():
- import codecs, csv, datetime, hashlib, os, re, sys, time, zipfile
+ import codecs, csv, datetime, hashlib, os, re, sys, time, zipfile
, zoneinfo
if pyversion("3"): import configparser
else: import ConfigParser as configparser
for filename in os.listdir("."):
if pyversion("3"): import configparser
else: import ConfigParser as configparser
for filename in os.listdir("."):
@@
-2138,6
+2139,7
@@
def correlate():
zctas_nocentroid += 1
zones_nocentroid = 0
zones_nodescription = 0
zctas_nocentroid += 1
zones_nocentroid = 0
zones_nodescription = 0
+ zones_notz = 0
zones_noforecast = 0
zones_overlapping = 0
zonetable = {}
zones_noforecast = 0
zones_overlapping = 0
zonetable = {}
@@
-2165,6
+2167,10
@@
def correlate():
if not zones.has_option(zone, "description"):
qalog.append("%s: no description\n" % zone)
zones_nodescription += 1
if not zones.has_option(zone, "description"):
qalog.append("%s: no description\n" % zone)
zones_nodescription += 1
+ if not zones.has_option(zone, "tz") or not zones.get(
+ zone, "tz") in zoneinfo.available_timezones():
+ qalog.append("%s: no time zone\n" % zone)
+ zones_notz += 1
if not zones.has_option(zone, "zone_forecast"):
qalog.append("%s: no forecast\n" % zone)
zones_noforecast += 1
if not zones.has_option(zone, "zone_forecast"):
qalog.append("%s: no forecast\n" % zone)
zones_noforecast += 1
@@
-2201,6
+2207,8
@@
def correlate():
print(" %s zones with no centroid"%zones_nocentroid)
if zones_nodescription:
print(" %s zones with no description"%zones_nodescription)
print(" %s zones with no centroid"%zones_nocentroid)
if zones_nodescription:
print(" %s zones with no description"%zones_nodescription)
+ if zones_notz:
+ print(" %s zones with no time zone"%zones_notz)
if zones_noforecast:
print(" %s zones with no forecast"%zones_noforecast)
if zones_overlapping:
if zones_noforecast:
print(" %s zones with no forecast"%zones_noforecast)
if zones_overlapping: