FOOTPRINT::GetProperty() swig extension

This commit is contained in:
qu1ck 2022-01-02 20:21:07 -08:00 committed by Seth Hillbrand
parent e6dc28fb2e
commit 33a4c9b08e
1 changed files with 8 additions and 0 deletions

View File

@ -31,6 +31,7 @@
%template(MAP_STRING_STRING) std::map<wxString, wxString>;
%rename(GetPropertiesNative) FOOTPRINT::GetProperties;
%rename(GetPropertyNative) FOOTPRINT::GetProperty;
%rename(SetPropertiesNative) FOOTPRINT::SetProperties;
%rename(MODULE_3D_SETTINGS_VECTOR3D) MODULE_3D_SETTINGS::VECTOR3D;
%feature("flatnested");
@ -66,6 +67,13 @@
properties = self.GetPropertiesNative()
return {str(k): str(v) for k, v in properties.items()}
def GetProperty(self, key):
""" Returns property with a given key if it exists, throws KeyError otherwise. """
if self.HasProperty(key):
return self.GetPropertyNative(key)
else:
raise KeyError("Property not found: " + key)
def SetProperties(self, properties):
""" Sets footprint properties map. """
wxproperties = MAP_STRING_STRING()