mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move imports to top for python_script (#29331)
This commit is contained in:
parent
5a24dbf599
commit
8baba2e33d
@ -5,6 +5,15 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from RestrictedPython import compile_restricted_exec
|
||||||
|
from RestrictedPython.Eval import default_guarded_getitem
|
||||||
|
from RestrictedPython.Guards import (
|
||||||
|
full_write_guard,
|
||||||
|
guarded_iter_unpack_sequence,
|
||||||
|
guarded_unpack_sequence,
|
||||||
|
safe_builtins,
|
||||||
|
)
|
||||||
|
from RestrictedPython.Utilities import utility_builtins
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import SERVICE_RELOAD
|
from homeassistant.const import SERVICE_RELOAD
|
||||||
@ -12,8 +21,8 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers.service import async_set_service_schema
|
from homeassistant.helpers.service import async_set_service_schema
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util import sanitize_filename
|
from homeassistant.util import sanitize_filename
|
||||||
from homeassistant.util.yaml.loader import load_yaml
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
from homeassistant.util.yaml.loader import load_yaml
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -122,15 +131,6 @@ def execute_script(hass, name, data=None):
|
|||||||
@bind_hass
|
@bind_hass
|
||||||
def execute(hass, filename, source, data=None):
|
def execute(hass, filename, source, data=None):
|
||||||
"""Execute Python source."""
|
"""Execute Python source."""
|
||||||
from RestrictedPython import compile_restricted_exec
|
|
||||||
from RestrictedPython.Guards import (
|
|
||||||
safe_builtins,
|
|
||||||
full_write_guard,
|
|
||||||
guarded_iter_unpack_sequence,
|
|
||||||
guarded_unpack_sequence,
|
|
||||||
)
|
|
||||||
from RestrictedPython.Utilities import utility_builtins
|
|
||||||
from RestrictedPython.Eval import default_guarded_getitem
|
|
||||||
|
|
||||||
compiled = compile_restricted_exec(source, filename=filename)
|
compiled = compile_restricted_exec(source, filename=filename)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user