# Description : Simple RSS Reader
# ============================================================================
+from __future__ import with_statement
+
import sqlite3
from os.path import isfile, isdir
from shutil import rmtree
abs_url = urljoin(baseurl,url)
f = opener.open(abs_url)
- outf = open(filename, "w")
- outf.write(f.read())
- f.close()
- outf.close()
+ try:
+ with open(filename, "w") as outf:
+ for data in f:
+ outf.write(data)
+ finally:
+ f.close()
except (urllib2.HTTPError, urllib2.URLError, IOError), exception:
logger.info("Could not download image %s: %s"
% (abs_url, str (exception)))