Exemplo n.º 1
0
        if key in context.PullRequest.ATTRIBUTES:
            return None
        elif key in context.PullRequest.LIST_ATTRIBUTES:
            return []
        else:
            raise context.PullRequestAttributeError(key)

    @staticmethod
    def _ensure_complete():
        pass


_DUMMY_PR = context.PullRequest(
    DummyContext(
        None,  # type: ignore
        {"number": 0},
        None,  # type: ignore
        [],
    ))


def Jinja2(value, extra_variables=None):
    """A Jinja2 type for voluptuous Schemas."""
    if value is None:
        raise voluptuous.Invalid("Template cannot be null")
    try:
        # TODO: optimize this by returning, storing and using the parsed Jinja2 AST
        _DUMMY_PR.render_template(value, extra_variables)
    except context.RenderTemplateFailure as rtf:
        if rtf.lineno is None:
            path = None
Exemplo n.º 2
0
    def _get_consolidated_data(key):
        if key in context.PullRequest.ATTRIBUTES:
            return None
        elif key in context.PullRequest.LIST_ATTRIBUTES:
            return []
        else:
            raise context.PullRequestAttributeError(key)

    @staticmethod
    def _ensure_complete():
        pass


_DUMMY_PR = context.PullRequest(DummyContext(
    None,
    {},
    {},
    [],
))


def Jinja2(value):
    """A Jinja2 type for voluptuous Schemas."""
    if value is None:
        raise voluptuous.Invalid("Template cannot be null")
    try:
        # TODO: optimize this by returning, storing and using the parsed Jinja2 AST
        _DUMMY_PR.render_template(value)
    except context.RenderTemplateFailure as rtf:
        if rtf.lineno is None:
            path = None
        else:
Exemplo n.º 3
0
_DUMMY_PR = context.PullRequest(
    DummyContext(
        None,  # type: ignore
        github_types.GitHubPullRequest(
            {
                "number": github_types.GitHubPullRequestNumber(
                    github_types.GitHubIssueNumber(0)
                ),
                "html_url": "",
                "id": github_types.GitHubPullRequestId(github_types.GitHubIssueId(0)),
                "maintainer_can_modify": False,
                "state": "open",
                "merged": False,
                "merged_by": None,
                "merged_at": None,
                "draft": False,
                "merge_commit_sha": None,
                "mergeable_state": "unknown",
                "rebaseable": False,
                "user": {
                    "id": github_types.GitHubAccountIdType(0),
                    "login": github_types.GitHubLogin(""),
                    "type": "User",
                },
                "labels": [],
                "base": {
                    "user": {
                        "id": github_types.GitHubAccountIdType(0),
                        "login": github_types.GitHubLogin(""),
                        "type": "User",
                    },
                    "label": "",
                    "ref": github_types.GitHubRefType(""),
                    "sha": github_types.SHAType(""),
                    "repo": {
                        "url": "",
                        "default_branch": github_types.GitHubRefType(""),
                        "full_name": "",
                        "archived": False,
                        "id": github_types.GitHubRepositoryIdType(0),
                        "private": False,
                        "name": "",
                        "owner": {
                            "login": github_types.GitHubLogin(""),
                            "id": github_types.GitHubAccountIdType(0),
                            "type": "User",
                        },
                    },
                },
                "head": {
                    "user": {
                        "id": github_types.GitHubAccountIdType(0),
                        "login": github_types.GitHubLogin(""),
                        "type": "User",
                    },
                    "label": "",
                    "ref": github_types.GitHubRefType(""),
                    "sha": github_types.SHAType(""),
                    "repo": {
                        "url": "",
                        "default_branch": github_types.GitHubRefType(""),
                        "full_name": "",
                        "archived": False,
                        "id": github_types.GitHubRepositoryIdType(0),
                        "private": False,
                        "name": "",
                        "owner": {
                            "login": github_types.GitHubLogin(""),
                            "id": github_types.GitHubAccountIdType(0),
                            "type": "User",
                        },
                    },
                },
            }
        ),
        None,  # type: ignore
        [],
    )
)