New YAML world order API is not good

Today I went ahead and tried to port the bst-plugins-experimental repository to work with BuildStream 2

See: bst-plugins-experimental!3, and please observe the patch "elements/dpkg_build.py: Port to BuildStream 2 API".

My observations is that this was quite a painful process and the resulting code is quite verbose, especially with regards to Plugin.node_set_member() and Plugin.new_empty_node().

What I think would be much nicer would be to remove both of those functions, and export a public Node() object.

This would make the Plugin.node_*() APIs more intuitive and documentable by having a specific type for the Node expose, and would allow for more simple constructs, like:

from buildstream import Node

# Simple manipulation, instead of big function calls
foo = Node()
foo['key'] = 'pony'

# Convenient constructor, automatically translating dictionaries and lists into Node hierarchies
bar = Node({
  'name': pony,
  'things': [
    {
      'name': 'thing1',
      'value': 'thething'
    },
    {
      'name': 'thing2',
      'value': 'theotherthing'
    }
  ]
})

# Implement regular `items` on public `Node()` class, instead of on `Plugin`
for key, value in node.items():
   ...

It could be good to move all the Plugin.node_get_*() APIs to Node() as well, although it would be more costly to migrate existing plugins to this model (perhaps a deprecation period would make this easier).

However, the new APIs for setting the mutable public data in an Element.assemble() implementation are quite painful to use, I think this is more pressing.