source: DPPP/kml/csml2kml/python/csml2kml/csml2kml/utils.py @ 3612

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/kml/csml2kml/python/csml2kml/csml2kml/utils.py@3612
Revision 3612, 750 bytes checked in by mkochan, 11 years ago (diff)

Added Epydoc fields to comments.

Line 
1'''
2Utility/convenience functions.
3'''
4
5import urllib2
6
7def wget(url):
8    '''
9    Read data from an URL.
10    @param url: The URL.
11    @type url: C{str}
12    @return: The returned data as a string, or C{None} on retrieval error.
13    @rtype: C{str}
14    '''
15    content = None
16    try:
17        try:
18            f = urllib2.urlopen(url)         # open a file-like object with the data
19            content = f.read()               # read the text in
20        except urllib2.HTTPError:
21            pass                             # error in retrieval, wget() will return None
22    finally:
23        try:
24            f.close()
25        except NameError:
26            pass                             # f uninitialised, so no need to close it
27    return content
Note: See TracBrowser for help on using the repository browser.