- if output_format == 'json':
- with open('%s/%s.json' % (outdir, self.name), "w") as fh:
- fh.write(self.descriptor.to_json(model))
- elif output_format.strip() == 'xml':
+ # Need to extract the catalog part to dump as descriptor
+ if output_format in ['json', 'yaml']:
+ # Convert to yaml instead of directly using as_dict as
+ # this adds the namespaces correctly
+ ya = self.descriptor.to_yaml(model)
+ proj = yaml.load(ya)
+ desc = proj['rw-project:project'][0]
+
+ if output_format == 'json':
+ with open('%s/%s.json' % (outdir, self.name), "w") as fh:
+ fh.write(simplejson.dumps(desc, indent=4))
+ elif output_format == 'yaml':
+ with open('%s/%s.yaml' % (outdir, self.name), "w") as fh:
+ fh.write(yaml.dump(desc, default_flow_style=False))
+ elif output_format == 'xml':
+ # Converting from dict to xml does not provide the
+ # required output. So using the PBCM to_xml and then
+ # printing only from the catalog tag.