def parse(self, iterator, config): super(FKColumn, self).parse(iterator, config) if self.fromcolumn is None: vo_raise(E02, config=config, pos=self._pos) if self.targetcolumn is None: vo_raise(E03, config=config, pos=self._pos)
def arraysize(self, arraysize): if all(( arraysize is not None, not re.match(r"^([0-9]+x)*[0-9]*[*]?(s\W)?$", arraysize) )): vo_raise(E01, arraysize, self._config, self._pos) self._arraysize = arraysize
def parse(self, iterator, config): super(ForeignKey, self).parse(iterator, config) if not self.targettable: vo_raise(E04, config=config, pos=self._pos) if not self.fkcolumns: vo_raise(E05, config=config, pos=self._pos)
def parse(self, iterator, config): super(Language, self).parse(iterator, config) if not self.name: vo_raise(E06, self._element_name, config=config, pos=self._pos) if not self.versions: vo_raise(E08, self._element_name, config=config, pos=self._pos)
def parse(self, iterator, config): super(Language, self).parse(iterator, config) if not self.name: vo_raise(E06, self._element_name, config=config, pos=self._pos) if not self.versions: vo_raise(E08, self._element_name, config=config, pos=self._pos)
def parse(self, iterator, config): for start, tag, data, pos in iterator: if start: if tag == "xml": pass elif tag == "capabilities": break else: vo_raise(E10, config=config, pos=pos) super(CapabilitiesFile, self).parse(iterator, config) return self
def parse(self, iterator, config): super(TablesFile, self).parse(iterator, config) if self.tableset is None and self.table is None: vo_raise(E07, config=config, pos=self._pos) self._version = config['version'] if config['version'] not in ('1.0', '1.1'): vo_warn(W15, config=config, pos=self._pos) if self.table: if version_compare(config['version'], '1.1') < 0: vo_warn(W16, config=config, pos=self._pos) self._ntables = 1 else: self._ntables = sum( len(schema.tables) for schema in self.tableset.schemas) return self
def vo_tab_parse(tab, url, kwargs): """ In case of errors from the server, a complete and correct 'stub' VOTable file may still be returned. This is to detect that case. Parameters ---------- tab : `astropy.io.votable.tree.VOTableFile` url : str URL used to obtain ``tab``. kwargs : dict Keywords used to obtain ``tab``, if any. Returns ------- out_tab : `astropy.io.votable.tree.Table` Raises ------ IndexError Table iterator fails. VOSError Server returns error message or invalid table. """ for param in tab.iter_fields_and_params(): if param.ID is not None and param.ID.lower() == 'error': if isinstance(param, tree.Param): e = param.value else: # pragma: no cover e = '' raise VOSError("Catalog server '{0}' returned error '{1}'".format( url, e)) for info in tab.infos: if info.name is not None and info.name.lower() == 'error': raise VOSError("Catalog server '{0}' returned error '{1}'".format( url, info.value)) if tab.resources == []: # pragma: no cover vo_raise(E19) for info in tab.resources[0].infos: if ((info.name == 'QUERY_STATUS' and info.value != 'OK') or (info.name is not None and info.name.lower() == 'error')): if info.content is not None: # pragma: no cover long_descr = ':\n{0}'.format(info.content) else: long_descr = '' raise VOSError("Catalog server '{0}' returned status " "'{1}'{2}".format(url, info.value, long_descr)) out_tab = tab.get_first_table() kw_sr = [k for k in kwargs if 'sr' == k.lower()] if len(kw_sr) == 0: sr = 0 else: sr = kwargs.get(kw_sr[0]) if sr != 0 and out_tab.array.size <= 0: raise VOSError("Catalog server '{0}' returned {1} result".format( url, out_tab.array.size)) out_tab.url = url # Track the URL return out_tab
def parse(self, iterator, config): super(InputParam, self).parse(iterator, config) if not self.name: vo_raise(E06, self._Element__name, config=config, pos=self._pos)
def parse(self, iterator, config): super(TableSchema, self).parse(iterator, config) if not self.name: vo_raise(E06, self._Element__name, config=config, pos=self._pos)
def parse(self, iterator, config): super(LanguageFeature, self).parse(iterator, config) if not self.form: vo_raise(E09, self._element_name, config=config, pos=self._pos)
def vo_tab_parse(tab, url, kwargs): """ In case of errors from the server, a complete and correct 'stub' VOTable file may still be returned. This is to detect that case. Parameters ---------- tab : `astropy.io.votable.tree.VOTableFile` url : str URL used to obtain ``tab``. kwargs : dict Keywords used to obtain ``tab``, if any. Returns ------- out_tab : `astropy.io.votable.tree.Table` Raises ------ IndexError Table iterator fails. VOSError Server returns error message or invalid table. """ for param in tab.iter_fields_and_params(): if param.ID is not None and param.ID.lower() == 'error': if isinstance(param, tree.Param): e = param.value else: # pragma: no cover e = '' raise VOSError("Catalog server '{0}' returned error '{1}'".format( url, e)) for info in tab.infos: if info.name is not None and info.name.lower() == 'error': raise VOSError("Catalog server '{0}' returned error '{1}'".format( url, info.value)) if tab.resources == []: # pragma: no cover vo_raise(E19) for info in tab.resources[0].infos: if ((info.name == 'QUERY_STATUS' and info.value != 'OK') or (info.name is not None and info.name.lower() == 'error')): if info.content is not None: # pragma: no cover long_descr = ':\n{0}'.format(info.content) else: long_descr = '' raise VOSError("Catalog server '{0}' returned status " "'{1}'{2}".format(url, info.value, long_descr)) out_tab = tab.get_first_table() kw_sr = [k for k in kwargs if 'sr' == k.lower()] if len(kw_sr) == 0: sr = 0 else: sr = kwargs.get(kw_sr[0]) if sr != 0 and out_tab.array.size <= 0: raise VOSError("Catalog server '{0}' returned {1} result".format( url, out_tab.array.size)) out_tab.url = url # Track the URL return out_tab
def parse(self, iterator, config): super(LanguageFeature, self).parse(iterator, config) if not self.form: vo_raise(E09, self._element_name, config=config, pos=self._pos)