Skip to content

Commit

Permalink
workaround when family type is not defined by the device
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ committed Oct 18, 2023
1 parent 3b5a1f6 commit 9f27f59
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions platform/panduza_platform/core/platform_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ def get_interface_defs(self):

# ---

def get_config_field(self, field):
def get_config_field(self, field, default=None):
config = self._PZA_DEV_config()
if not field in config:
raise InitializationError(f"\"{field}\" field is not provided in the device config {config}")
if default == None:
raise InitializationError(f"\"{field}\" field is not provided in the device config {config}")
else:
return default
return config.get(field)

# ---
Expand Down Expand Up @@ -82,7 +85,7 @@ def get_base_name(self):
# ---

def get_family(self):
return self.get_config_field("family")
return self.get_config_field("family", "unknown")

# ---

Expand Down

0 comments on commit 9f27f59

Please sign in to comment.