projects
/
weather.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Py3K compatibility for compressed correlation
[weather.git]
/
weather.py
diff --git
a/weather.py
b/weather.py
index
a8ff613
..
af43de4
100644
(file)
--- a/
weather.py
+++ b/
weather.py
@@
-6,7
+6,7
@@
weather_copyright = """\
# provided in the LICENSE file distributed with this software.
#"""
# provided in the LICENSE file distributed with this software.
#"""
-weather_version = "2.
2
"
+weather_version = "2.
3
"
radian_to_km = 6372.795484
radian_to_mi = 3959.871528
radian_to_km = 6372.795484
radian_to_mi = 3959.871528
@@
-744,7
+744,10
@@
def guess(
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
- stations.readfp( gzip.open(datafile) )
+ if pyversion("3"):
+ stations.read_string(
+ gzip.open(datafile).read().decode("utf-8") )
+ else: stations.readfp( gzip.open(datafile) )
else:
stations.read(datafile)
else:
else:
stations.read(datafile)
else:
@@
-760,7
+763,9
@@
def guess(
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
- zones.readfp( gzip.open(datafile) )
+ if pyversion("3"):
+ zones.read_string( gzip.open(datafile).read().decode("utf-8") )
+ else: zones.readfp( gzip.open(datafile) )
else:
zones.read(datafile)
else:
else:
zones.read(datafile)
else:
@@
-784,7
+789,10
@@
def guess(
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
- airports.readfp( gzip.open(datafile) )
+ if pyversion("3"):
+ airports.read_string(
+ gzip.open(datafile).read().decode("utf-8") )
+ else: airports.readfp( gzip.open(datafile) )
else:
airports.read(datafile)
else:
else:
airports.read(datafile)
else:
@@
-870,7
+878,10
@@
def guess(
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
- zctas.readfp( gzip.open(datafile) )
+ if pyversion("3"):
+ zctas.read_string(
+ gzip.open(datafile).read().decode("utf-8") )
+ else: zctas.readfp( gzip.open(datafile) )
else:
zctas.read(datafile)
else:
else:
zctas.read(datafile)
else:
@@
-925,7
+936,10
@@
def guess(
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
datafile = datafiles[dataname][0]
if datafile.endswith(".gz"):
import gzip
- places.readfp( gzip.open(datafile) )
+ if pyversion("3"):
+ places.read_string(
+ gzip.open(datafile).read().decode("utf-8") )
+ else: places.readfp( gzip.open(datafile) )
else:
places.read(datafile)
else:
else:
places.read(datafile)
else:
@@
-1531,12
+1545,13
@@
def correlate():
zones[zone]["description"] = description
for line in data[1:]:
line = line.decode("latin1").strip()
zones[zone]["description"] = description
for line in data[1:]:
line = line.decode("latin1").strip()
- urimatch = re.match("/webdocs/(.+):(.+) for ", line)
+ urimatch = re.match("/webdocs/pub/(.+):(.+) for ",
+ line)
if urimatch:
uritype = urimatch.group(2).lower().replace(" ","_")
if urimatch:
uritype = urimatch.group(2).lower().replace(" ","_")
- zones[zone][uritype]
\
- = "http://weather.noaa.gov/%s" \
- % urimatch.group(1)
+ zones[zone][uritype]
= (
+ "http://tgftp.nws.noaa.gov/%s"
+ % urimatch.group(1)
)
count += 1
zcatalog.close()
print("done (%s files)." % count)
count += 1
zcatalog.close()
print("done (%s files)." % count)