code: def format_snippet(sensor_graph):
      output = []
      output.append("disable")
      output.append("clear")
      output.append("reset")
      for node in sensor_graph.dump_nodes():
          output.append('add_node "{}"'.format(node))
      for streamer in sensor_graph.streamers:
          line = "add_streamer '{}' '{}' {} {} {}".format(streamer.selector, streamer.dest, streamer.automatic, streamer.format, streamer.report_type)
          if streamer.with_other is not None:
              line += ' --withother {}'.format(streamer.with_other)
          output.append(line)
      for stream, value in sorted(sensor_graph.constant_database.items(), key=lambda x: x[0].encode()):
          output.append("set_constant '{}' {}".format(stream, value))
      output.append("persist")
      output.append("back")
      app_tag = sensor_graph.metadata_database.get('app_tag')
      app_version = sensor_graph.metadata_database.get('app_version')
      if app_tag is not None:
          if app_version is None:
              app_version = "0.0"
          output.append("test_interface")
          output.append("set_version app %d --version '%s'" % (app_tag, app_version))
          output.append("back")
      output.append("config_database")
      output.append("clear_variables")
      for slot, conf_vars in sensor_graph.config_database.items():
          for conf_var, conf_def in conf_vars.items():
              conf_type, conf_val = conf_def
              if conf_type == 'binary':
                  conf_val = 'hex:' + hexlify(conf_val)
              elif isinstance(conf_val, str):
                  conf_val = '"%s"' % conf_val
              output.append("set_variable '{}' {} {} {}".format(slot, conf_var, conf_type, conf_val))
      output.append("back")
      output.append("reset")
      return "\n".join(output) + '\n'