Package gmisclib :: Module cache
[frames] | no frames]

Module cache

source code

Classes
  CannotGetStat
  BadFileFormat
  cache_info
This class manages a disk cache of arbitrary objects.
Functions
tuple(str, str)
cachepath(f, tail='', root='')
OBSOLETE: Return a pathname suitable for cacheing some result.
source code
 
fileinfo(fname, *other)
Collect enough information about a file to determine whether or not the cache can be used.
source code
 
modFileInfo(fname, *other)
Collect enough information about a file to determine whether or not the cache can be used.
source code
 
modinfo(m, seen) source code
 
modinfo_guts(m, seen) source code
 
namedModInfo(nm) source code
 
walkcache(top)
This is to help humans read the cache.
source code
 
test_errs() source code
 
test_normal() source code
 
test() source code
Variables
  DEBUG = 0
  __package__ = 'gmisclib'

Imports: os, sys, stat, types, atexit, time, random, hashlib, cPickle, threading, g_mailbox, die, gpkmisc, UnpicklingError


Function Details

cachepath(f, tail='', root='')

source code 

OBSOLETE: Return a pathname suitable for cacheing some result.

Parameters:
  • f (often str, but could be anything convertible to a str via repr.) - An arbitrary key, could be a pathname or a tuple of information about a file.
  • tail (str or None) - something to add at the end of the constructed path.
Returns: tuple(str, str)
(path_to_root,path_with_tail). Path_to_root is/will be a directory; path_with_tail is a path to a data file within that directory. Normally, the actual cache is at the location os.path.join(path_to_root,path_with_tail) on the disk; that is what you would pass as the fname argument to load_cache or dump_cache.
Raises:
  • ValueError - if suffix_to_del is specified and f doesn't end that way.