From 44b07b6c6b6c8a63930837aa533b65c7a48ae844 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Thu, 19 May 2016 12:02:08 +0200 Subject: [PATCH] Add update_texture_nodes_maps to manage.py --- pillar/manage.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pillar/manage.py b/pillar/manage.py index f33ece69..eb5105dd 100755 --- a/pillar/manage.py +++ b/pillar/manage.py @@ -740,5 +740,24 @@ def update_texture_node_type(): {'_id': project['_id']}, project) +@manager.command +def update_texture_nodes_maps(): + """Update abbreviated texture map types to the extended version""" + nodes_collection = app.data.driver.db['nodes'] + remap = { + 'col': 'color', + 'spec': 'specular', + 'nor': 'normal'} + for node in nodes_collection.find({'node_type': 'texture'}): + for v in node['properties']['files']: + try: + updated_map_types = remap[v['map_type']] + print("Updating {} to {}".format(v['map_type'], updated_map_types)) + v['map_type'] = updated_map_types + except KeyError: + print("Skipping {}".format(v['map_type'])) + nodes_collection.update({'_id': node['_id']}, node) + + if __name__ == '__main__': manager.run()