def add_package_data()

in src/integ_test_resources/common/scripts/device_config_builder.py [0:0]


    def add_package_data(self, all_package_data: dict, key: str, value: str) -> None:
        """
        This is a helper method used by build_package_data.
        This is called recursively to explore a nested key path, as
        described below.

        Given a key of the form /suitename/foo/bar/baz,
        /suitename/foo/bar/baz is considered to be a key-path into a
        nested dicitonary structure. The provided ssm_value is stored as
        a string in its leaf:
        {
          "suitename": {
            "foo": {
              "bar": {
                "baz": ssm_value
              }
            }
          }
        }
        """
        key = key.strip("/")
        first_slash_pos = key.find("/")
        if first_slash_pos == -1:
            # If the key didn't have a '/', its just a simple leaf, and
            # we can store the value, here.
            all_package_data[key] = value
        else:
            # Otherwise, we need to nest. Pull out the next part of the
            # path, wrap a dict, and repeat the process on the remainder
            # of the key.
            first_part = key[:first_slash_pos]
            continue_index = first_slash_pos + 1
            the_rest = key[continue_index:]
            if first_part not in all_package_data:
                all_package_data[first_part] = dict()
            self.add_package_data(all_package_data[first_part], the_rest, value)