# Path: submit/models.py
# class BuildFile(BasicBase, Base):
# class Class(BasicBase, Base):
# class ExecutionFile(BasicBase, Base):
# class File(BasicBase, Base):
# class FileVerifier(BasicBase, Base):
# class Group(BasicBase, Base):
# class GroupRequest(BasicBase, Base):
# class VerificationResults(object):
# class PasswordReset(Base):
# class Project(BasicBase, Base):
# class Submission(BasicBase, Base):
# class SubmissionToFile(Base):
# class TestCase(BasicBase, Base):
# class TestCaseResult(Base):
# class Testable(BasicBase, Base):
# class TestableResult(BasicBase, Base):
# class User(UserMixin, BasicBase, Base):
# class UserToGroup(Base):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def __repr__(self):
#     def __str__(self):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def is_admin(self, user):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def fetch_or_create(data, base_path, sha1sum=None):
#     def file_path(base_path, sha1sum):
#     def __init__(self, base_path, data, sha1):
#     def can_view(self, user):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def verify(self, base_path, file_):
#     def has_consent(self):
#     def users(self):
#     def users_str(self):
#     def __lt__(self, other):
#     def can_view(self, user):
#     def can_access(self, user):
#     def can_edit(self, user):
#     def errors(self):
#     def extra_filenames(self):
#     def warnings(self):
#     def __init__(self):
#     def __str__(self):
#     def missing_testables(self):
#     def set_errors_for_filename(self, errors, filename):
#     def set_extra_filenames(self, filenames):
#     def set_warnings_for_filename(self, warnings, filename):
#     def fetch_by(cls, **kwargs):
#     def generate(cls, user):
#     def get_token(self):
#     def delay(self):
#     def is_ready(self):
#     def student_submissions(self):
#     def __cmp__(self, other):
#     def build_files_json(self):
#     def can_access(self, user):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def execution_files_json(self):
#     def file_verifiers_json(self):
#     def points_possible(self, include_hidden=False):
#     def process_submissions(self):
#     def recent_submissions(self):
#     def submit_string(self):
#     def testables_json(self):
#     def verify_submission(self, base_path, submission, update):
#     def is_late(self):
#     def earlier_submission_for_group(submission):
#     def later_submission_for_group(submission):
#     def merge_dict(d1, d2, on_collision):
#     def most_recent_submission(project, group):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def file_mapping(self):
#     def get_delay(self, update):
#     def points(self, include_hidden=False):
#     def testables_pending(self, prune=False):
#     def testables_succeeded(self):
#     def time_score(self, request, group=False, admin=False):
#     def verify(self, base_path, update=False):
#     def __cmp__(self, other):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=False):
#     def serialize(self):
#     def fetch_by_ids(cls, submission_id, test_case_id):
#     def update(self, data):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#         def ids(item):
#     def points(self):
#     def requires_file(self, filename):
#     def update_points(self):
#     def fetch_or_create(make_results, status, **kwargs):
#     def get_value(cls, value):
#     def login(username, password, development_mode=False):
#     def __cmp__(self, other):
#     def __repr__(self):
#     def __str__(self):
#     def can_join_group(self, project):
#     def can_view(self, user):
#     def classes_can_admin(self):
#     def group_with(self, to_user, project, bypass_limit=False):
#     def fetch_group_assoc(self, project):
#     def make_submission(self, project):
#     def user_count(self):
#     def __eq__(self, other):
# def configure_sql(engine):
# def create_schema(alembic_config_ini=None):
# def populate_database():


from submit.models import User, Session
from pyramid.paster import get_appsettings, setup_logging
from sqlalchemy import engine_from_config
from datetime import datetime
import os
import pytz
import sys
import transaction
                continue
            _, last, first, email, cdate, _, _, _ = line.split(',')
            people.append({'last': last.strip().lower(),
                           'first': first.strip().lower(),
                           'email': email.strip().lower(),
                           'consent_date': cdate})
    return people


def main():
    if len(sys.argv) != 3:
        usage(sys.argv)
    config_uri = sys.argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    Session.configure(bind=engine)

    people = fetch_consent_data(sys.argv[2])
    by_email = {}
    for user in people:
        email = user['email']
        if email in by_email:
            if to_date(user) > by_email[email]:
                continue
        by_email[email] = to_date(user)
    matched = {}
    total = len(by_email)

    # Attempt to match by email

