Ejemplo n.º 1
0
 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 = {}
Ejemplo n.º 2
0
    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()]
Ejemplo n.º 3
0
 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]))