Пример #1
0
 def table(self):
     if self.__file is None:
         self.__file = tempfile.NamedTemporaryFile()
         self.__file.write(self.data.encode('utf-8'))
         self.__file.flush()
         self.__table = votable.parse_single_table(self.__file, pedantic=False).to_table()
     return self.__table
Пример #2
0
def getVOTable(url, table_number):
    """
   Returns VOTable from a URL and table number
   """

    tmp = tempfile.mkstemp(".xml", "pogs", None, False)
    file = tmp[0]
    os.close(file)
    xml_file = tmp[1]
    table = None
    try:
        req = urllib2.Request(url)
        response = urllib2.urlopen(req, timeout=10)
        with open(xml_file, 'w') as file:
            file.write(response.read())
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            table = parse_single_table(xml_file,
                                       pedantic=False,
                                       table_number=table_number)
    except:
        raise Exception("Problem contacting VOTable provider")
    finally:
        os.remove(xml_file)

    return table
Пример #3
0
 def table(self):
     if self.__file is None:
         self.__file = tempfile.NamedTemporaryFile()
         self.__file.write(self.data.encode('utf-8'))
         self.__file.flush()
         # if bibcode query then first create table from raw data
         bibcode_match = bibcode_regex.search(self.script)
         if bibcode_match:
             self.__table = _create_bibcode_table(self.data, bibcode_match.group(2))
         else:
             self.__table = votable.parse_single_table(self.__file, pedantic=False).to_table()
     return self.__table
Пример #4
0
 def table(self):
     if self.__file is None:
         self.__file = tempfile.NamedTemporaryFile()
         self.__file.write(self.data.encode('utf-8'))
         self.__file.flush()
         # if bibcode query then first create table from raw data
         bibcode_match = bibcode_regex.search(self.script)
         if bibcode_match:
             self.__table = _create_bibcode_table(self.data, bibcode_match.group(2))
         else:
             self.__table = votable.parse_single_table(self.__file, pedantic=False).to_table()
     return self.__table
Пример #5
0
def getVOTable(url,table_number):
   """
   Returns VOTable from a URL and table number
   """

   tmp = tempfile.mkstemp(".xml", "pogs", None, False)
   file = tmp[0]
   os.close(file)
   xml_file = tmp[1]
   table = None
   try: 
      req = urllib2.Request(url)
      response = urllib2.urlopen(req,timeout=10)
      with open(xml_file, 'w') as file:
         file.write(response.read())
      with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         table = parse_single_table(xml_file,pedantic=False,table_number=table_number)
   except:
      raise Exception("Problem contacting VOTable provider")
   finally:
      os.remove(xml_file)

   return table