VOSDatabase¶
-
class
astropy.vo.client.vos_catalog.
VOSDatabase
(tree)[source] [edit on github]¶ Bases:
astropy.vo.client.vos_catalog.VOSBase
A class to represent a collection of
VOSCatalog
.Parameters: tree : JSON tree
Raises: VOSError
If given
tree
does not have ‘catalogs’ key or catalog is invalid.Attributes Summary
version
Database version number. Methods Summary
add_catalog
(name, cat[, allow_duplicate_url])Add a catalog to database. add_catalog_by_url
(name, url, **kwargs)Like add_catalog()
but the catalog is created with only the given name and access URL.create_empty
()Create an empty database of VO services. delete_catalog
(name)Delete a catalog from database with given name. delete_catalog_by_url
(url)Like delete_catalog()
but using access URL.from_json
(filename, **kwargs)Create a database of VO services from a JSON file. from_registry
(registry_url[, timeout])Create a database of VO services from VO registry URL. get_catalog
(name)Get one catalog of given name. get_catalog_by_url
(url)Like get_catalog()
but using access URL look-up.get_catalogs
()Iterator to get all catalogs. get_catalogs_by_url
(url)Like get_catalogs()
but using access URL look-up.list_catalogs
([pattern, sort])List catalog names. list_catalogs_by_url
([pattern, sort])Like list_catalogs()
but using access URL.merge
(other, **kwargs)Merge two database together. to_json
(filename[, clobber])Write database content to a JSON file. Attributes Documentation
-
version
¶ Database version number.
Methods Documentation
-
add_catalog
(name, cat, allow_duplicate_url=False)[source] [edit on github]¶ Add a catalog to database.
Parameters: name : str
Primary key for the catalog.
cat :
VOSCatalog
Catalog to add.
allow_duplicate_url : bool
Allow catalog with duplicate access URL?
Raises: VOSError
Invalid catalog.
DuplicateCatalogName
Catalog with given name already exists.
DuplicateCatalogURL
Catalog with given access URL already exists.
-
add_catalog_by_url
(name, url, **kwargs)[source] [edit on github]¶ Like
add_catalog()
but the catalog is created with only the given name and access URL.Parameters: name : str
Primary key for the catalog.
url : str
Access URL of the service. This is used to build queries.
kwargs : dict
Keywords accepted by
add_catalog()
.
-
classmethod
create_empty
()[source] [edit on github]¶ Create an empty database of VO services.
Empty database format:
{ "__version__": 1, "catalogs" : { } }
Returns: db :
VOSDatabase
Empty database.
-
delete_catalog
(name)[source] [edit on github]¶ Delete a catalog from database with given name.
Parameters: name : str
Primary key identifying the catalog.
Raises: MissingCatalog
If catalog is not found.
-
delete_catalog_by_url
(url)[source] [edit on github]¶ Like
delete_catalog()
but using access URL. On multiple matches, all matches are deleted.
-
classmethod
from_json
(filename, **kwargs)[source] [edit on github]¶ Create a database of VO services from a JSON file.
Example JSON format for Cone Search:
{ "__version__": 1, "catalogs" : { "My Cone Search": { "capabilityClass": "ConeSearch", "title": "My Cone Search", "url": "http://foo/cgi-bin/search?CAT=bar&", ... }, "Another Cone Search": { ... } } }
Parameters: filename : str
JSON file.
kwargs : dict
Keywords accepted by
get_readable_fileobj()
.Returns: db :
VOSDatabase
Database from given file.
-
classmethod
from_registry
(registry_url, timeout=60, **kwargs)[source] [edit on github]¶ Create a database of VO services from VO registry URL.
This is described in detail in Building the Database from Registry, except for the
validate_xxx
keys that are added by the validator itself.Parameters: registry_url : str
URL of VO registry that returns a VO Table. For example, see
astropy.vo.validator.validate.CS_MSTR_LIST
. Pedantic is automatically set toFalse
for parsing.timeout : number
Temporarily set
astropy.utils.data.Conf.remote_timeout
to this value to avoid time out error while reading the entire registry.kwargs : dict
Keywords accepted by
get_readable_fileobj()
.Returns: db :
VOSDatabase
Database from given registry.
Raises: VOSError
Invalid VO registry.
-
get_catalog
(name)[source] [edit on github]¶ Get one catalog of given name.
Parameters: name : str
Primary key identifying the catalog.
Returns: obj :
VOSCatalog
Raises: MissingCatalog
If catalog is not found.
-
get_catalog_by_url
(url)[source] [edit on github]¶ Like
get_catalog()
but using access URL look-up. On multiple matches, only first match is returned.
-
get_catalogs
()[source] [edit on github]¶ Iterator to get all catalogs.
-
get_catalogs_by_url
(url)[source] [edit on github]¶ Like
get_catalogs()
but using access URL look-up.
-
list_catalogs
(pattern=None, sort=True)[source] [edit on github]¶ List catalog names.
Parameters: pattern : str or
None
If given string is anywhere in a catalog name, it is considered a matching catalog. It accepts patterns as in
fnmatch
and is case-insensitive. By default, all catalogs are returned.sort : bool
Sort output in alphabetical order. If not sorted, the order depends on dictionary hashing. Default is
True
.Returns: out_arr : list of str
List of catalog names.
-
list_catalogs_by_url
(pattern=None, sort=True)[source] [edit on github]¶ Like
list_catalogs()
but using access URL.
-
merge
(other, **kwargs)[source] [edit on github]¶ Merge two database together.
Parameters: other :
VOSDatabase
The other database to merge.
kwargs : dict
Keywords accepted by
add_catalog()
.Returns: db :
VOSDatabase
Merged database.
Raises: VOSError
Invalid database or incompatible version.
-
to_json
(filename, clobber=False)[source] [edit on github]¶ Write database content to a JSON file.
Parameters: filename : str
JSON file.
clobber : bool
Overwrite existing file?
Raises: OSError
File exists.
-