def set_cache(self, url):
up = urlparse(formaturl(url, 'https'))
if self.cache and up and up.netloc and os.path.isdir(self.path):
try:
cpath = os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))
if not os.path.isdir(cpath):
os.makedirs(cpath)
scm_dir = '.'+self.scm.name
if os.path.isdir(os.path.join(cpath, scm_dir)):
rmtree_readonly(os.path.join(cpath, scm_dir))
shutil.copytree(os.path.join(self.path, scm_dir), os.path.join(cpath, scm_dir))
except Exception:
warning("Unable to cache \"%s\" to \"%s\"" % (self.path, cpath))
return False
评论列表
文章目录