lsst.daf.persistence  13.0-28-gf70af18
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Attributes | List of all members
lsst.daf.persistence.storageInterface.StorageInterface Class Reference

Public Member Functions

def __init__
 
def registerFormatter
 
def write
 
def read
 
def getLocalFile
 
def exists
 
def instanceSearch
 
def search
 
def copyFile
 
def locationWithRoot
 
def getRepositoryCfg
 
def putRepositoryCfg
 
def getMapperClass
 
def relativePath
 
def absolutePath
 

Static Public Attributes

dictionary formatters = {}
 

Detailed Description

Defines the interface for a connection to a Storage location.

Parameters
----------
uri : string
    URI or path that is used as the storage location.
create : bool
    If True The StorageInterface subclass should create a new
    repository at the root location. If False then a new repository
    will not be created.

Raises
------
NoRepositroyAtRoot
    If create is False and a repository does not exist at the root
    specified by uri then NoRepositroyAtRoot is raised.

Definition at line 31 of file storageInterface.py.

Constructor & Destructor Documentation

def lsst.daf.persistence.storageInterface.StorageInterface.__init__ (   self,
  uri,
  create 
)
initialzer

Definition at line 51 of file storageInterface.py.

Member Function Documentation

def lsst.daf.persistence.storageInterface.StorageInterface.absolutePath (   cls,
  fromPath,
  relativePath 
)
Get an absolute path for the path from fromUri to toUri

Parameters
----------
fromPath : the starting location
    A location at which to start. It can be a relative path or an
    absolute path.
relativePath : the location relative to fromPath
    A relative path.

Returns
-------
string
    Path that is an absolute path representation of fromPath +
    relativePath, if one exists. If relativePath is absolute or if
    fromPath is not related to relativePath then relativePath will be
    returned.

Definition at line 326 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.copyFile (   self,
  fromLocation,
  toLocation 
)
Copy a file from one location to another on the local filesystem.

Parameters
----------
fromLocation : string
    Path and name of existing file.
 toLocation : string
    Path and name of new file.

Returns
-------
None

Definition at line 214 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.exists (   self,
  location 
)
Check if location exists.

Parameters
----------
location : ButlerLocation or string
    A a string or a ButlerLocation that describes the location of an
    object in this storage.

Returns
-------
bool
    True if exists, else False.

Definition at line 152 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.getLocalFile (   self,
  path 
)
Get a handle to a local copy of the file, downloading it to a
temporary if needed.

Parameters
----------
path : string
    A path to the the file in storage, relative to root.

Returns
-------
A handle to a local copy of the file. If storage is remote it will be
a temporary file. If storage is local it may be the original file or
a temporary file. The file name can be gotten via the 'name' property
of the returned object.

Definition at line 134 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.getMapperClass (   cls,
  root 
)
Get the mapper class associated with a repository root.

Parameters
----------
root : string
    The location of a persisted RepositoryCfg is (new style repos).

Returns
-------
A class object or a class instance, depending on the state of the
mapper when the repository was created.

Definition at line 286 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.getRepositoryCfg (   cls,
  uri 
)
Get a persisted RepositoryCfg

Parameters
----------
uri : URI or path to a RepositoryCfg
    Description

Returns
-------
A RepositoryCfg instance or None

Definition at line 247 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.instanceSearch (   self,
  path 
)
Search for the given path in this storage instance.

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
----------
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 168 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.locationWithRoot (   self,
  location 
)
Get the full path to the location.

Parameters
----------
location : string
    Path to a location within the repository relative to repository
    root.

Returns
-------
string
    Absolute path to to the locaiton within the repository.

Definition at line 230 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.putRepositoryCfg (   cls,
  cfg,
  loc = None 
)
Serialize a RepositoryCfg to a location.

When loc == cfg.root, the RepositoryCfg is to be written at the root
location of the repository. In that case, root is not written, it is
implicit in the location of the cfg. This allows the cfg to move from
machine to machine without modification.

Parameters
----------
cfg : RepositoryCfg instance
    The RepositoryCfg to be serailized.
loc : string, optional
    The URI location (can be relative path) to write the RepositoryCfg.
    If loc is None, the location will be read from the root parameter
    of loc.

Returns
-------
None

Definition at line 262 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.read (   self,
  butlerLocation 
)
Read from a butlerLocation.

Parameters
----------
butlerLocation : ButlerLocation
    The location & formatting for the object(s) to be read.

Returns
-------
A list of objects as described by the butler location. One item for
each location in butlerLocation.getLocations()

Definition at line 119 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.registerFormatter (   cls,
  formatable,
  formatter 
)
Register a formatter for a storageInterface subclass

Parameters
----------
cls : StorageInterface subclass
    The type of StorageInterface the formatter is being registered for.
formatable : class object
    The class object whose instances can be formatted by the formatter.
formatter : Formatter class
    The formatter class that can be used by the StorageInterface instance to read and write the object
    to the storage.

Raises
------
RuntimeError
    For each object type and StorageInterface subclass a formatter should only be registered once. If
    a second registration occurs a RuntimeError is raised.

Definition at line 58 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.relativePath (   cls,
  fromPath,
  toPath 
)
Get a relative path from a location to a location.

Parameters
----------
fromPath : string
    A path at which to start. It can be a relative path or an
    absolute path.
toPath : string
    A target location. It can be a relative path or an absolute path.

Returns
-------
string
    A relative path that describes the path from fromPath to toPath.

Definition at line 304 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.search (   cls,
  root,
  path 
)
Look for the given path in the current root.

Also supports searching for the path in Butler v1 repositories by
following the Butler v1 _parent symlink

If the path contains an HDU indicator (a number in brackets, 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
    The path to the root directory.
path : string
    The path to the file within the root directory.

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

Definition at line 189 of file storageInterface.py.

def lsst.daf.persistence.storageInterface.StorageInterface.write (   self,
  butlerLocation,
  obj 
)
Writes an object to a location and persistence format specified by ButlerLocation

Parameters
----------
butlerLocation : ButlerLocation
    The location & formatting for the object to be written.
obj : object instance
    The object to be written.

Definition at line 107 of file storageInterface.py.

Member Data Documentation

dictionary lsst.daf.persistence.storageInterface.StorageInterface.formatters = {}
static

Definition at line 55 of file storageInterface.py.


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