def download_if_dne(href, filename):
if os.path.isfile(filename):
# print 'already downloaded:', href
return False
else:
if not href.startswith('http://'
href = 'http://maps.google.com' + href
print 'Fixed url :', href
try:
print 'downloading:', href
oa = openanything.fetch(href)
if oa['status']==200:
file = open( filename, 'w' )
file.write( oa['data'] )
file.close()
return True
except KeyboardInterrupt:
raise
except:
print '\tdownload failed -', sys.exc_info()[0]
return False
This code is an edit to the software ogmaps.
http://code.google.com/p/ogmaps/issues/detail?id=1
Error message:
File "ogmaps.py", line 36
href = 'http://maps.google.com' + href
^
SyntaxError: invalid syntax
I am not a python person and can’t figure out the reason for the error.
if not href.startswith('http://'should beif not href.startswith('http://'):