except (IOError, OSError): pass
dcache_fn = os.path.join(
dcachedir,
- uri.split(":")[1].replace("/","_")
+ uri.split(":",1)[1].replace("/","_")
)
now = time.time()
if cache_data and os.access(dcache_fn, os.R_OK) \
dcache_fd.close()
else:
try:
- if pyversion("3"): data = urlopen(uri).read().decode("utf-8")
- else: data = urlopen(uri).read()
+ data = urlopen(uri).read().decode("utf-8")
except URLError:
if ignore_fail: return ""
else:
print(
" (proximity %s, %.3gkm, %.3gmi)" % ( score, km, mi )
)
- elif searchtype is "coordinates":
+ elif searchtype == "coordinates":
print( " (%.3gkm, %.3gmi)" % (km, mi) )
if zone[0]:
print(
print(
" (proximity %s, %.3gkm, %.3gmi)" % ( score, km, mi )
)
- elif searchtype is "coordinates" and zone[0]:
+ elif searchtype == "coordinates" and zone[0]:
print( " (%.3gkm, %.3gmi)" % (km, mi) )
if cache_search:
now = time.time()
)
search_cache = ["\n"]
search_cache.append( "[%s]\n" % search[0] )
- search_cache.append( "description = cached %s\n" % nowstamp )
+ search_cache.append( "cached = %s\n" % nowstamp )
for uriname in sorted(uris.keys()):
search_cache.append( "%s = %s\n" % ( uriname, uris[uriname] ) )
real_cachedir = os.path.expanduser(cachedir)
if os.path.exists(overrideslog_fn):
os.rename(overrideslog_fn, "%s_old"%overrideslog_fn)
overrideslog_fd = codecs.open(overrideslog_fn, "w", "utf8")
+ import time
+ overrideslog_fd.write(
+ '# Copyright (c) %s Jeremy Stanley <fungi@yuggoth.org>. Permission to\n'
+ '# use, copy, modify, and distribute this software is granted under terms\n'
+ '# provided in the LICENSE file distributed with this software.\n\n'
+ % time.gmtime().tm_year)
overrideslog_fd.writelines(overrideslog)
overrideslog_fd.close()
print("done (%s overridden sections: +%s/-%s/!%s)." % (
if os.path.exists(qalog_fn):
os.rename(qalog_fn, "%s_old"%qalog_fn)
qalog_fd = codecs.open(qalog_fn, "w", "utf8")
+ import time
+ qalog_fd.write(
+ '# Copyright (c) %s Jeremy Stanley <fungi@yuggoth.org>. Permission to\n'
+ '# use, copy, modify, and distribute this software is granted under terms\n'
+ '# provided in the LICENSE file distributed with this software.\n\n'
+ % time.gmtime().tm_year)
qalog_fd.writelines(qalog)
qalog_fd.close()
if qalog: