@staticmethod
    def fix_xforms(unique_id_to_xmlns_map, app_to_unique_ids_map, log_file, dry_run):
        total, submissions = get_submissions_without_xmlns()
        xform_db = IterDB(XFormInstance.get_db())
        with xform_db as xform_db:
            for i, xform_instance in enumerate(submissions):
                Command._print_progress(i, total)
                try:
                    unique_id = get_form_unique_id(xform_instance)
                except (MultipleFormsMissingXmlns, FormNameMismatch) as e:
                    log_file.write(e.message)
                    print e.message
                    continue

                if unique_id:
                    if unique_id_to_xmlns_map not in unique_id:
                        xmlns = get_xmlns(unique_id, xform_instance.app_id,
                                          xform_instance.domain)
                        log_file.write(xmlns_map_log_message(xmlns, unique_id))
                        unique_id_to_xmlns_map[unique_id] = xmlns

                    set_xmlns_on_submission(
                        xform_instance,
                        unique_id_to_xmlns_map[unique_id],
                        xform_db,
                        log_file,
                        dry_run,
                    )

                    key = (xform_instance.app_id, xform_instance.domain)
                    val = unique_id
                    if val not in app_to_unique_ids_map[key]:
                        log_file.write(unique_ids_map_log_message(key[0], key[1], unique_id))
                        app_to_unique_ids_map[key].add(val)

        for error_id in xform_db.error_ids:
            log_file.write("Failed to save xform {}\n".format(error_id))
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/cleanup/management/commands/fix_forms_with_missing_xmlns.py/Command.fix_xforms/swapped operands of `not in`