def METHOD_NAME(self, *args, **kwargs):
    path = kwargs["path"]
    upload_to_s3 = kwargs["upload_to_s3"]
    semesters = get_semesters(kwargs["semesters"], verbose=True)
    if len(semesters) == 0:
        raise ValueError("No semesters provided for registration export.")
    assert path.endswith(".csv") or path == os.devnull
    script_print_path = ("s3://penn.courses/" if upload_to_s3 else "") + path
    print(
        f"Generating {script_print_path} with registration data from "
        f"semesters {semesters}..."
    )
    rows = 0
    output_file_path = "/tmp/export_anon_registrations.csv" if upload_to_s3 else path
    with open(output_file_path, "w") as output_file:
        csv_writer = csv.writer(
            output_file, delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL
        )
        for registration in tqdm(
            Registration.objects.filter(
                section__course__semester__in=semesters,
                section__course__full_code__startswith=kwargs["courses_query"],
            ).annotate(
                efficient_semester=F("section__course__semester"),
                section_full_code=F("section__full_code"),
            )
        ):
            resubscribed_from_id = (
                str(registration.resubscribed_from_id)
                if registration.resubscribed_from is not None
                else ""
            )
            original_created_at = (
                registration.original_created_at.strftime("%Y-%m-%d %H:%M:%S.%f %Z")
                if registration.original_created_at is not None
                else ""
            )
            notification_sent_at = (
                registration.notification_sent_at.strftime("%Y-%m-%d %H:%M:%S.%f %Z")
                if registration.notification_sent_at is not None
                else ""
            )
            cancelled_at = (
                registration.cancelled_at.strftime("%Y-%m-%d %H:%M:%S.%f %Z")
                if registration.cancelled_at is not None
                else ""
            )
            deleted_at = (
                registration.deleted_at.strftime("%Y-%m-%d %H:%M:%S.%f %Z")
                if registration.deleted_at is not None
                else ""
            )
            rows += 1
            csv_writer.writerow(
                [
                    str(field)
                    for field in [
                        registration.section_full_code,
                        registration.efficient_semester,
                        registration.created_at.strftime("%Y-%m-%d %H:%M:%S.%f %Z"),
                        original_created_at,
                        registration.id,
                        resubscribed_from_id,
                        registration.notification_sent,
                        notification_sent_at,
                        registration.cancelled,
                        cancelled_at,
                        registration.deleted,
                        deleted_at,
                    ]
                ]
            )
            if rows % 5000 == 0:
                output_file.flush()
    if upload_to_s3:
        S3_resource.meta.client.upload_file(output_file_path, "penn.courses", path)
        os.remove(output_file_path)
    print(f"Generated {script_print_path} with {rows} rows.")