def validate_quad(self, zone, host, path, key): if not self.validname(path) or \ '/' in key or '/' in zone or '/' in host or \ not utils.good_path_elem(host) or \ not utils.good_path_elem(zone) or \ not utils.good_path_elem(key): raise derrors.CacheKeyErr("bad zone / host / path / key in cachestore: '%s' '%s' '%s' '%s'" % (zone, host, path, key))
def validate_quad(self, zone, host, path, key): if not self.validname(path) or \ '/' in key or '/' in zone or '/' in host or \ not utils.good_path_elem(host) or \ not utils.good_path_elem(zone) or \ not utils.good_path_elem(key): raise derrors.CacheKeyErr( "bad zone / host / path / key in cachestore: '%s' '%s' '%s' '%s'" % (zone, host, path, key))
def children(self, path): if not utils.goodpath(path): # With an iterator, this yields de nada return if path == '': spath = self.root else: spath = join2(self.root, path) pdirs = [spath,] rlen = len(self.root)+1 while pdirs: wd = pdirs.pop() try: names = os.listdir(wd) except EnvironmentError: continue for name in names: if not utils.good_path_elem(name): continue cn = join2(wd, name) st = os.lstat(cn) self.stcache[cn] = st if stat.S_ISDIR(st.st_mode): pdirs.append(cn) elif stat.S_ISREG(st.st_mode): cn = cn[rlen:] # cn is guaranteed to be non-null. # we can only get here if it's a # regular file, and if it's a # regular file it must be inside # the root, which is a directory. yield (st.st_mtime, cn)
def children(self, path): if not utils.goodpath(path): # With an iterator, this yields de nada return if path == '': spath = self.root else: spath = join2(self.root, path) pdirs = [ spath, ] rlen = len(self.root) + 1 while pdirs: wd = pdirs.pop() try: names = os.listdir(wd) except EnvironmentError: continue for name in names: if not utils.good_path_elem(name): continue cn = join2(wd, name) st = os.lstat(cn) self.stcache[cn] = st if stat.S_ISDIR(st.st_mode): pdirs.append(cn) elif stat.S_ISREG(st.st_mode): cn = cn[rlen:] # cn is guaranteed to be non-null. # we can only get here if it's a # regular file, and if it's a # regular file it must be inside # the root, which is a directory. yield (st.st_mtime, cn)
def fill(self): if self._state != None: return try: self.fstore = [x for x in os.listdir(self.name) if utils.good_path_elem(x)] self.fstore.sort() self._state = sGood except EnvironmentError: self._state = sBad
def fill(self): if self._state != None: return try: self.fstore = [ x for x in os.listdir(self.name) if utils.good_path_elem(x) ] self.fstore.sort() self._state = sGood except EnvironmentError: self._state = sBad