def from_splitconf(repo): repo_acl = {} split_conf_path = os.path.join(repo.repo_path, 'gl-conf') split_conf_mtime = os.path.getmtime(split_conf_path) split_conf_cache_key = '%s-%s' % (repo.repo_path, split_conf_mtime) repo_conf = acl_cache.get(split_conf_cache_key) if repo_conf: logging.info("Using cached acl for %s (mtime %s)" % (repo, split_conf_mtime)) else: logging.info("Reading split config from %s" % split_conf_path) repo_conf = DataDumperReader().read(split_conf_path) acl_cache.set(split_conf_cache_key, repo_conf) if 'one_repo' in repo_conf: one_repo = repo_conf['one_repo'] assert len(one_repo) == 1, \ "Expected a single repository in one_repo of %s; got %s" % (repo, len(repo_conf)) for user_or_group, ug_acl in one_repo[one_repo.keys()[0]].items(): l = repo_acl.get(user_or_group, []) l.extend([tuple(y) for y in ug_acl]) repo_acl[user_or_group] = l return GitoliteACLDefinition(repo_acl)
def bigconf(self): if not self._bigconf: big_conf_mtime = os.path.getmtime(self.big_conf_path) bc_cache_key = "gl-bigconf-%s" % big_conf_mtime self._bigconf = acl_cache.get(bc_cache_key) if not self._bigconf: self._bigconf = DataDumperReader().read(self.big_conf_path) acl_cache.set(bc_cache_key, self._bigconf) return self._bigconf