Skip to content

Commit f75f4e2

Browse files
authored
Support empy4 and empy3 (#921)
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
1 parent 01ab67c commit f75f4e2

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

ros2pkg/ros2pkg/api/create.py

+25-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
import sys
1818

1919
import em
20+
try:
21+
from em import Configuration
22+
em_has_configuration = True
23+
except ImportError:
24+
em_has_configuration = False
25+
2026
try:
2127
import importlib.resources as importlib_resources
2228
except ModuleNotFoundError:
@@ -25,14 +31,25 @@
2531

2632
def _expand_template(template_file, data, output_file):
2733
output = StringIO()
28-
interpreter = em.Interpreter(
29-
output=output,
30-
options={
31-
em.BUFFERED_OPT: True,
32-
em.RAW_OPT: True,
33-
},
34-
globals=data,
35-
)
34+
if em_has_configuration:
35+
config = Configuration(
36+
defaultStdout=output,
37+
deleteOnError=True,
38+
rawErrors=True,
39+
useProxy=True)
40+
interpreter = em.Interpreter(
41+
config=config,
42+
dispatcher=False,
43+
globals=data)
44+
else:
45+
interpreter = em.Interpreter(
46+
output=output,
47+
options={
48+
em.BUFFERED_OPT: True,
49+
em.RAW_OPT: True,
50+
},
51+
globals=data)
52+
3653
with open(template_file, 'r') as h:
3754
try:
3855
interpreter.file(h)

0 commit comments

Comments
 (0)