コード例 #1
0
ファイル: versioning.py プロジェクト: turboza/quark
def compiler_version_spec_messages(file_nodes):
    for file in file_nodes:
        assert isinstance(file, ast.File)
        compiler_version_spec_nodes = [
            node for node in file.children
            if isinstance(node, ast.CompilerVersionSpec)
        ]
        if compiler_version_spec_nodes == []:
            yield Warning(
                messages.version_spec_missing(
                    location=lineinfo(file),
                    compiler_version=COMPILER_VERSION,
                ))
        if len(compiler_version_spec_nodes) >= 2:
            yield Error(
                messages.too_many_version_specs(
                    first_location=lineinfo(compiler_version_spec_nodes[0]),
                    second_location=lineinfo(compiler_version_spec_nodes[1]),
                ))
        for node in compiler_version_spec_nodes:
            if not node.strict:
                yield Error(
                    messages.version_spec_malformed(
                        location=lineinfo(node),
                        compiler_version=COMPILER_VERSION,
                    ))
            errors = version_spec_string_messages(
                spec_string=node.spec_string,
                location=lineinfo(node),
            )
            for error in errors:
                yield error
コード例 #2
0
ファイル: versioning.py プロジェクト: datawire/quark
def compiler_version_spec_messages(file_nodes):
    for file in file_nodes:
        assert isinstance(file, ast.File)
        compiler_version_spec_nodes = [
            node for node in file.children
            if isinstance(node, ast.CompilerVersionSpec)
        ]
        if compiler_version_spec_nodes == []:
            yield Warning(messages.version_spec_missing(
                location=lineinfo(file),
                compiler_version=COMPILER_VERSION,
            ))
        if len(compiler_version_spec_nodes) >= 2:
            yield Error(messages.too_many_version_specs(
                first_location=lineinfo(compiler_version_spec_nodes[0]),
                second_location=lineinfo(compiler_version_spec_nodes[1]),
            ))
        for node in compiler_version_spec_nodes:
            if not node.strict:
                yield Error(messages.version_spec_malformed(
                    location=lineinfo(node),
                    compiler_version=COMPILER_VERSION,
                ))
            errors = version_spec_string_messages(
                spec_string=node.spec_string,
                location=lineinfo(node),
            )
            for error in errors:
                yield error
コード例 #3
0
ファイル: versioning.py プロジェクト: datawire/quark
def version_spec_string_messages(spec_string, location):
    version = Version.parse(spec_string)

    if version is Version.Invalid:
        yield Error(messages.version_spec_malformed(
            location=location,
            compiler_version=COMPILER_VERSION,
        ))
    else:
        if not version.is_compatible_with(COMPILER_VERSION):
            yield Error(messages.compiler_version_incompatible_with_source(
                location=location,
                compiler_version=COMPILER_VERSION,
                source_version_spec=spec_string,
            ))
コード例 #4
0
ファイル: versioning.py プロジェクト: turboza/quark
def version_spec_string_messages(spec_string, location):
    version = Version.parse(spec_string)

    if version is Version.Invalid:
        yield Error(
            messages.version_spec_malformed(
                location=location,
                compiler_version=COMPILER_VERSION,
            ))
    else:
        if not version.is_compatible_with(COMPILER_VERSION):
            yield Error(
                messages.compiler_version_incompatible_with_source(
                    location=location,
                    compiler_version=COMPILER_VERSION,
                    source_version_spec=spec_string,
                ))