def METHOD_NAME(self, out, session, codes):
    codes = codes or session.query(PromoCode).all()
    out.writerow(['Code', 'Expiration Date', 'Discount', 'Uses'])
    for code in codes:
        out.writerow([
            code.code,
            code.expiration_date,
            code.discount_str,
            code.uses_allowed_str])