mirror of
https://github.com/netbox-community/Device-Type-Library-Import.git
synced 2025-01-22 13:28:34 +01:00
Import all YAML files
Add list of YAML extensions. The netbox device type library excepts both *.yaml and *.yml files
This commit is contained in:
parent
17e2bf9c50
commit
85b868c12e
@ -26,8 +26,10 @@ def update_package(path: str):
|
||||
def slugFormat(name):
|
||||
return name.lower().replace(' ', '_')
|
||||
|
||||
YAML_EXTENSIONS = ['yml', 'yaml']
|
||||
|
||||
def getFiles(vendors=None):
|
||||
|
||||
files = []
|
||||
discoveredVendors = []
|
||||
base_path = './repo/device-types/'
|
||||
@ -38,14 +40,16 @@ def getFiles(vendors=None):
|
||||
if vendor.lower() == folder.lower():
|
||||
discoveredVendors.append({'name': folder,
|
||||
'slug': slugFormat(folder)})
|
||||
files.extend(glob.glob(base_path + folder + '/*.yaml'))
|
||||
for extension in YAML_EXTENSIONS:
|
||||
files.extend(glob.glob(base_path + folder + f'/*.{extension}'))
|
||||
else:
|
||||
for r, d, f in os.walk(base_path):
|
||||
for folder in d:
|
||||
if folder.lower() != "Testing":
|
||||
discoveredVendors.append({'name': folder,
|
||||
'slug': slugFormat(folder)})
|
||||
files.extend(glob.glob(base_path + '[!Testing]*/*.yaml'))
|
||||
for extension in YAML_EXTENSIONS:
|
||||
files.extend(glob.glob(base_path + f'[!Testing]*/*.{extension}'))
|
||||
return files, discoveredVendors
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user