コード例 #1
0
ファイル: ext.py プロジェクト: Capitains/Hook
    def f_slugify(string):
        """ Slugify filter

        :return: Slugified string
        """
        if not string:
            return ""
        return slugify(string)
コード例 #2
0
ファイル: models.py プロジェクト: Capitains/Hook
        def Get_or_Create(uuid, repository, branch=None, slug=None, **kwargs):
            """ Find said RepoTest is not found, create an instance for it

            :param repository: Repository for which the test has been performed
            :type repository: Repository
            :param branch: Branch's name
            :type branch: str
            :param uuid: Id representing the test
            :type uuid: str
            :param save: If set to True, if the object does not exist, save it
            :type save: boolean

            :returns: A Repository logs
            :rtype: RepoTest

            """

            if slug is not None:
                repo_test = RepoTest.objects(
                    uuid__iexact=uuid,
                    repository=repository,
                    branch_slug__iexact=slug
                )
            else:
                slug = slugify(branch)
                repo_test = RepoTest.objects(
                    uuid__iexact=uuid,
                    repository=repository,
                    branch__iexact=branch,
                    branch_slug=slug
                )
            if len(repo_test) == 0:
                repo_test = RepoTest(
                    uuid=uuid,
                    repository=repository,
                    branch=branch,
                    branch_slug=slug,
                    scheme=repository.dtd,
                    verbose=repository.verbose,
                    **kwargs
                )
                repo_test.save()
            else:
                repo_test = repo_test.first()
            return repo_test