Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support EmPy 4.x configuration API #665

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions colcon_core/shell/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from colcon_core.logging import colcon_logger
try:
from em import Interpreter
from em import OVERRIDE_OPT
except ImportError as e:
try:
import em # noqa: F401
Expand All @@ -35,13 +34,24 @@
"""
output = StringIO()
try:
# disable OVERRIDE_OPT to avoid saving / restoring stdout
interpreter = CachingInterpreter(
output=output, options={OVERRIDE_OPT: False})
try:
from em import Configuration
except ImportError:
from em import OVERRIDE_OPT
# disable OVERRIDE_OPT to avoid saving / restoring stdout
interpreter = CachingInterpreter(
output=output, options={OVERRIDE_OPT: False})
else:
interpreter = CachingInterpreter(

Check warning on line 45 in colcon_core/shell/template/__init__.py

View check run for this annotation

Codecov / codecov/patch

colcon_core/shell/template/__init__.py#L45

Added line #L45 was not covered by tests
config=Configuration(
defaultRoot=str(template_path),
defaultStdout=output,
useProxy=False),
dispatcher=False)
try:
with template_path.open('r') as h:
content = h.read()
interpreter.string(content, str(template_path), locals=data)
interpreter.string(content, locals=data)
output = output.getvalue()
finally:
interpreter.shutdown()
Expand Down
Loading