custom depth added

This commit is contained in:
htmltiger 2022-03-12 01:14:40 +00:00 committed by GitHub
parent f101b537be
commit c221e52407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ async def async_setup(hass, config):
vol.Required("file"): str,
vol.Required("data"): str,
vol.Required("ext"): str,
vol.Optional("depth", default=2): int
}
)
async def websocket_create(hass, connection, msg):
@ -50,7 +51,7 @@ async def websocket_create(hass, connection, msg):
v = os.path.join(r, d)
if os.path.isdir(v):
p = d if s == '' else os.path.join(s, d)
if(p.count(os.sep) < 3) and ( ext == 'all' or p != 'custom_components' ):
if(p.count(os.sep) < msg["depth"]) and ( ext == 'all' or p != 'custom_components' ):
rec(v, p)
drec(v, p)
@ -107,7 +108,8 @@ async def websocket_create(hass, connection, msg):
dirnm = os.path.dirname(hass.config.path(yamlname))
listyaml = []
rec(dirnm, '')
drec(dirnm, '')
if msg["depth"]>0:
drec(dirnm, '')
if (len(listyaml) < 1):
listyaml = ['list_error.'+ext]
connection.send_result(