Skip to content

Commit 33e3ceb

Browse files
committed
support multiple Jupyter execute messages in one group;
also added print() function as alias for log.debug() so black nbextension works
1 parent ab0bb05 commit 33e3ceb

File tree

4 files changed

+199
-194
lines changed

4 files changed

+199
-194
lines changed

custom_components/pyscript/const.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,21 @@
77
SERVICE_JUPYTER_KERNEL_START = "jupyter_kernel_start"
88

99
LOGGER_PATH = "custom_components.pyscript"
10+
11+
ALLOWED_IMPORTS = {
12+
"black",
13+
"cmath",
14+
"datetime",
15+
"decimal",
16+
"fractions",
17+
"homeassistant.const",
18+
"isort",
19+
"json",
20+
"math",
21+
"number",
22+
"random",
23+
"re",
24+
"statistics",
25+
"string",
26+
"time",
27+
}

custom_components/pyscript/eval.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
import sys
88

9-
from .const import LOGGER_PATH
9+
from .const import ALLOWED_IMPORTS, LOGGER_PATH
1010

1111
_LOGGER = logging.getLogger(LOGGER_PATH + ".eval")
1212

@@ -148,24 +148,6 @@ async def locals_func():
148148
}
149149

150150

151-
ALLOWED_IMPORTS = {
152-
"bisect",
153-
"cmath",
154-
"colorsys",
155-
"datetime",
156-
"decimal",
157-
"fractions",
158-
"homeassistant.const",
159-
"math",
160-
"number",
161-
"random",
162-
"re",
163-
"statistics",
164-
"string",
165-
"time",
166-
}
167-
168-
169151
#
170152
# Objects returned by return, break and continue statements that change execution flow
171153
#

custom_components/pyscript/handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(self, hass):
4343
"log.error": self.get_logger_error,
4444
"log.info": self.get_logger_info,
4545
"log.warning": self.get_logger_warning,
46+
"print": self.get_logger_debug,
4647
}
4748

4849
#

0 commit comments

Comments
 (0)