aea.protocols.generator.common
This module contains utility code for generator modules.
is_
installed
Check whether a programme is installed on the system.
Arguments:
programme
: the name of the programme.
Returns:
True if installed, False otherwise
base_
protolint_
command
Return the base protolint command.
Returns:
The base protolint command
check_
prerequisites
Check whether a programme is installed on the system.
get_
protoc_
version
Get the protoc version used.
load_
protocol_
specification
Load a protocol specification.
Arguments:
specification_path
: path to the protocol specification yaml file.
Returns:
A ProtocolSpecification object
try_
run_
black_
formatting
Run Black code formatting via subprocess.
Arguments:
path_to_protocol_package
: a path where formatting should be applied.
try_
run_
isort_
formatting
Run Isort code formatting via subprocess.
Arguments:
path_to_protocol_package
: a path where formatting should be applied.
try_
run_
protoc
try_run_protoc(path_to_generated_protocol_package: str, name: str, language: str = PROTOCOL_LANGUAGE_PYTHON) -> None
Run 'protoc' protocol buffer compiler via subprocess.
Arguments:
path_to_generated_protocol_package
: path to the protocol buffer schema file.name
: name of the protocol buffer schema file.language
: the target language in which to compile the protobuf schema file
try_
run_
protolint
Run 'protolint' linter via subprocess.
Arguments:
path_to_generated_protocol_package
: path to the protocol buffer schema file.name
: name of the protocol buffer schema file.
check_
protobuf_
using_
protoc
Check whether a protocol buffer schema file is valid.
Validation is via trying to compile the schema file. If successfully compiled it is valid, otherwise invalid. If valid, return True and a 'protobuf file is valid' message, otherwise return False and the error thrown by the compiler.
Arguments:
path_to_generated_protocol_package
: path to the protocol buffer schema file.name
: name of the protocol buffer schema file.
Returns:
Boolean result and an accompanying message
compile_
protobuf_
using_
protoc
compile_protobuf_using_protoc(path_to_generated_protocol_package: str, name: str, language: str) -> Tuple[bool, str]
Compile a protocol buffer schema file using protoc.
If successfully compiled, return True and a success message, otherwise return False and the error thrown by the compiler.
Arguments:
path_to_generated_protocol_package
: path to the protocol buffer schema file.name
: name of the protocol buffer schema file.language
: the target language in which to compile the protobuf schema file
Returns:
Boolean result and an accompanying message
apply_
protolint
Apply protolint linter to a protocol buffer schema file.
If no output, return True and a success message, otherwise return False and the output shown by the linter (minus the indentation suggestions which are automatically fixed by protolint).
Arguments:
path_to_proto_file
: path to the protocol buffer schema file.name
: name of the protocol buffer schema file.
Returns:
Boolean result and an accompanying message