def handle(self, *args, **options):
        quiet = options.get('quiet', False)
        if not quiet:
            self.stdout.write("Export of DMS MDT's command called.\n")

        # Try and Fetch all mdts
        manager = MetaDataTemplateManager()
        mdts = manager.get_all_mdts()
        # Validating all OK
        if not mdts:
            if not quiet:
                self.stderr.write('DMS has no MDT-s.')
            return

        for mdt_link in mdts.itervalues():

            filename = mdt_link['mdt_id']
            mdt_instance = manager.get_mdts_by_name([filename, ])
            filename += '.json'
            file_obj = open(os.path.join(filename), 'w+')
            file_obj.seek(0)
            mdt_obj = mdt_instance['1']
            try:
                del mdt_obj["doc_type"]
            except __HOLE__:
                pass
            mdt_jsoned = json.dumps(mdt_obj, sort_keys=True, indent=4)
            file_obj.write(mdt_jsoned)
            if not quiet:
                self.stderr.write('Exported to file: %s\n'% filename)

        if not quiet:
            self.stdout.write("Exporting %s MDT's" % str(len(mdts)))
            self.stdout.write('\n')
dataset/ETHPy150Open adlibre/Adlibre-DMS/adlibre_dms/couchapps/mdtcouch/management/commands/export_mdts.py/Command.handle