def __init__(self, root): """ Return a db object that will manage the specied directory""" self.root = Path(root).expanduser().abspath() if not self.root.isdir(): self.root.makedirs_p() # cache has { 'key' : (obj, orig_mod_time) } self.cache = {}
def keys(self, globpat=None): """ All keys in DB, or all keys matching a glob""" if globpat is None: files = self.root.walkfiles() else: files = [Path(p) for p in glob.glob(self.root / globpat)] return [self._normalized(p) for p in files if p.isfile()]
def __repr__(self): db = self.__dict__['db'] keys = db.keys(self.__dict__['keydir'] + "/*") return "<PickleShareLink '%s': %s>" % ( self.__dict__['keydir'], ";".join( [Path(k).basename() for k in keys]))