| 1 | Create a wrapper to also allow scanbtable creation directly from a file on the web. |
| 2 | |
| 3 | {{{ |
| 4 | import urllib2 |
| 5 | import tempfile |
| 6 | from asap import scantable |
| 7 | |
| 8 | def urlscantable(*args, **kwargs): |
| 9 | if isinstance(args[0], basestring) and args[0].startswith("http"): |
| 10 | url = urllib2.urlopen(args[0]) |
| 11 | tfile = tempfile.NamedTemporaryFile() |
| 12 | tfile.write(url.read()) |
| 13 | return scantable(tfile.name, *args[1:], **kwargs) |
| 14 | else: |
| 15 | return scantable(*args, **kwargs) |
| 16 | |
| 17 | if __name__ == "__main__": |
| 18 | s = urlscantable("http://www.narrabri.atnf.csiro.au/mopra/DataDepot/2008-03-12_0932-M999.rp\ |
| 19 | f") |
| 20 | print s |
| 21 | |
| 22 | }}} |