Merge pull request #7 from htmltiger/htmltiger-patch-1

custom depth added
This commit is contained in:
htmltiger 2022-03-12 01:17:53 +00:00 committed by GitHub
commit 3f1a32afc2
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("file"): str,
vol.Required("data"): str, vol.Required("data"): str,
vol.Required("ext"): str, vol.Required("ext"): str,
vol.Optional("depth", default=2): int
} }
) )
async def websocket_create(hass, connection, msg): async def websocket_create(hass, connection, msg):
@ -50,7 +51,7 @@ async def websocket_create(hass, connection, msg):
v = os.path.join(r, d) v = os.path.join(r, d)
if os.path.isdir(v): if os.path.isdir(v):
p = d if s == '' else os.path.join(s, d) 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) rec(v, p)
drec(v, p) drec(v, p)
@ -107,6 +108,7 @@ async def websocket_create(hass, connection, msg):
dirnm = os.path.dirname(hass.config.path(yamlname)) dirnm = os.path.dirname(hass.config.path(yamlname))
listyaml = [] listyaml = []
rec(dirnm, '') rec(dirnm, '')
if msg["depth"]>0:
drec(dirnm, '') drec(dirnm, '')
if (len(listyaml) < 1): if (len(listyaml) < 1):
listyaml = ['list_error.'+ext] listyaml = ['list_error.'+ext]