mirror of
https://github.com/netbox-community/devicetype-library.git
synced 2025-08-09 23:17:45 +02:00
@ -1,3 +1,4 @@
|
||||
from test_configuration import KNOWN_SLUGS
|
||||
import os
|
||||
|
||||
class DeviceType:
|
||||
@ -40,18 +41,9 @@ class DeviceType:
|
||||
def get_filepath(self):
|
||||
return self.file_path
|
||||
|
||||
def verify_slug(self, KNOWN_SLUGS):
|
||||
def verify_slug(self):
|
||||
# Verify the slug is unique, and not already known
|
||||
known_slug_list_intersect = [(slug, file_path) for slug, file_path in KNOWN_SLUGS if slug == self.slug]
|
||||
|
||||
if len(known_slug_list_intersect) == 0:
|
||||
pass
|
||||
elif len(known_slug_list_intersect) == 1:
|
||||
if self.file_path not in known_slug_list_intersect[0][1]:
|
||||
self.failureMessage = f'{self.file_path} has a duplicate slug: "{self.slug}"'
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
if self.slug in KNOWN_SLUGS:
|
||||
self.failureMessage = f'{self.file_path} has a duplicate slug "{self.slug}"'
|
||||
return False
|
||||
|
||||
@ -66,7 +58,7 @@ class DeviceType:
|
||||
return False
|
||||
|
||||
# Add the slug to the list of known slugs
|
||||
KNOWN_SLUGS.add((self.slug, self.file_path))
|
||||
KNOWN_SLUGS.add(self.slug)
|
||||
return True
|
||||
|
||||
def validate_power(self):
|
||||
|
Reference in New Issue
Block a user