sensordatahandler: Support empty inventory interfaces

This commit adds support for empty inventory interfaces when
asserting a sensor into the inventory. This is something already
supported in ipmi-fru-parser, for example.

Currently, the notify::assertion function expects that each DBUS
interface also have a set of associated properties. One of the
use-cases this commit tries to solve is when a sensor being asserted
maps to an inventory item (accessed via
xyz.openbmc_project.Inventory.Manager DBUS service) that implements
a DBUS interface with no properties. For example, the GPU sensor
is mapped to a GPU inventory object that implements the DBUS
interface xyz.openbmc_project.Inventory.Item.Accelerator.
This commit enables phosphor-host-ipmid to correctly create/update
inventory objects even in cases where they implement DBUS interfaces
that contain no properties.

The sensor-example.yaml file has been updated to show an example
of a GPU sensor, the inventory object for which implements a
property-less DBUS interface.

Tested:

Tested on a witherspoon system that had some GPUs attached to it.
Pulled also https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/21107
in order to generate the right sensor configs for testing.
Verified that the GPU invetory objects that are created when the host
asserts a GPU sensor now implement the empty interface
xyz.openbmc_project.Inventory.Item.Accelerator

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: I973580e285ae0fff1a513d3bbe8c03a89e0eeb83
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 559f0f9..192b858 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -74,67 +74,69 @@
         ${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
     % for interface,properties in interfaces.items():
             {"${interface}",{
-            % for dbus_property,property_value in properties.items():
-                {"${dbus_property}",{
+            % if properties:
+                % for dbus_property,property_value in properties.items():
+                    {"${dbus_property}",{
 <%
 try:
     preReq = property_value["Prereqs"]
 except KeyError, e:
     preReq = dict()
 %>\
-                {
-                    % for preOffset,preValues in preReq.items():
-                    { ${preOffset},{
-                        % for name,value in preValues.items():
-                            % if name == "type":
+                    {
+                        % for preOffset,preValues in preReq.items():
+                        { ${preOffset},{
+                            % for name,value in preValues.items():
+                                % if name == "type":
 <%                              continue %>\
-                            % endif
+                                % endif
 <%                          value = str(value).lower() %>\
-                            ${value},
+                                ${value},
+                            % endfor
+                            }
+                        },
                         % endfor
-                        }
                     },
-                    % endfor
-                },
-                {
-                % for offset,values in property_value["Offsets"].items():
-                    { ${offset},{
-                        % if offset == 0xFF:
-                            }},
+                    {
+                    % for offset,values in property_value["Offsets"].items():
+                        { ${offset},{
+                            % if offset == 0xFF:
+                                }},
 <%                          continue %>\
-                        % endif
+                            % endif
 <%                          valueType = values["type"] %>\
 <%
 try:
     skip = values["skipOn"]
     if skip == "assert":
-         skipVal = "SkipAssertion::ASSERT"
+        skipVal = "SkipAssertion::ASSERT"
     elif skip == "deassert":
-         skipVal = "SkipAssertion::DEASSERT"
+        skipVal = "SkipAssertion::DEASSERT"
     else:
-         assert "Unknown skip value " + str(skip)
+        assert "Unknown skip value " + str(skip)
 except KeyError, e:
     skipVal = "SkipAssertion::NONE"
 %>\
-                            ${skipVal},
-                    % for name,value in values.items():
-                        % if name == "type" or name == "skipOn":
+                                ${skipVal},
+                        % for name,value in values.items():
+                            % if name == "type" or name == "skipOn":
 <%                          continue %>\
-                        % endif
-                        % if valueType == "string":
-                           std::string("${value}"),
-                        % elif valueType == "bool":
+                            % endif
+                            % if valueType == "string":
+                            std::string("${value}"),
+                            % elif valueType == "bool":
 <%                         value = str(value).lower() %>\
-                           ${value},
-                        % else:
-                           ${value},
-                        % endif
-                     % endfor
-                        }
-                    },
+                            ${value},
+                            % else:
+                            ${value},
+                            % endif
+                        % endfor
+                            }
+                        },
+                    % endfor
+                    }}},
                 % endfor
-                }}},
-            % endfor
+            % endif
             }},
     % endfor
      },