# Path: submit/models.py
# class BuildFile(BasicBase, Base):
# class Class(BasicBase, Base):
# class ExecutionFile(BasicBase, Base):
# class File(BasicBase, Base):
# class FileVerifier(BasicBase, Base):
# class Group(BasicBase, Base):
# class GroupRequest(BasicBase, Base):
# class VerificationResults(object):
# class PasswordReset(Base):
# class Project(BasicBase, Base):
# class Submission(BasicBase, Base):
# class SubmissionToFile(Base):
# class TestCase(BasicBase, Base):
# class TestCaseResult(Base):
# class Testable(BasicBase, Base):
# class TestableResult(BasicBase, Base):
# class User(UserMixin, BasicBase, Base):
# class UserToGroup(Base):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def __repr__(self):
#     def __str__(self):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def is_admin(self, user):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def fetch_or_create(data, base_path, sha1sum=None):
#     def file_path(base_path, sha1sum):
#     def __init__(self, base_path, data, sha1):
#     def can_view(self, user):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#     def verify(self, base_path, file_):
#     def has_consent(self):
#     def users(self):
#     def users_str(self):
#     def __lt__(self, other):
#     def can_view(self, user):
#     def can_access(self, user):
#     def can_edit(self, user):
#     def errors(self):
#     def extra_filenames(self):
#     def warnings(self):
#     def __init__(self):
#     def __str__(self):
#     def missing_testables(self):
#     def set_errors_for_filename(self, errors, filename):
#     def set_extra_filenames(self, filenames):
#     def set_warnings_for_filename(self, warnings, filename):
#     def fetch_by(cls, **kwargs):
#     def generate(cls, user):
#     def get_token(self):
#     def delay(self):
#     def is_ready(self):
#     def student_submissions(self):
#     def __cmp__(self, other):
#     def build_files_json(self):
#     def can_access(self, user):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def execution_files_json(self):
#     def file_verifiers_json(self):
#     def points_possible(self, include_hidden=False):
#     def process_submissions(self):
#     def recent_submissions(self):
#     def submit_string(self):
#     def testables_json(self):
#     def verify_submission(self, base_path, submission, update):
#     def is_late(self):
#     def earlier_submission_for_group(submission):
#     def later_submission_for_group(submission):
#     def merge_dict(d1, d2, on_collision):
#     def most_recent_submission(project, group):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def can_view(self, user):
#     def file_mapping(self):
#     def get_delay(self, update):
#     def points(self, include_hidden=False):
#     def testables_pending(self, prune=False):
#     def testables_succeeded(self):
#     def time_score(self, request, group=False, admin=False):
#     def verify(self, base_path, update=False):
#     def __cmp__(self, other):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=False):
#     def serialize(self):
#     def fetch_by_ids(cls, submission_id, test_case_id):
#     def update(self, data):
#     def __cmp__(self, other):
#     def can_edit(self, user):
#     def edit_json(self, jsonify=True):
#         def ids(item):
#     def points(self):
#     def requires_file(self, filename):
#     def update_points(self):
#     def fetch_or_create(make_results, status, **kwargs):
#     def get_value(cls, value):
#     def login(username, password, development_mode=False):
#     def __cmp__(self, other):
#     def __repr__(self):
#     def __str__(self):
#     def can_join_group(self, project):
#     def can_view(self, user):
#     def classes_can_admin(self):
#     def group_with(self, to_user, project, bypass_limit=False):
#     def fetch_group_assoc(self, project):
#     def make_submission(self, project):
#     def user_count(self):
#     def __eq__(self, other):
# def configure_sql(engine):
# def create_schema(alembic_config_ini=None):
# def populate_database():


# Path: scripts/import_consent_dates.py
from submit.models import User, Session
from pyramid.paster import get_appsettings, setup_logging
from sqlalchemy import engine_from_config
from datetime import datetime
import os
import pytz
import sys
import transaction

                continue
            _, last, first, email, cdate, _, _, _ = line.split(',')
            people.append({'last': last.strip().lower(),
                           'first': first.strip().lower(),
                           'email': email.strip().lower(),
                           'consent_date': cdate})
    return people


def main():
    if len(sys.argv) != 3:
        usage(sys.argv)
    config_uri = sys.argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    Session.configure(bind=engine)

    people = fetch_consent_data(sys.argv[2])
    by_email = {}
    for user in people:
        email = user['email']
        if email in by_email:
            if to_date(user) > by_email[email]:
                continue
        by_email[email] = to_date(user)
    matched = {}
    total = len(by_email)

    # Attempt to match by email

    for user in User.query_by().order_by(User.name).all():