Skip to content

Commit

Permalink
Add Python-Protobuf generator
Browse files Browse the repository at this point in the history
We add a generator for a library which allows conversion from model
instance to and from corresponding Protocol Buffers.
  • Loading branch information
mristin committed Nov 3, 2024
1 parent 39a2259 commit 1f16585
Show file tree
Hide file tree
Showing 37 changed files with 14,503 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Call the generator with the appropriate target:
usage: aas-core-codegen [-h] --model_path MODEL_PATH --snippets_dir
SNIPPETS_DIR --output_dir OUTPUT_DIR --target
{csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf}
{csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf,python_protobuf}
[--version]
Generate implementations and schemas based on an AAS meta-model.
Expand All @@ -153,7 +153,7 @@ Call the generator with the appropriate target:
specific code snippets
--output_dir OUTPUT_DIR
path to the generated code
--target {csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf}
--target {csharp,cpp,golang,java,jsonschema,python,typescript,rdf_shacl,xsd,jsonld_context,protobuf,python_protobuf}
target language or schema
--version show the current version and exit
Expand Down
5 changes: 5 additions & 0 deletions aas_core_codegen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import aas_core_codegen.xsd.main as xsd_main
import aas_core_codegen.jsonld.main as jsonld_main
import aas_core_codegen.protobuf.main as protobuf_main
import aas_core_codegen.python_protobuf.main as python_protobuf_main
from aas_core_codegen import run, specific_implementations
from aas_core_codegen.common import LinenoColumner, assert_never

Expand All @@ -38,6 +39,7 @@ class Target(enum.Enum):
XSD = "xsd"
JSONLD_CONTEXT = "jsonld_context"
PROTOBUF = "protobuf"
PYTHON_PROTOBUF = "python_protobuf"


class Parameters:
Expand Down Expand Up @@ -169,6 +171,9 @@ def execute(params: Parameters, stdout: TextIO, stderr: TextIO) -> int:
elif params.target is Target.PROTOBUF:
return protobuf_main.execute(run_context, stdout=stdout, stderr=stderr)

elif params.target is Target.PYTHON_PROTOBUF:
return python_protobuf_main.execute(run_context, stdout=stdout, stderr=stderr)

else:
assert_never(params.target)

Expand Down
1 change: 1 addition & 0 deletions aas_core_codegen/python_protobuf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Generate the code for conversion from and to Protocol Buffers."""
Loading

0 comments on commit 1f16585

Please sign in to comment.