| LSSTApplications
    20.0.0
    LSSTDataManagementBasePackage | 
 
 
 
Go to the documentation of this file.
   24 from abc 
import ABCMeta, abstractmethod
 
   32     """Defines the interface for a connection to a Storage location. 
   37         URI or path that is used as the storage location. 
   39         If True The StorageInterface subclass should create a new 
   40         repository at the root location. If False then a new repository 
   46         If create is False and a repository does not exist at the root 
   47         specified by uri then NoRepositroyAtRoot is raised. 
   49     __metaclass__ = ABCMeta
 
   56     def _readFormatters(cls):
 
   57         """Getter for the container of read formatters of a StorageInterface subclass. 
   62             The read formatters container belonging to the class type. 
   66         except AttributeError:
 
   71     def _writeFormatters(cls):
 
   72         """Getter for the container of write formatters of a StorageInterface subclass. 
   77             The write formatters container belonging to the class type. 
   81         except AttributeError:
 
   87         """Search in the registered formatters for the objType read formatter. 
   92             The type of class to find a formatter for. 
   97             The formatter callable used to read the object from the storageInterface. 
  103         """Search in the registered formatters for the objType write formatter. 
  108             The type of class to find a formatter for. 
  113             The formatter callable used to write the object to the storageInterface. 
  119         """Register read and/or write formatters for a storageInterface subclass 
  123         cls : StorageInterface subclass 
  124             The type of StorageInterface the formatter is being registered for. 
  125         formatable : class object 
  126             The class object whose instances can be formatted by the formatter. 
  127         readFormatter : a read formatter callable 
  128             The formatter function that can be used by the StorageInterface instance to read the object from 
  130         writeFormatter : a write formatter callable 
  131             The formatter function that can be used by the StorageInterface instance to write the object to 
  137             For each object type and StorageInterface subclass the read and write formatters should only be 
  138             registered once. If a second registration occurs for either a RuntimeError is raised. 
  140         def register(formatable, formatter, formatters, storageInterface):
 
  141             if formatable 
in formatters:
 
  142                 raise RuntimeError((
"Registration of second formatter {} for formattable {} in " 
  143                                     " storageInterface {}").
format(formatter, formatable, storageInterface))
 
  144             formatters[formatable] = formatter
 
  148             register(formatable, readFormatter, formatters, cls)
 
  151             register(formatable, writeFormatter, formatters, cls)
 
  154     def write(self, butlerLocation, obj):
 
  155         """Writes an object to a location and persistence format specified by ButlerLocation 
  159         butlerLocation : ButlerLocation 
  160             The location & formatting for the object to be written. 
  161         obj : object instance 
  162             The object to be written. 
  166     def read(self, butlerLocation):
 
  167         """Read from a butlerLocation. 
  171         butlerLocation : ButlerLocation 
  172             The location & formatting for the object(s) to be read. 
  176         A list of objects as described by the butler location. One item for 
  177         each location in butlerLocation.getLocations() 
  182         """Get a handle to a local copy of the file, downloading it to a 
  188             A path to the the file in storage, relative to root. 
  192         A handle to a local copy of the file. If storage is remote it will be 
  193         a temporary file. If storage is local it may be the original file or 
  194         a temporary file. The file name can be gotten via the 'name' property 
  195         of the returned object. 
  200         """Check if location exists. 
  204         location : ButlerLocation or string 
  205             A a string or a ButlerLocation that describes the location of an 
  206             object in this storage. 
  211             True if exists, else False. 
  216         """Search for the given path in this storage instance. 
  218         If the path contains an HDU indicator (a number in brackets before the 
  219         dot, e.g. 'foo.fits[1]', this will be stripped when searching and so 
  220         will match filenames without the HDU indicator, e.g. 'foo.fits'. The 
  221         path returned WILL contain the indicator though, e.g. ['foo.fits[1]']. 
  226             A filename (and optionally prefix path) to search for within root. 
  231             The location that was found, or None if no location was found. 
  237         """Look for the given path in the current root. 
  239         Also supports searching for the path in Butler v1 repositories by 
  240         following the Butler v1 _parent symlink 
  242         If the path contains an HDU indicator (a number in brackets, e.g. 
  243         'foo.fits[1]', this will be stripped when searching and so 
  244         will match filenames without the HDU indicator, e.g. 'foo.fits'. The 
  245         path returned WILL contain the indicator though, e.g. ['foo.fits[1]']. 
  250             The path to the root directory. 
  252             The path to the file within the root directory. 
  257             The location that was found, or None if no location was found. 
  262         """Copy a file from one location to another on the local filesystem. 
  266         fromLocation : string 
  267             Path and name of existing file. 
  269             Path and name of new file. 
  278         """Get the full path to the location. 
  283             Path to a location within the repository relative to repository 
  289             Absolute path to to the locaiton within the repository. 
  295         """Get a persisted RepositoryCfg 
  299         uri : URI or path to a RepositoryCfg 
  304         A RepositoryCfg instance or None 
  310         """Serialize a RepositoryCfg to a location. 
  312         When loc == cfg.root, the RepositoryCfg is to be written at the root 
  313         location of the repository. In that case, root is not written, it is 
  314         implicit in the location of the cfg. This allows the cfg to move from 
  315         machine to machine without modification. 
  319         cfg : RepositoryCfg instance 
  320             The RepositoryCfg to be serailized. 
  321         loc : string, optional 
  322             The URI location (can be relative path) to write the RepositoryCfg. 
  323             If loc is None, the location will be read from the root parameter 
  334         """Get the mapper class associated with a repository root. 
  339             The location of a persisted RepositoryCfg is (new style repos). 
  343         A class object or a class instance, depending on the state of the 
  344         mapper when the repository was created. 
  352         """Get a relative path from a location to a location. 
  357             A path at which to start. It can be a relative path or an 
  360             A target location. It can be a relative path or an absolute path. 
  365             A relative path that describes the path from fromPath to toPath. 
  374         """Get an absolute path for the path from fromUri to toUri 
  378         fromPath : the starting location 
  379             A location at which to start. It can be a relative path or an 
  381         relativePath : the location relative to fromPath 
  387             Path that is an absolute path representation of fromPath + 
  388             relativePath, if one exists. If relativePath is absolute or if 
  389             fromPath is not related to relativePath then relativePath will be 
  
def getMapperClass(cls, root)
def write(self, butlerLocation, obj)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
def search(cls, root, path)
def copyFile(self, fromLocation, toLocation)
def __init__(self, uri, create)
def putRepositoryCfg(cls, cfg, loc=None)
def getWriteFormatter(cls, objType)
def getLocalFile(self, path)
def instanceSearch(self, path)
def getReadFormatter(cls, objType)
def absolutePath(cls, fromPath, relativePath)
def getRepositoryCfg(cls, uri)
def read(self, butlerLocation)
def exists(self, location)
def registerFormatters(cls, formatable, readFormatter=None, writeFormatter=None)
def relativePath(cls, fromPath, toPath)
def locationWithRoot(self, location)
def _writeFormatters(cls)