def lookupRepositoryByPath(user,path): """ If a repository with this path exists, return that repository. Otherwise, return None. """ for _,repository in user.getRegistry().getRepositories().items(): if repository.isLocal() and path == repository.getRepoPath(): return repository return None
def lookupRepositoryByPath(user, path): """ If a repository with this path exists, return that repository. Otherwise, return None. """ for _, repository in user.getRegistry().getRepositories().items(): if repository.isLocal() and path == repository.getRepoPath(): return repository return None
def save(self): """ Save attributes of the repositories to disk. Note: This is done automatically for you when you ``commit()`` the registry. """ userRepositoryListDict = {} for name,repository in self.userRepositories.items(): userRepositoryListDict[name] = {} if repository.getGitOriginURI(): userRepositoryListDict[name]["git-origin"] = repository.getGitOriginURI() else: userRepositoryListDict[name]["source-dir"] = repository.getRepoPath() userRepositoryListDict[name]["temporary"] = repository.isTemporary() with open(self.userRepositoryListPath, 'w') as file_f: json.dump(userRepositoryListDict, file_f, indent=1, separators=(',', ': ')) repositoryStatesDotJsonPath = os.path.join(self.getUser().getConfig()["registry-dir"],"repository-states.json") repositoryStates = {} for repoName,repository in self.items(): repositoryStates[repoName] = {} repositoryStates[repoName]["git-commit-hash"] = repository.getGitCommitHash() with open(repositoryStatesDotJsonPath,mode="w") as repositoryStatesDotJsonFile: json.dump(repositoryStates,repositoryStatesDotJsonFile, indent=1, separators=(',', ': '))
def save(self): """ Save attributes of the repositories to disk. Note: This is done automatically for you when you ``commit()`` the registry. """ userRepositoryListDict = {} for name, repository in self.userRepositories.items(): userRepositoryListDict[name] = {} if repository.getGitOriginURI(): userRepositoryListDict[name][ "git-origin"] = repository.getGitOriginURI() else: userRepositoryListDict[name][ "source-dir"] = repository.getRepoPath() userRepositoryListDict[name]["temporary"] = repository.isTemporary( ) with open(self.userRepositoryListPath, 'w') as file_f: json.dump(userRepositoryListDict, file_f, indent=1, separators=(',', ': ')) repositoryStatesDotJsonPath = os.path.join( self.getUser().getConfig()["registry-dir"], "repository-states.json") repositoryStates = {} for repoName, repository in self.items(): repositoryStates[repoName] = {} repositoryStates[repoName][ "git-commit-hash"] = repository.getGitCommitHash() with open(repositoryStatesDotJsonPath, mode="w") as repositoryStatesDotJsonFile: json.dump(repositoryStates, repositoryStatesDotJsonFile, indent=1, separators=(',', ': '))