stinger-ipc 0.0.2__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/METADATA +2 -2
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/RECORD +24 -19
- stingeripc/components.py +20 -14
- stingeripc/lang_symb.py +35 -1
- stingeripc/templates/cpp/examples/client_main.cpp.jinja2 +2 -2
- stingeripc/templates/cpp/examples/server_main.cpp.jinja2 +5 -5
- stingeripc/templates/cpp/include/broker.hpp.jinja2 +7 -0
- stingeripc/templates/cpp/include/client.hpp.jinja2 +12 -4
- stingeripc/templates/cpp/include/ibrokerconnection.hpp.jinja2 +7 -0
- stingeripc/templates/cpp/include/property_structs.hpp.jinja2 +10 -0
- stingeripc/templates/cpp/include/return_types.hpp.jinja2 +8 -1
- stingeripc/templates/cpp/include/server.hpp.jinja2 +11 -4
- stingeripc/templates/cpp/include/structs.hpp.jinja2 +7 -1
- stingeripc/templates/cpp/src/client.cpp.jinja2 +15 -10
- stingeripc/templates/cpp/src/server.cpp.jinja2 +12 -12
- stingeripc/templates/markdown/index.md.jinja2 +74 -1
- stingeripc/tools/__init__.py +0 -0
- stingeripc/tools/markdown_generator.py +25 -0
- stingeripc/tools/python_generator.py +39 -0
- stingeripc/tools/rust_generator.py +50 -0
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/WHEEL +0 -0
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/entry_points.txt +0 -0
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/licenses/LICENSE +0 -0
- {stinger_ipc-0.0.2.dist-info → stinger_ipc-0.0.4.dist-info}/top_level.txt +0 -0
@@ -1,27 +1,28 @@
|
|
1
|
-
stinger_ipc-0.0.
|
1
|
+
stinger_ipc-0.0.4.dist-info/licenses/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
2
2
|
stingeripc/__init__.py,sha256=PTr5WfMfB-GL4vp3-XMU8IwGv3Q5RXQ24H7JuEo3hdk,133
|
3
3
|
stingeripc/args.py,sha256=x3P8GRu9-jyiMl62t0FPqbWY18FbhMVN4eSa2UzUv6c,3960
|
4
4
|
stingeripc/asyncapi.py,sha256=DJZuz_LiQEJjQGlnfRtgOToWVD55uLw5ZoiZ95-bxZc,23291
|
5
|
-
stingeripc/components.py,sha256=
|
5
|
+
stingeripc/components.py,sha256=WtIfhKAm9ZglCZiW-k98vAUC1Y5j3BJtcNRdMgr44zQ,38536
|
6
6
|
stingeripc/connection.py,sha256=DfBG9LKaEuGacmX5NPphDabJqJmO3tVUg8Oa-efCd7w,184
|
7
7
|
stingeripc/exceptions.py,sha256=nX5Xl4KjPTfSRTVZIB9NkgM0g_6auXgr5fTyunCZy5Q,51
|
8
8
|
stingeripc/interface.py,sha256=ypt4T7hTH7ePKLy3JCl1b1ggyH5T38m68Gt0m_5VOBM,1558
|
9
|
-
stingeripc/lang_symb.py,sha256=
|
9
|
+
stingeripc/lang_symb.py,sha256=STcGEQQd72RK4J9UZr_vQgjVqf7dR9UZ2f9qicxjxGo,2736
|
10
10
|
stingeripc/topic.py,sha256=mIL6Abf3fcI0yeSGj_o9ulV6xFNIfyfwGZ5joEVXyzE,2404
|
11
11
|
stingeripc/templates/cpp/CMakeLists.txt.jinja2,sha256=jXlF2GOAt1mBsm6JqPZGaRr53NV5oJsfTd6nedeJ-GA,945
|
12
|
-
stingeripc/templates/cpp/examples/client_main.cpp.jinja2,sha256=
|
13
|
-
stingeripc/templates/cpp/examples/server_main.cpp.jinja2,sha256
|
14
|
-
stingeripc/templates/cpp/include/broker.hpp.jinja2,sha256=
|
15
|
-
stingeripc/templates/cpp/include/client.hpp.jinja2,sha256=
|
12
|
+
stingeripc/templates/cpp/examples/client_main.cpp.jinja2,sha256=llUcuT4_R4SA5Nhpg6pRjs8nMogD5M21n6_aaewTJwE,2630
|
13
|
+
stingeripc/templates/cpp/examples/server_main.cpp.jinja2,sha256=AvkkZX_jbB3xYL7W04ZKna_rE4fL8l1PN8b5pq9WrCU,1523
|
14
|
+
stingeripc/templates/cpp/include/broker.hpp.jinja2,sha256=5VQ2k3EXavBlXjBfSykjH0YqhwTA_upDcVz_aIptwho,5569
|
15
|
+
stingeripc/templates/cpp/include/client.hpp.jinja2,sha256=ap5gCYpTicYHRa0a97Ta9X836UxHNwErE0jM5H4Nmjg,2714
|
16
16
|
stingeripc/templates/cpp/include/enums.hpp.jinja2,sha256=psTnV1KXr72RfL4ufdtX8BO0Ub_CJm9Uj5h8UUM_-uI,598
|
17
|
-
stingeripc/templates/cpp/include/ibrokerconnection.hpp.jinja2,sha256=
|
18
|
-
stingeripc/templates/cpp/include/
|
19
|
-
stingeripc/templates/cpp/include/
|
20
|
-
stingeripc/templates/cpp/include/
|
17
|
+
stingeripc/templates/cpp/include/ibrokerconnection.hpp.jinja2,sha256=KH73Jk6FqZ4MovN2bKSzgjKN-tufm3AxGsFRkT9USc4,1829
|
18
|
+
stingeripc/templates/cpp/include/property_structs.hpp.jinja2,sha256=ndEUE-1A5l0aMFvd8n1R_3_eCMYLh1FosEFMh2LKbao,263
|
19
|
+
stingeripc/templates/cpp/include/return_types.hpp.jinja2,sha256=qFBkvNG0m4XT7sCVCjuE0cDoROp5Fq4XXiWUt6DwEho,528
|
20
|
+
stingeripc/templates/cpp/include/server.hpp.jinja2,sha256=LSLf-Og2R1atstOSOJFuiOzBCEqFfXorJbC1IT1TZNY,2033
|
21
|
+
stingeripc/templates/cpp/include/structs.hpp.jinja2,sha256=DJAAq07DWJmYAEI9An5yxD2YHbA0Vwv11xR5MgcQdmM,507
|
21
22
|
stingeripc/templates/cpp/src/broker.cpp.jinja2,sha256=32bfKFJIzHe8w4JKZKjJ-wv8vVrYtOULyRK8f2lF1ow,9345
|
22
|
-
stingeripc/templates/cpp/src/client.cpp.jinja2,sha256=
|
23
|
-
stingeripc/templates/cpp/src/server.cpp.jinja2,sha256=
|
24
|
-
stingeripc/templates/markdown/index.md.jinja2,sha256=
|
23
|
+
stingeripc/templates/cpp/src/client.cpp.jinja2,sha256=lfIbb-Usnru44-5EmrAGzjFiLqkoiSt-9VYkIrugXSI,9010
|
24
|
+
stingeripc/templates/cpp/src/server.cpp.jinja2,sha256=hs27uqLCwYR_1cvhwZwGiXTpEnsoBiGlMJE0pbY5cPg,7765
|
25
|
+
stingeripc/templates/markdown/index.md.jinja2,sha256=yB1Jpawc1VdBAzmnCI0ikdvVlcjZXf-2xRs159XSnHg,6432
|
25
26
|
stingeripc/templates/python/__init__.py.jinja2,sha256=jdZ07ogzJLOgzqqkHjj2_8hld9uBDnvB1DXPXnWkt98,22
|
26
27
|
stingeripc/templates/python/client.py.jinja2,sha256=lUlnh-Z2ulDaomx-bR7RAgovmZ4QYLjck0c_885x8DY,16461
|
27
28
|
stingeripc/templates/python/connection.py.jinja2,sha256=-ftw5lHa2ab_hfQLhVuFK5HTY5cdetk4YeDjI-KvUe0,7159
|
@@ -41,8 +42,12 @@ stingeripc/templates/rust/connection/src/payloads.rs.jinja2,sha256=rlQgHeiCYGU8y
|
|
41
42
|
stingeripc/templates/rust/server/Cargo.toml.jinja2,sha256=eyMM4xmZP-9mlDJMQ5zrFR1dWWmoldMac6h_aFKtPQs,476
|
42
43
|
stingeripc/templates/rust/server/examples/server.rs.jinja2,sha256=6XrMXUrcr9c0_m5u02kQzM88UHngVcUQCqL5uChefS8,3682
|
43
44
|
stingeripc/templates/rust/server/src/lib.rs.jinja2,sha256=CFIrHI9LkZ2P1vX-YOOa0TwVVzqnVo59RnDAIXYV5Iw,13580
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
stinger_ipc-0.0.
|
45
|
+
stingeripc/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
46
|
+
stingeripc/tools/markdown_generator.py,sha256=C-Xjz1B8HSXiScj-f9aDYkvXG7TueRz5Ft9sL4P85k8,631
|
47
|
+
stingeripc/tools/python_generator.py,sha256=hdmowp4xquoy9QGVkAsnYMfs30pnjVAf7O_v7BnM2Bc,1232
|
48
|
+
stingeripc/tools/rust_generator.py,sha256=cjl7kbTT92FXpZlZdlq_R3F7lPxcMMOxGQjP9wH1nvo,1824
|
49
|
+
stinger_ipc-0.0.4.dist-info/METADATA,sha256=5J-i0dZQdoL1dLyJBW2TtFt4-1VjVSLpaU01iDTv7bg,6008
|
50
|
+
stinger_ipc-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
51
|
+
stinger_ipc-0.0.4.dist-info/entry_points.txt,sha256=OP6HFi6z11HE_zxLsy9kPnoq8C2anF--_NiHMsMcazY,171
|
52
|
+
stinger_ipc-0.0.4.dist-info/top_level.txt,sha256=mSNwAf83_1qiTP_vu7XEPBrZu-fDusT1FFyQZzCrRcU,11
|
53
|
+
stinger_ipc-0.0.4.dist-info/RECORD,,
|
stingeripc/components.py
CHANGED
@@ -3,7 +3,7 @@ from enum import Enum
|
|
3
3
|
import random
|
4
4
|
import stringcase
|
5
5
|
from abc import abstractmethod
|
6
|
-
from typing import
|
6
|
+
from typing import Any
|
7
7
|
from .topic import (
|
8
8
|
SignalTopicCreator,
|
9
9
|
InterfaceTopicCreator,
|
@@ -387,7 +387,7 @@ class Signal(InterfaceComponent):
|
|
387
387
|
def __init__(self, topic_creator: SignalTopicCreator, name: str):
|
388
388
|
super().__init__(name)
|
389
389
|
self._topic_creator = topic_creator
|
390
|
-
self._arg_list
|
390
|
+
self._arg_list: list[Arg] = []
|
391
391
|
|
392
392
|
def add_arg(self, arg: Arg) -> Signal:
|
393
393
|
if arg.name in [a.name for a in self._arg_list]:
|
@@ -408,7 +408,7 @@ class Signal(InterfaceComponent):
|
|
408
408
|
cls,
|
409
409
|
topic_creator: SignalTopicCreator,
|
410
410
|
name: str,
|
411
|
-
signal_spec:
|
411
|
+
signal_spec: dict[str, str],
|
412
412
|
stinger_spec: StingerSpec | None = None,
|
413
413
|
) -> "Signal":
|
414
414
|
"""Alternative constructor from a Stinger signal structure."""
|
@@ -437,7 +437,7 @@ class Method(InterfaceComponent):
|
|
437
437
|
super().__init__(name)
|
438
438
|
self._python = PythonMethodSymbols(self)
|
439
439
|
self._topic_creator = topic_creator
|
440
|
-
self._arg_list
|
440
|
+
self._arg_list: list[Arg] = []
|
441
441
|
self._return_value: Arg | list[Arg] | None = None
|
442
442
|
|
443
443
|
@property
|
@@ -482,7 +482,7 @@ class Method(InterfaceComponent):
|
|
482
482
|
@property
|
483
483
|
def return_value_cpp_class(self) -> str:
|
484
484
|
if self._return_value is None:
|
485
|
-
return "
|
485
|
+
return "void"
|
486
486
|
elif isinstance(self._return_value, Arg):
|
487
487
|
return self._return_value.cpp_type
|
488
488
|
elif isinstance(self._return_value, list):
|
@@ -572,7 +572,7 @@ class Method(InterfaceComponent):
|
|
572
572
|
cls,
|
573
573
|
topic_creator: MethodTopicCreator,
|
574
574
|
name: str,
|
575
|
-
method_spec:
|
575
|
+
method_spec: dict[str, str],
|
576
576
|
stinger_spec: StingerSpec | None = None,
|
577
577
|
) -> "Method":
|
578
578
|
"""Alternative constructor from a Stinger method structure."""
|
@@ -614,7 +614,7 @@ class Property(InterfaceComponent):
|
|
614
614
|
def __init__(self, topic_creator: PropertyTopicCreator, name: str):
|
615
615
|
super().__init__(name)
|
616
616
|
self._topic_creator = topic_creator
|
617
|
-
self._arg_list
|
617
|
+
self._arg_list: list[Arg] = []
|
618
618
|
self._read_only = False
|
619
619
|
|
620
620
|
def add_arg(self, arg: Arg) -> Property:
|
@@ -829,7 +829,7 @@ class InterfaceStruct:
|
|
829
829
|
def new_struct_from_stinger(
|
830
830
|
cls,
|
831
831
|
name,
|
832
|
-
spec:
|
832
|
+
spec: dict[str, str | list[dict[str, str]]],
|
833
833
|
stinger_spec: StingerSpec,
|
834
834
|
) -> InterfaceStruct:
|
835
835
|
istruct = cls(name)
|
@@ -884,7 +884,7 @@ class Broker:
|
|
884
884
|
self._port = port
|
885
885
|
|
886
886
|
@classmethod
|
887
|
-
def new_broker_from_stinger(cls, name: str, spec:
|
887
|
+
def new_broker_from_stinger(cls, name: str, spec: dict[str, Any]) -> Broker:
|
888
888
|
new_broker = cls(name=name)
|
889
889
|
if "host" in spec:
|
890
890
|
new_broker.hostname = spec["host"]
|
@@ -897,13 +897,14 @@ class Broker:
|
|
897
897
|
|
898
898
|
|
899
899
|
class StingerSpec:
|
900
|
-
def __init__(self, topic_creator: InterfaceTopicCreator, interface):
|
900
|
+
def __init__(self, topic_creator: InterfaceTopicCreator, interface: dict[str, Any]):
|
901
901
|
self._topic_creator = topic_creator
|
902
902
|
try:
|
903
903
|
self._name: str = interface["name"]
|
904
904
|
self._version: str = interface["version"]
|
905
905
|
self._python = PythonInterfaceSymbols(self)
|
906
906
|
self._rust = RustInterfaceSymbols(self)
|
907
|
+
self._cpp = CppInterfaceSymbols(self)
|
907
908
|
except KeyError as e:
|
908
909
|
raise InvalidStingerStructure(
|
909
910
|
f"Missing interface property in {interface}: {e}"
|
@@ -913,8 +914,9 @@ class StingerSpec:
|
|
913
914
|
f"Interface didn't appear to have a correct type"
|
914
915
|
)
|
915
916
|
|
916
|
-
self._summary = interface
|
917
|
-
self._title = interface
|
917
|
+
self._summary = interface.get("summary")
|
918
|
+
self._title = interface.get("title")
|
919
|
+
self._documentation = interface.get("documentation")
|
918
920
|
|
919
921
|
self.signals: dict[str, Signal] = {}
|
920
922
|
self.properties: dict[str, Property] = {}
|
@@ -951,7 +953,7 @@ class StingerSpec:
|
|
951
953
|
self._brokers[broker.name] = broker
|
952
954
|
|
953
955
|
@property
|
954
|
-
def brokers(self) ->
|
956
|
+
def brokers(self) -> dict[str, Broker]:
|
955
957
|
if len(self._brokers) == 0:
|
956
958
|
default_broker = Broker()
|
957
959
|
return {default_broker.name: default_broker}
|
@@ -1007,6 +1009,10 @@ class StingerSpec:
|
|
1007
1009
|
def rust(self) -> RustInterfaceSymbols:
|
1008
1010
|
return self._rust
|
1009
1011
|
|
1012
|
+
@property
|
1013
|
+
def cpp(self) -> CppInterfaceSymbols:
|
1014
|
+
return self._cpp
|
1015
|
+
|
1010
1016
|
@staticmethod
|
1011
1017
|
def get_enum_module_name() -> str:
|
1012
1018
|
return InterfaceEnum.get_module_name()
|
@@ -1017,7 +1023,7 @@ class StingerSpec:
|
|
1017
1023
|
|
1018
1024
|
@classmethod
|
1019
1025
|
def new_spec_from_stinger(
|
1020
|
-
cls, topic_creator, stinger:
|
1026
|
+
cls, topic_creator, stinger: dict[str, Any]
|
1021
1027
|
) -> StingerSpec:
|
1022
1028
|
if "stingeripc" not in stinger:
|
1023
1029
|
raise InvalidStingerStructure("Missing 'stingeripc' format version")
|
stingeripc/lang_symb.py
CHANGED
@@ -5,6 +5,10 @@ class PythonSymbols:
|
|
5
5
|
def __init__(self):
|
6
6
|
...
|
7
7
|
|
8
|
+
@property
|
9
|
+
def package_name(self):
|
10
|
+
return f"{stringmanip.lower_camel_case(self._iface.name).lower()}ipc"
|
11
|
+
|
8
12
|
@property
|
9
13
|
def type_definition_module(self) -> str:
|
10
14
|
return "stinger_types"
|
@@ -51,7 +55,11 @@ class PythonMethodSymbols(PythonSymbols):
|
|
51
55
|
def return_value_class(self):
|
52
56
|
return f"{self.type_definition_module}.{self.return_value_local_class}"
|
53
57
|
|
54
|
-
class
|
58
|
+
class RustSymbols:
|
59
|
+
def __init__(self):
|
60
|
+
pass
|
61
|
+
|
62
|
+
class RustInterfaceSymbols(RustSymbols):
|
55
63
|
|
56
64
|
def __init__(self, interface):
|
57
65
|
super().__init__()
|
@@ -66,3 +74,29 @@ class RustInterfaceSymbols(PythonSymbols):
|
|
66
74
|
def server_struct_name(self) -> str:
|
67
75
|
""" Name of the struct for the interface server."""
|
68
76
|
return f"{stringmanip.upper_camel_case(self._iface.name)}Server"
|
77
|
+
|
78
|
+
class CppSymbols:
|
79
|
+
def __init__(self):
|
80
|
+
pass
|
81
|
+
|
82
|
+
class CppInterfaceSymbols(CppSymbols):
|
83
|
+
|
84
|
+
def __init__(self, interface):
|
85
|
+
super().__init__()
|
86
|
+
self._iface = interface
|
87
|
+
|
88
|
+
@property
|
89
|
+
def client_class_name(self) -> str:
|
90
|
+
return f"{stringmanip.upper_camel_case(self._iface.name)}Client"
|
91
|
+
|
92
|
+
@property
|
93
|
+
def server_class_name(self) -> str:
|
94
|
+
return f"{stringmanip.upper_camel_case(self._iface.name)}Server"
|
95
|
+
|
96
|
+
@property
|
97
|
+
def enum_header_file(self) -> str:
|
98
|
+
return "enums.hpp"
|
99
|
+
|
100
|
+
@property
|
101
|
+
def property_struct_header_file(self) -> str:
|
102
|
+
return "property_structs.hpp"
|
@@ -7,8 +7,8 @@
|
|
7
7
|
int main(int argc, char** argv) {
|
8
8
|
|
9
9
|
{%set broker = stinger.get_example_broker()%}
|
10
|
-
auto conn = std::make_shared<{{broker.class_name}}>({%if broker.hostname is none%}"localhost", 1883, {%endif%}"{{stinger.
|
11
|
-
{{stinger.
|
10
|
+
auto conn = std::make_shared<{{broker.class_name}}>({%if broker.hostname is none%}"localhost", 1883, {%endif%}"{{stinger.cpp.client_class_name}}-demo");
|
11
|
+
{{stinger.cpp.client_class_name}} client(conn);
|
12
12
|
|
13
13
|
{%-for sig_name, sig in stinger.signals.items() %}
|
14
14
|
client.register{{sig_name | UpperCamelCase}}Callback([]({%for arg in sig.arg_list%}{{arg.cpp_type}} {{arg.name}}{%if not loop.last%}, {%endif%}{%endfor%}) {
|
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
#include "broker.hpp"
|
5
5
|
#include "server.hpp"
|
6
|
-
#include "
|
6
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
7
7
|
|
8
8
|
int main(int argc, char** argv) {
|
9
9
|
|
10
10
|
{%set broker = stinger.get_example_broker()%}
|
11
|
-
auto conn = std::make_shared<{{broker.class_name}}>({%if broker.hostname is none%}"localhost", 1883, {%endif%}"{{stinger.name | UpperCamelCase}}
|
12
|
-
{{stinger.
|
11
|
+
auto conn = std::make_shared<{{broker.class_name}}>({%if broker.hostname is none%}"localhost", 1883, {%endif%}"{{stinger.name | UpperCamelCase}}");
|
12
|
+
{{stinger.cpp.server_class_name}} server(conn);
|
13
13
|
|
14
14
|
{%-for sig_name, sig in stinger.signals.items() %}
|
15
15
|
auto {{sig_name}}Future = server.emit{{sig_name | UpperCamelCase}}Signal({%for arg in sig.arg_list%}{{arg.get_random_example_value(lang="c++")}}{%if not loop.last%}, {%endif%}{%endfor%});
|
@@ -22,9 +22,9 @@ int main(int argc, char** argv) {
|
|
22
22
|
server.register{{method_name | UpperCamelCase}}Handler([]({%for arg in method.arg_list%}{{arg.cpp_type}} unused{{loop.index}}{%if not loop.last%}, {%endif%}{%endfor%}) -> {{method.return_value_cpp_class}}
|
23
23
|
{
|
24
24
|
std::cout << "Received call for {{method_name}}\n";
|
25
|
-
{
|
25
|
+
{%-if method.return_value_type == 'struct'%}
|
26
26
|
return {{method.return_value_name | UpperCamelCase}}{ {{method.get_return_value_random_example_value('c++')}} };
|
27
|
-
{%
|
27
|
+
{%-elif method.return_value_type is not false %}
|
28
28
|
return {{method.get_return_value_random_example_value('c++')}};
|
29
29
|
{%-endif%}
|
30
30
|
});
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
DO NOT MODIFY THIS FILE. It is automatically generated and changes will be over-written
|
3
|
+
on the next generation.
|
4
|
+
|
5
|
+
It contains enumerations used by the {{stinger.name}} interface.
|
6
|
+
*/
|
7
|
+
|
1
8
|
|
2
9
|
#pragma once
|
3
10
|
|
@@ -11,10 +18,11 @@
|
|
11
18
|
#include <boost/uuid/uuid.hpp>
|
12
19
|
|
13
20
|
#include "ibrokerconnection.hpp"
|
14
|
-
#include "
|
21
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
15
22
|
#include "return_types.hpp"
|
23
|
+
{%if stinger.properties | length > 0 %}#include "{{stinger.cpp.property_struct_header_file}}"{%endif%}
|
16
24
|
|
17
|
-
class {{stinger.
|
25
|
+
class {{stinger.cpp.client_class_name}} {
|
18
26
|
|
19
27
|
public:
|
20
28
|
// This is the name of the API.
|
@@ -23,9 +31,9 @@ public:
|
|
23
31
|
static constexpr const char INTERFACE_VERSION[] = "{{stinger.version}}";
|
24
32
|
|
25
33
|
// Constructor taking a connection object.
|
26
|
-
{{stinger.
|
34
|
+
{{stinger.cpp.client_class_name}}(std::shared_ptr<IBrokerConnection> broker);
|
27
35
|
|
28
|
-
virtual ~{{stinger.
|
36
|
+
virtual ~{{stinger.cpp.client_class_name}}() = default;
|
29
37
|
|
30
38
|
{%for sig_name, sig in stinger.signals.items()%}
|
31
39
|
// Register a callback for the `{{sig_name}}` signal.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
DO NOT MODIFY THIS FILE. It is automatically generated and changes will be over-written
|
3
|
+
on the next generation.
|
4
|
+
|
5
|
+
It contains enumerations used by the {{stinger.name}} interface.
|
6
|
+
*/
|
7
|
+
|
8
|
+
{%for prop_name, prop in stinger.properties.items() %}
|
9
|
+
// {{prop}}
|
10
|
+
{%endfor%}
|
@@ -1,7 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
DO NOT MODIFY THIS FILE. It is automatically generated and changes will be over-written
|
3
|
+
on the next generation.
|
4
|
+
|
5
|
+
It contains enumerations used by the {{stinger.name}} interface.
|
6
|
+
*/
|
7
|
+
|
1
8
|
|
2
9
|
#pragma once
|
3
10
|
#include <string>
|
4
|
-
#include "
|
11
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
5
12
|
|
6
13
|
{%for method_name, method in stinger.methods.items()%}
|
7
14
|
{%-if method.return_value_type == 'struct'%}
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
DO NOT MODIFY THIS FILE. It is automatically generated and changes will be over-written
|
3
|
+
on the next generation.
|
4
|
+
|
5
|
+
It contains enumerations used by the {{stinger.name}} interface.
|
6
|
+
*/
|
7
|
+
|
1
8
|
|
2
9
|
#pragma once
|
3
10
|
|
@@ -12,18 +19,18 @@
|
|
12
19
|
#include <rapidjson/document.h>
|
13
20
|
|
14
21
|
#include "ibrokerconnection.hpp"
|
15
|
-
#include "
|
22
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
16
23
|
#include "return_types.hpp"
|
17
24
|
|
18
|
-
class {{stinger.
|
25
|
+
class {{stinger.cpp.server_class_name}} {
|
19
26
|
|
20
27
|
public:
|
21
28
|
static constexpr const char NAME[] = "{{stinger.name}}";
|
22
29
|
static constexpr const char INTERFACE_VERSION[] = "{{stinger.version}}";
|
23
30
|
|
24
|
-
{{stinger.
|
31
|
+
{{stinger.cpp.server_class_name}}(std::shared_ptr<IBrokerConnection> broker);
|
25
32
|
|
26
|
-
virtual ~{{stinger.
|
33
|
+
virtual ~{{stinger.cpp.server_class_name}}() = default;
|
27
34
|
|
28
35
|
{%for sig_name, sig in stinger.signals.items()%}
|
29
36
|
boost::future<bool> emit{{sig_name | UpperCamelCase}}Signal({%for arg in sig.arg_list%}{{arg.cpp_type}}{%if not loop.last%}, {%endif%}{%endfor%});
|
@@ -1,8 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
DO NOT MODIFY THIS FILE. It is automatically generated and changes will be over-written
|
3
|
+
on the next generation.
|
4
|
+
|
5
|
+
It contains enumerations used by the {{stinger.name}} interface.
|
6
|
+
*/
|
1
7
|
|
2
8
|
#pragma once
|
3
9
|
#include <string>
|
4
10
|
#include <boost/optional.hpp>
|
5
|
-
#include "
|
11
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
6
12
|
|
7
13
|
{%for istruct_name, istruct in stinger.structs.items() %}
|
8
14
|
struct {{istruct_name | UpperCamelCase }} {
|
@@ -13,14 +13,14 @@
|
|
13
13
|
#include <rapidjson/document.h>
|
14
14
|
|
15
15
|
#include "client.hpp"
|
16
|
-
#include "
|
16
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
17
17
|
#include "ibrokerconnection.hpp"
|
18
18
|
|
19
19
|
|
20
|
-
constexpr const char {{stinger.
|
21
|
-
constexpr const char {{stinger.
|
20
|
+
constexpr const char {{stinger.cpp.client_class_name}}::NAME[];
|
21
|
+
constexpr const char {{stinger.cpp.client_class_name}}::INTERFACE_VERSION[];
|
22
22
|
|
23
|
-
{{stinger.
|
23
|
+
{{stinger.cpp.client_class_name}}::{{stinger.cpp.client_class_name}}(std::shared_ptr<IBrokerConnection> broker) : _broker(broker)
|
24
24
|
{
|
25
25
|
_broker->AddMessageCallback([this](const std::string& topic, const std::string& payload, const boost::optional<std::string> optCorrelationId, const boost::optional<std::string> unusedRespTopic, const boost::optional<MethodResultCode> optResultCode)
|
26
26
|
{
|
@@ -39,7 +39,7 @@ constexpr const char {{stinger.name | UpperCamelCase}}Client::INTERFACE_VERSION[
|
|
39
39
|
{%-endfor%}
|
40
40
|
}
|
41
41
|
|
42
|
-
void {{stinger.
|
42
|
+
void {{stinger.cpp.client_class_name}}::_receiveMessage(
|
43
43
|
const std::string& topic,
|
44
44
|
const std::string& payload,
|
45
45
|
const boost::optional<std::string> optCorrelationId,
|
@@ -106,14 +106,14 @@ void {{stinger.name | UpperCamelCase}}Client::_receiveMessage(
|
|
106
106
|
|
107
107
|
|
108
108
|
{%-for sig_name, sig in stinger.signals.items() %}
|
109
|
-
void {{stinger.
|
109
|
+
void {{stinger.cpp.client_class_name}}::register{{sig_name | UpperCamelCase}}Callback(const std::function<void({%for arg in sig.arg_list%}{{arg.cpp_type}}{%if not loop.last%}, {%endif%}{%endfor%})>& cb)
|
110
110
|
{
|
111
111
|
_{{sig_name | camelCase}}Callback = cb;
|
112
112
|
}
|
113
113
|
{%-endfor%}
|
114
114
|
|
115
115
|
{%for method_name, method in stinger.methods.items()%}
|
116
|
-
boost::future<{{method.return_value_cpp_class}}> {{stinger.
|
116
|
+
boost::future<{{method.return_value_cpp_class}}> {{stinger.cpp.client_class_name}}::{{method_name | camelCase}}({%for arg in method.arg_list%}{{arg.cpp_type}} {{arg.name}}{%if not loop.last%}, {%endif%}{%endfor%})
|
117
117
|
{
|
118
118
|
auto correlationId = boost::uuids::random_generator()();
|
119
119
|
const std::string correlationIdStr = boost::lexical_cast<std::string>(correlationId);
|
@@ -122,7 +122,7 @@ boost::future<{{method.return_value_cpp_class}}> {{stinger.name | UpperCamelCase
|
|
122
122
|
rapidjson::Document doc;
|
123
123
|
doc.SetObject();
|
124
124
|
|
125
|
-
{
|
125
|
+
{%-macro addToDoc(arg)%}
|
126
126
|
{%-if arg.arg_type.name.lower() == 'primitive'%}
|
127
127
|
{%-if arg.optional %}if ({{arg.name}}) {%endif-%}
|
128
128
|
{%-if arg.type.name.lower() == 'string'%}
|
@@ -151,7 +151,7 @@ boost::future<{{method.return_value_cpp_class}}> {{stinger.name | UpperCamelCase
|
|
151
151
|
return _pending{{method_name|UpperCamelCase}}MethodCalls[correlationId].get_future();
|
152
152
|
}
|
153
153
|
|
154
|
-
void {{stinger.
|
154
|
+
void {{stinger.cpp.client_class_name}}::_handle{{method_name|UpperCamelCase}}Response(
|
155
155
|
const std::string& topic,
|
156
156
|
const std::string& payload,
|
157
157
|
const std::string &correlationId)
|
@@ -182,6 +182,7 @@ void {{stinger.name | UpperCamelCase}}Client::_handle{{method_name|UpperCamelCas
|
|
182
182
|
{%endif-%}
|
183
183
|
{%endmacro-%}
|
184
184
|
{%if method.return_value_type == 'struct'-%}
|
185
|
+
// Response has multiple values.
|
185
186
|
{%for item in method.return_value%}
|
186
187
|
{{unpack_rv(item)}}
|
187
188
|
{%-endfor%}
|
@@ -191,8 +192,12 @@ void {{stinger.name | UpperCamelCase}}Client::_handle{{method_name|UpperCamelCas
|
|
191
192
|
{%-endfor%}
|
192
193
|
};
|
193
194
|
promiseItr->second.set_value(returnValue);
|
195
|
+
{%-elif method.return_value_type is false %}
|
196
|
+
// There are no values in the response.
|
197
|
+
promiseItr->second.set_value();
|
194
198
|
{%-else%}
|
195
|
-
|
199
|
+
// Response has a single value.
|
200
|
+
{{unpack_rv(method.return_value)}}
|
196
201
|
promiseItr->second.set_value({{method.return_value_property_name}});
|
197
202
|
{%-endif%}
|
198
203
|
}
|
@@ -11,14 +11,14 @@
|
|
11
11
|
#include <rapidjson/document.h>
|
12
12
|
|
13
13
|
#include "server.hpp"
|
14
|
-
#include "
|
14
|
+
#include "{{stinger.cpp.enum_header_file}}"
|
15
15
|
#include "ibrokerconnection.hpp"
|
16
16
|
|
17
17
|
|
18
|
-
constexpr const char {{stinger.
|
19
|
-
constexpr const char {{stinger.
|
18
|
+
constexpr const char {{stinger.cpp.server_class_name}}::NAME[];
|
19
|
+
constexpr const char {{stinger.cpp.server_class_name}}::INTERFACE_VERSION[];
|
20
20
|
|
21
|
-
{{stinger.
|
21
|
+
{{stinger.cpp.server_class_name}}::{{stinger.cpp.server_class_name}}(std::shared_ptr<IBrokerConnection> broker) : _broker(broker) {
|
22
22
|
_broker->AddMessageCallback([this](const std::string& topic, const std::string& payload, const boost::optional<std::string> optCorrelationId, const boost::optional<std::string> optResponseTopic, const boost::optional<MethodResultCode> unusedRc)
|
23
23
|
{
|
24
24
|
_receiveMessage(topic, payload, optCorrelationId, optResponseTopic);
|
@@ -28,7 +28,7 @@ constexpr const char {{stinger.name | UpperCamelCase}}Server::INTERFACE_VERSION[
|
|
28
28
|
{%endfor%}
|
29
29
|
}
|
30
30
|
|
31
|
-
void {{stinger.
|
31
|
+
void {{stinger.cpp.server_class_name}}::_receiveMessage(
|
32
32
|
const std::string& topic,
|
33
33
|
const std::string& payload,
|
34
34
|
const boost::optional<std::string> optCorrelationId,
|
@@ -67,7 +67,7 @@ void {{stinger.name | UpperCamelCase}}Server::_receiveMessage(
|
|
67
67
|
}
|
68
68
|
|
69
69
|
{%for sig_name, sig in stinger.signals.items()%}
|
70
|
-
boost::future<bool> {{stinger.
|
70
|
+
boost::future<bool> {{stinger.cpp.server_class_name}}::emit{{sig_name | UpperCamelCase}}Signal({%for arg in sig.arg_list%}{{arg.cpp_type}} {{arg.name}}{%if not loop.last%}, {%endif%}{%endfor%})
|
71
71
|
{
|
72
72
|
rapidjson::Document doc;
|
73
73
|
doc.SetObject();
|
@@ -98,7 +98,7 @@ boost::future<bool> {{stinger.name | UpperCamelCase}}Server::emit{{sig_name | Up
|
|
98
98
|
{%endfor%}
|
99
99
|
|
100
100
|
{%for method_name, method in stinger.methods.items()%}
|
101
|
-
void {{stinger.
|
101
|
+
void {{stinger.cpp.server_class_name}}::register{{method_name | UpperCamelCase}}Handler(std::function<{{method.return_value_cpp_class}}({%for arg in method.arg_list%}{{arg.cpp_type}}{%if not loop.last%}, {%endif%}{%endfor%})> func)
|
102
102
|
{
|
103
103
|
std::cout << "Registered method to handle {{method.topic}}\n";
|
104
104
|
_{{method_name | camelCase}}Handler = func;
|
@@ -106,7 +106,7 @@ void {{stinger.name | UpperCamelCase}}Server::register{{method_name | UpperCamel
|
|
106
106
|
{%endfor%}
|
107
107
|
|
108
108
|
{%for method_name, method in stinger.methods.items()%}
|
109
|
-
void {{stinger.
|
109
|
+
void {{stinger.cpp.server_class_name}}::_call{{method_name | UpperCamelCase}}Handler(
|
110
110
|
const std::string& topic,
|
111
111
|
const rapidjson::Document& doc,
|
112
112
|
const boost::optional<std::string> optCorrelationId,
|
@@ -130,12 +130,13 @@ void {{stinger.name | UpperCamelCase}}Server::_call{{method_name | UpperCamelCas
|
|
130
130
|
}
|
131
131
|
{%endfor%}
|
132
132
|
|
133
|
-
{{method.return_value_cpp_class}} ret = _{{method_name | camelCase}}Handler({%for arg in method.arg_list%}temp{{arg.name|UpperCamelCase}}{%if not loop.last%}, {%endif%}{%endfor%});
|
133
|
+
{%if method.return_value_type is not false%}{{method.return_value_cpp_class}} ret = {%endif%}_{{method_name | camelCase}}Handler({%for arg in method.arg_list%}temp{{arg.name|UpperCamelCase}}{%if not loop.last%}, {%endif%}{%endfor%});
|
134
134
|
|
135
135
|
if (optResponseTopic)
|
136
136
|
{
|
137
137
|
rapidjson::Document responseJson;
|
138
138
|
responseJson.SetObject();
|
139
|
+
|
139
140
|
{%macro add_arg_to_json(arg, value) %}
|
140
141
|
// add the {{arg.name}} (a/n {{arg.arg_type.name}}) to the json
|
141
142
|
rapidjson::Value returnValue{{arg.name|UpperCamelCase}};
|
@@ -150,16 +151,15 @@ void {{stinger.name | UpperCamelCase}}Server::_call{{method_name | UpperCamelCas
|
|
150
151
|
{%-endif%} {# value or enum#}
|
151
152
|
responseJson.AddMember("{{arg.name}}", returnValue{{arg.name|UpperCamelCase}}, responseJson.GetAllocator());
|
152
153
|
{%endmacro%}
|
153
|
-
|
154
154
|
{%-if method.return_value_type == 'struct'%}
|
155
155
|
// Return type is a struct of values that need added to json
|
156
156
|
{%for member in method.return_value-%}
|
157
157
|
{{add_arg_to_json(member, "ret."+member.name)}}
|
158
158
|
{%endfor%}
|
159
|
-
{%-
|
159
|
+
{%-elif method.return_value_type is not false%}
|
160
|
+
// Return type is a single value
|
160
161
|
{{add_arg_to_json(method.return_value, "ret")}}
|
161
162
|
{%-endif%}
|
162
|
-
|
163
163
|
rapidjson::StringBuffer buf;
|
164
164
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buf);
|
165
165
|
responseJson.Accept(writer);
|
@@ -1,6 +1,79 @@
|
|
1
1
|
# _{{stinger.name}}_ API Overview
|
2
|
+
{%-if stinger.summary %}
|
3
|
+
_{{stinger.summary}}_
|
4
|
+
{%endif-%}
|
5
|
+
{%if stinger.documentation%}
|
6
|
+
{{stinger.documentation}}
|
7
|
+
|
8
|
+
## Connections
|
9
|
+
|
10
|
+
A connection object is a wrapper around an MQTT client and provides specific functionality to support both clients and servers.
|
11
|
+
Generally, you only need one connection object per daemon/program, as it can support multiple clients and servers.
|
12
|
+
|
13
|
+
### Connection code Examples
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary>Python</summary>
|
17
|
+
|
18
|
+
```python{%set broker = stinger.get_example_broker()%}
|
19
|
+
from connection import {{broker.class_name}}
|
20
|
+
|
21
|
+
connection_object = {{broker.class_name}}({%if broker.hostname is none%}'localhost', 1883{%endif%})
|
22
|
+
```
|
23
|
+
|
24
|
+
The `connection_object` will be passed to client and server constructors.
|
25
|
+
|
26
|
+
</details>
|
27
|
+
|
28
|
+
<details>
|
29
|
+
<summary>C++</summary>
|
30
|
+
|
31
|
+
```c++{%set broker = stinger.get_example_broker()%}
|
32
|
+
#include "broker.hpp"
|
33
|
+
|
34
|
+
auto connection_object = std::make_shared<{{broker.class_name}}>({%if broker.hostname is none%}"localhost", 1883, {%endif%}"{{stinger.name | UpperCamelCase}}");
|
35
|
+
```
|
36
|
+
|
37
|
+
The `connection_object` will be passed to client and server constructors.
|
38
|
+
|
39
|
+
</details>
|
40
|
+
|
41
|
+
## Server
|
2
42
|
|
3
|
-
|
43
|
+
A server is a _provider_ of functionality. It sends signals, handles method calls, and owns property values.
|
44
|
+
|
45
|
+
### Server Code Examples
|
46
|
+
|
47
|
+
<details>
|
48
|
+
<summary>Python Server</summary>
|
49
|
+
|
50
|
+
```python{%set broker = stinger.get_example_broker()%}
|
51
|
+
from {{stinger.python.package_name}}.client import {{stinger.cpp.server_class_name}}
|
52
|
+
|
53
|
+
server = {{stinger.python.server_class_name}}(connection_object)
|
54
|
+
```
|
55
|
+
|
56
|
+
The `server` object provides methods for emitting signals and updating properties. It also allows for decorators to indicate method call handlers.
|
57
|
+
|
58
|
+
</details>
|
59
|
+
|
60
|
+
<details>
|
61
|
+
<summary>C++ Server</summary>
|
62
|
+
|
63
|
+
```python{%set broker = stinger.get_example_broker()%}
|
64
|
+
from connection import {{broker.class_name}}
|
65
|
+
|
66
|
+
conn = {{broker.class_name}}({%if broker.hostname is none%}'localhost', 1883{%endif%})
|
67
|
+
server = {{stinger.python.server_class_name}}(conn)
|
68
|
+
```
|
69
|
+
|
70
|
+
The `server` object provides methods for emitting signals and updating properties. It also allows for decorators to indicate method call handlers.
|
71
|
+
|
72
|
+
</details>
|
73
|
+
|
74
|
+
## Client
|
75
|
+
|
76
|
+
{%endif-%}
|
4
77
|
{%macro argrow(arg) -%}
|
5
78
|
|{{arg.name|center(15)}}|
|
6
79
|
{%-if arg.arg_type.name.lower() == "enum" or arg.arg_type.name.lower() == "struct"%}{{arg.markdown_type|center(10)}}
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
from jacobsjinjatoo import templator as jj2
|
4
|
+
|
5
|
+
from stingeripc import StingerInterface
|
6
|
+
|
7
|
+
def main():
|
8
|
+
inname = sys.argv[1]
|
9
|
+
outdir = sys.argv[2]
|
10
|
+
with open(inname, "r") as f:
|
11
|
+
stinger = StingerInterface.from_yaml(f)
|
12
|
+
params = {
|
13
|
+
"stinger": stinger,
|
14
|
+
}
|
15
|
+
t = jj2.CodeTemplator(output_dir=os.path.dirname(outdir))
|
16
|
+
t.add_template_dir(
|
17
|
+
os.path.join(os.path.dirname(__file__), "../templates", "markdown")
|
18
|
+
)
|
19
|
+
for output_file in [
|
20
|
+
"index.md",
|
21
|
+
]:
|
22
|
+
t.render_template(f"{output_file}.jinja2", output_file, **params)
|
23
|
+
|
24
|
+
if __name__ == '__main__':
|
25
|
+
main()
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from jacobsjinjatoo import templator as jj2
|
2
|
+
from jacobsjinjatoo import stringmanip
|
3
|
+
import sys
|
4
|
+
import os.path
|
5
|
+
|
6
|
+
from stingeripc import StingerInterface
|
7
|
+
|
8
|
+
def main():
|
9
|
+
inname = sys.argv[1]
|
10
|
+
outdir = sys.argv[2]
|
11
|
+
with open(inname, "r") as f:
|
12
|
+
stinger = StingerInterface.from_yaml(f)
|
13
|
+
params = {
|
14
|
+
"stinger": stinger,
|
15
|
+
}
|
16
|
+
t = jj2.CodeTemplator(output_dir=os.path.dirname(outdir))
|
17
|
+
t.add_template_dir(
|
18
|
+
os.path.join(os.path.dirname(__file__), "../templates", "python")
|
19
|
+
)
|
20
|
+
for output_file in [
|
21
|
+
"pyproject.toml",
|
22
|
+
]:
|
23
|
+
t.render_template(f"{output_file}.jinja2", output_file, **params)
|
24
|
+
|
25
|
+
generated_src_dir = os.path.join(outdir, f"{stringmanip.lower_camel_case(stinger.name).lower()}ipc")
|
26
|
+
os.makedirs(generated_src_dir, exist_ok=True)
|
27
|
+
for output_file in [
|
28
|
+
"server.py",
|
29
|
+
"client.py",
|
30
|
+
"connection.py",
|
31
|
+
"__init__.py",
|
32
|
+
"method_codes.py",
|
33
|
+
]:
|
34
|
+
t.render_template(f"{output_file}.jinja2", os.path.join(stinger.name.lower(), output_file), **params)
|
35
|
+
|
36
|
+
t.render_template("interface_types.py.jinja2", os.path.join(stinger.name.lower(), f"{stinger.get_enum_module_name()}.py"), **params)
|
37
|
+
|
38
|
+
if __name__ == "__main__":
|
39
|
+
main()
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from jacobsjinjatoo import templator as jj2
|
2
|
+
import sys
|
3
|
+
import yaml
|
4
|
+
import os
|
5
|
+
import shutil
|
6
|
+
|
7
|
+
from stingeripc import StingerInterface
|
8
|
+
|
9
|
+
def main():
|
10
|
+
inname = sys.argv[1] # Path to the stinger file
|
11
|
+
outdir = sys.argv[2] # Directory to which the files should be written
|
12
|
+
with open(inname, "r") as f:
|
13
|
+
stinger = StingerInterface.from_yaml(f)
|
14
|
+
params = {
|
15
|
+
"stinger": stinger,
|
16
|
+
}
|
17
|
+
|
18
|
+
if not os.path.exists(outdir):
|
19
|
+
os.makedirs(outdir)
|
20
|
+
|
21
|
+
template_dir = os.path.join(os.path.dirname(__file__), "../templates", "rust")
|
22
|
+
|
23
|
+
t = jj2.CodeTemplator(output_dir=os.path.dirname(outdir))
|
24
|
+
t.add_template_dir(template_dir)
|
25
|
+
|
26
|
+
def recursive_render_templates(local_dir: str):
|
27
|
+
cur_template_dir = os.path.join(template_dir, local_dir)
|
28
|
+
for entry in os.listdir(cur_template_dir):
|
29
|
+
if entry == 'target':
|
30
|
+
# Do not copy 'target' dir
|
31
|
+
continue
|
32
|
+
entry_full_path = os.path.join(cur_template_dir, entry)
|
33
|
+
entry_local_path = os.path.join(local_dir, entry)
|
34
|
+
if entry.endswith(".jinja2"):
|
35
|
+
print(f"GENER: {entry_local_path}")
|
36
|
+
t.render_template(entry_local_path, entry_local_path[:-len(".jinja2")], **params)
|
37
|
+
elif os.path.isdir(entry_full_path):
|
38
|
+
print(f"MKDIR: {entry_local_path}")
|
39
|
+
new_dir = os.path.join(outdir, entry_local_path)
|
40
|
+
if not os.path.exists(new_dir):
|
41
|
+
os.makedirs(new_dir)
|
42
|
+
recursive_render_templates(entry_local_path)
|
43
|
+
elif os.path.isfile(entry_full_path):
|
44
|
+
shutil.copyfile(entry_full_path, os.path.join(outdir, entry_local_path))
|
45
|
+
print(f"COPY: {entry_local_path}")
|
46
|
+
|
47
|
+
recursive_render_templates(".")
|
48
|
+
|
49
|
+
if __name__ == "__main__":
|
50
|
+
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|