# Path: submit/exceptions.py
# class GroupWithException(SubmitException):
# 
#     """Indicates there are too many users to join a group."""
# 
# Path: submit/helpers.py
# def alphanum_key(string):
#     """Return a comparable tuple with extracted number segments.
# 
#     Adapted from: http://stackoverflow.com/a/2669120/176978
# 
#     """
#     convert = lambda text: int(text) if text.isdigit() else text
#     return [convert(segment) for segment in re.split('([0-9]+)', string)]


import errno
import json
import os
import re
import sys
import transaction
import uuid
    import builtins
        import pprint
from datetime import datetime, timedelta
from hashlib import sha1
from pyramid_addons.helpers import UTC
from sqla_mixins import BasicBase, UserMixin
from sqlalchemy import (Binary, Boolean, Column, DateTime, Enum, ForeignKey,
                        Integer, PickleType, String, Table, Unicode,
                        UnicodeText, and_, func)
from sqlalchemy.exc import IntegrityError, OperationalError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relationship, scoped_session, sessionmaker
from sqlalchemy.schema import UniqueConstraint
from zope.sqlalchemy import ZopeTransactionExtension
from .exceptions import GroupWithException
from .helpers import alphanum_key
        from alembic.config import Config
        from alembic import command
    'testable_to_file_verifier', Base.metadata,
    Column('testable_id', Integer, ForeignKey('testable.id'),
           primary_key=True),
    Column('file_verifier_id', Integer, ForeignKey('fileverifier.id'),
           primary_key=True))

user_to_class = Table(
    'user_to_class', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('class_id', Integer, ForeignKey('class.id'), primary_key=True))

user_to_class_admin = Table(
    'user_to_class_admin', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('class_id', Integer, ForeignKey('class.id'), primary_key=True))

user_to_file = Table(
    'user_to_file', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('file_id', Integer, ForeignKey('file.id'), primary_key=True))


class BuildFile(BasicBase, Base):
    __table_args__ = (UniqueConstraint('filename', 'project_id'),)
    file = relationship('File', backref='build_files')
    file_id = Column(Integer, ForeignKey('file.id'), nullable=False)
    filename = Column(Unicode, nullable=False)
    project_id = Column(Integer, ForeignKey('project.id'), nullable=False)

    def __cmp__(self, other):

# Path: submit/exceptions.py
# class GroupWithException(SubmitException):
# 
#     """Indicates there are too many users to join a group."""
# 
# Path: submit/helpers.py
# def alphanum_key(string):
#     """Return a comparable tuple with extracted number segments.
# 
#     Adapted from: http://stackoverflow.com/a/2669120/176978
# 
#     """
#     convert = lambda text: int(text) if text.isdigit() else text
#     return [convert(segment) for segment in re.split('([0-9]+)', string)]


# Path: submit/models.py
import errno
import json
import os
import re
import sys
import transaction
import uuid
    import builtins
        import pprint
from datetime import datetime, timedelta
from hashlib import sha1
from pyramid_addons.helpers import UTC
from sqla_mixins import BasicBase, UserMixin
from sqlalchemy import (Binary, Boolean, Column, DateTime, Enum, ForeignKey,
                        Integer, PickleType, String, Table, Unicode,
                        UnicodeText, and_, func)
from sqlalchemy.exc import IntegrityError, OperationalError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relationship, scoped_session, sessionmaker
from sqlalchemy.schema import UniqueConstraint
from zope.sqlalchemy import ZopeTransactionExtension
from .exceptions import GroupWithException
from .helpers import alphanum_key
        from alembic.config import Config
        from alembic import command

    'testable_to_file_verifier', Base.metadata,
    Column('testable_id', Integer, ForeignKey('testable.id'),
           primary_key=True),
    Column('file_verifier_id', Integer, ForeignKey('fileverifier.id'),
           primary_key=True))

user_to_class = Table(
    'user_to_class', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('class_id', Integer, ForeignKey('class.id'), primary_key=True))

user_to_class_admin = Table(
    'user_to_class_admin', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('class_id', Integer, ForeignKey('class.id'), primary_key=True))

user_to_file = Table(
    'user_to_file', Base.metadata,
    Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
    Column('file_id', Integer, ForeignKey('file.id'), primary_key=True))


class BuildFile(BasicBase, Base):
    __table_args__ = (UniqueConstraint('filename', 'project_id'),)
    file = relationship('File', backref='build_files')
    file_id = Column(Integer, ForeignKey('file.id'), nullable=False)
    filename = Column(Unicode, nullable=False)
    project_id = Column(Integer, ForeignKey('project.id'), nullable=False)

    def __cmp__(self, other):

        return cmp(alphanum_key(self.filename), alphanum_key(other.filename))