def setSvnRepositoryTree(self, databaseSession, repositoryUrl, sourceSvnRepositoryTree): from svnrepositorytree import SvnRepositoryTree destinationSvnRepositoryTree = self.svnRepositoryTree if destinationSvnRepositoryTree is None: destinationSvnRepositoryTree = SvnRepositoryTree() destinationSvnRepositoryTree.copy(sourceSvnRepositoryTree) destinationSvnRepositoryTree.setRepositoryUrl(databaseSession, repositoryUrl) self.setType(databaseSession, "svn") if self.svnRepositoryTree is None: self.svnRepositoryTree = destinationSvnRepositoryTree databaseSession.add(self.svnRepositoryTree)
def validateFormFieldsDictionary(cls, dictionary): from svnrepositorytree import SvnRepositoryTree from gitrepositorytree import GitRepositoryTree type = dictionary.get("type", "") if type == "none": return True, None elif type == "svn": return SvnRepositoryTree.validateFormFieldsDictionary(dictionary) elif type == "git": return GitRepositoryTree.validateFormFieldsDictionary(dictionary) elif type == "raw": return RawDirectoryTree.validateFormFieldsDictionary(dictionary) else: return False, { "field": "type", "message": "You must provide a valid directory tree type." }
def fromFormFieldsDictionary(self, databaseSession, dictionary): from svnrepositorytree import SvnRepositoryTree from gitrepositorytree import GitRepositoryTree if dictionary["type"] == "none": self.setNone(databaseSession) elif dictionary["type"] == "svn": repositoryUrl = dictionary["url"] svnRepositoryTree = SvnRepositoryTree() svnRepositoryTree.fromFormFieldsDictionary(databaseSession, dictionary) self.setSvnRepositoryTree(databaseSession, repositoryUrl, svnRepositoryTree) elif dictionary["type"] == "git": repositoryUrl = dictionary["url"] gitRepositoryTree = GitRepositoryTree() gitRepositoryTree.fromFormFieldsDictionary(databaseSession, dictionary) self.setGitRepositoryTree(databaseSession, repositoryUrl, gitRepositoryTree) elif dictionary["type"] == "raw": raise NotImplementedError() else: raise ValueError() return self