lsst.daf.persistence g6a31054a6e+047df862d9
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.daf.persistence.storage.Storage Class Reference

Public Member Functions

def __init__ (self)
 
def getRepositoryCfg (self, uri)
 

Static Public Member Functions

def registerStorageClass (scheme, cls)
 
def putRepositoryCfg (cfg, uri)
 
def getMapperClass (uri)
 
def makeFromURI (uri, create=True)
 
def isPosix (uri)
 
def relativePath (fromUri, toUri)
 
def absolutePath (fromUri, toUri)
 
def search (uri, path)
 
def storageExists (uri)
 

Public Attributes

 repositoryCfgs
 

Static Public Attributes

dictionary storages = {}
 

Detailed Description

Base class for storages

Definition at line 29 of file storage.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.daf.persistence.storage.Storage.__init__ (   self)

Definition at line 34 of file storage.py.

Member Function Documentation

◆ absolutePath()

def lsst.daf.persistence.storage.Storage.absolutePath (   fromUri,
  toUri 
)
static
Get an absolute path for the path from fromUri to toUri

Parameters
----------
fromUri : the starting location
    Description
toUri : the location relative to fromUri
    Description

Returns
-------
string
    URI that is absolutepath fromUri + toUri, if one exists. If toUri is absolute or if fromUri is not
    related to toUri (e.g. are of different storage types) then toUri will be returned.

Definition at line 220 of file storage.py.

◆ getMapperClass()

def lsst.daf.persistence.storage.Storage.getMapperClass (   uri)
static
Get a mapper class cfg value from location described by uri.

Note that in legacy repositories the mapper may be specified by a file called _mapper at the uri
location, and in newer repositories the mapper would be specified by a RepositoryCfg stored at the uri
location.

.. warning::

    Storage is 'wet paint' and very likely to change during factorization of Butler back end and
    storage formats (DM-6225). Use of it in production code other than via the 'old butler' API is
    strongly discouraged.

Definition at line 103 of file storage.py.

◆ getRepositoryCfg()

def lsst.daf.persistence.storage.Storage.getRepositoryCfg (   self,
  uri 
)
Get a RepositoryCfg from a location specified by uri.

If a cfg is found then it is cached by the uri, so that multiple lookups
are not performed on storages that might be remote.

RepositoryCfgs are not supposed to change once they are created so this
should not lead to stale data.

Definition at line 70 of file storage.py.

◆ isPosix()

def lsst.daf.persistence.storage.Storage.isPosix (   uri)
static
Test if a URI is for a local filesystem storage.

This is mostly for backward compatibility; Butler V1 repositories were only ever on the local
filesystem. They may exist but not have a RepositoryCfg class. This enables conditional checking for a
V1 Repository.

This function treats 'file' and '' (no scheme) as posix storages, see
the class docstring for more details.

Parameters
----------
uri : string
    URI to the root of a Repository.

Returns
-------
Bool
    True if the URI is associated with a posix storage, else false.

Definition at line 168 of file storage.py.

◆ makeFromURI()

def lsst.daf.persistence.storage.Storage.makeFromURI (   uri,
  create = True 
)
static
Instantiate a StorageInterface sublcass from a URI.

.. warning::

    Storage is 'wet paint' and very likely to change during factorization of Butler back end and
    storage formats (DM-6225). Use of it in production code other than via the 'old butler' API is
    strongly discouraged.

Parameters
----------
uri : string
    The uri to the root location of a repository.
create : bool, optional
    If True The StorageInterface subclass should create a new
    repository at the root location. If False then a new repository
    will not be created.

Returns
-------
A Storage subclass instance, or if create is False and a repository
does not exist at the root location then returns None.

Raises
------
RuntimeError
    When a StorageInterface subclass does not exist for the scheme
    indicated by the uri.

Definition at line 126 of file storage.py.

◆ putRepositoryCfg()

def lsst.daf.persistence.storage.Storage.putRepositoryCfg (   cfg,
  uri 
)
static
Write a RepositoryCfg object to a location described by uri

Definition at line 92 of file storage.py.

◆ registerStorageClass()

def lsst.daf.persistence.storage.Storage.registerStorageClass (   scheme,
  cls 
)
static
Register derived classes for lookup by URI scheme.

A scheme is a name that describes the form a resource at the beginning of a URI
e.g. 'http' indicates HTML and related code, such as is found in http://www.lsst.org

The only currently supported schemes are:
* 'file' where the portion of the URI after the // indicates an absolute locaiton on disk.
  for example: file:/my_repository_folder/
* '' (no scheme) where the entire string is a relative path on the local system
  for example "my_repository_folder" will indicate a folder in the current working directory with the
  same name.

See documentation for the urlparse python library for more information.

.. warning::

    Storage is 'wet paint' and very likely to change during factorization of Butler back end and
    storage formats (DM-6225). Use of it in production code other than via the 'old butler' API is
    strongly discouraged.

Parameters
----------
scheme : str
    Name of the `scheme` the class is being registered for, which appears at the beginning of a URI.
cls : class object
    A class object that should be used for a given scheme.

Definition at line 38 of file storage.py.

◆ relativePath()

def lsst.daf.persistence.storage.Storage.relativePath (   fromUri,
  toUri 
)
static
Get a relative path from a location to a location, if a relative path for these 2 locations exists.

Parameters
----------
fromPath : string
    A URI that describes a location at which to start.
toPath : string
    A URI that describes a target location.

Returns
-------
string
    A relative path that describes the path from fromUri to toUri, provided one exists. If a relative
    path between the two URIs does not exist then the entire toUri path is returned.

Definition at line 194 of file storage.py.

◆ search()

def lsst.daf.persistence.storage.Storage.search (   uri,
  path 
)
static
Look for the given path in a storage root at URI; return None if it can't be found.

If the path contains an HDU indicator (a number in brackets before the
dot, e.g. 'foo.fits[1]', this will be stripped when searching and so
will match filenames without the HDU indicator, e.g. 'foo.fits'. The
path returned WILL contain the indicator though, e.g. ['foo.fits[1]'].


Parameters
----------
root : string
    URI to the the root location to search
path : string
    A filename (and optionally prefix path) to search for within root.

Returns
-------
string or None
    The location that was found, or None if no location was found.

Definition at line 246 of file storage.py.

◆ storageExists()

def lsst.daf.persistence.storage.Storage.storageExists (   uri)
static
Ask if a storage at the location described by uri exists

Parameters
----------
root : string
    URI to the the root location of the storage

Returns
-------
bool
    True if the storage exists, false if not

Definition at line 274 of file storage.py.

Member Data Documentation

◆ repositoryCfgs

lsst.daf.persistence.storage.Storage.repositoryCfgs

Definition at line 35 of file storage.py.

◆ storages

dictionary lsst.daf.persistence.storage.Storage.storages = {}
static

Definition at line 32 of file storage.py.


The documentation for this class was generated from the following file: