Package sabayon :: Module cache :: Class cacheRepository
[hide private]
[frames] | no frames]

Class cacheRepository

source code

This is a remote resource cache, based on Python native urllib2 and implementing a local cache for remote resources. It will provide access to copies of the resources if unavailable and try to transfer only files remotely modified from the cache.

Instance Methods [hide private]
  __init__(self, directory=None)
  __ensure_directory(self, directory, remove_old)
  __check_directory(self)
  __URL_mapping(self, URL)
Function to convert an URL to a local name in the cache
  __save_catalog(self)
Save the on disk catalog in XML format
  __update_catalog(self, URL, timestamp=None)
Update the catalog of resources in the cache with an updated entry
  __catalog_lookup(self, URL)
lookup an entry in the catalog, it will return a tuple of the file path and the timestamp if found, None otherwise.
  get_resource(self, URL)
Get a resource from the cache.

Method Details [hide private]

__init__(self, directory=None)
(Constructor)

source code 
None

__ensure_directory(self, directory, remove_old)

source code 
None

__check_directory(self)

source code 
None

__URL_mapping(self, URL)

source code 
Function to convert an URL to a local name in the cache

__save_catalog(self)

source code 
Save the on disk catalog in XML format

__update_catalog(self, URL, timestamp=None)

source code 
Update the catalog of resources in the cache with an updated entry

__catalog_lookup(self, URL)

source code 
lookup an entry in the catalog, it will return a tuple of the file path and the timestamp if found, None otherwise. If the file is referenced in the cache but has not timestamp then it will return an empty string.

get_resource(self, URL)

source code 
Get a resource from the cache. It may fetch it from the network or use a local copy. It returns a Python file liek open() would. If passed a filename it will accept it if absolute. The return value is an absolute path to a local file.