Changes between Initial Version and Version 1 of ScantableFromUrl


Ignore:
Timestamp:
12/14/11 11:54:29 (13 years ago)
Author:
Malte Marquarding
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ScantableFromUrl

    v1 v1  
     1Create a wrapper to also allow scanbtable creation directly from a file on the web.
     2
     3{{{
     4import urllib2
     5import tempfile
     6from asap import scantable
     7
     8def 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
     17if __name__ == "__main__":
     18    s = urlscantable("http://www.narrabri.atnf.csiro.au/mopra/DataDepot/2008-03-12_0932-M999.rp\
     19f")
     20    print s
     21
     22}}}