# Path: scalymongo/connection.py
# class Connection(MongoClient):
#     """A connection to a MongoDB database.
# 
#     This is a wrapper for a :class:`pymongo.mongo_client.MongoClient`.
# 
#     """
# 
#     def connect_document(self, document):
#         """Connect a document by creating a new type and injecting the
#         connection.
# 
#         """
#         attrs = {
#             'connection': self,
#             'database': self[document.__database__],
#             'collection': self[document.__database__][document.__collection__],
#         }
#         return type('Connected{0}'.format(document.__name__),
#                     (document,),
#                     attrs)
# 
#     @property
#     def models(self):
#         return DocumentProxy(self, get_concrete_classes())


from optparse import OptionParser
from scalymongo.connection import Connection

    """
    parser = OptionParser()
    parser.usage = '%prog [options] MODULE ENDPOINT'
    parser.add_option(
        '--background', action='store_true',
        help='create indexes as a non-blocking operation [default]',
    )
    parser.add_option(
        '--no-background', action='store_false', dest='background',
        help='disable background index creation',
    )
    parser.set_defaults(background=True)

    options, arguments = parser.parse_args()

    if len(arguments) != 2:
        parser.print_help()
        exit(1)

    module_name, endpoint = arguments
    return options, module_name, endpoint


def main():
    options, module_name, endpoint = parse_arguments()

    # Import the models so that they get registered with Connection.
    __import__(module_name)


# Path: scalymongo/connection.py
# class Connection(MongoClient):
#     """A connection to a MongoDB database.
# 
#     This is a wrapper for a :class:`pymongo.mongo_client.MongoClient`.
# 
#     """
# 
#     def connect_document(self, document):
#         """Connect a document by creating a new type and injecting the
#         connection.
# 
#         """
#         attrs = {
#             'connection': self,
#             'database': self[document.__database__],
#             'collection': self[document.__database__][document.__collection__],
#         }
#         return type('Connected{0}'.format(document.__name__),
#                     (document,),
#                     attrs)
# 
#     @property
#     def models(self):
#         return DocumentProxy(self, get_concrete_classes())


# Path: scalymongo/manage/ensure_indexes.py
from optparse import OptionParser
from scalymongo.connection import Connection


    """
    parser = OptionParser()
    parser.usage = '%prog [options] MODULE ENDPOINT'
    parser.add_option(
        '--background', action='store_true',
        help='create indexes as a non-blocking operation [default]',
    )
    parser.add_option(
        '--no-background', action='store_false', dest='background',
        help='disable background index creation',
    )
    parser.set_defaults(background=True)

    options, arguments = parser.parse_args()

    if len(arguments) != 2:
        parser.print_help()
        exit(1)

    module_name, endpoint = arguments
    return options, module_name, endpoint


def main():
    options, module_name, endpoint = parse_arguments()

    # Import the models so that they get registered with Connection.
    __import__(module_name)


    connection = Connection(endpoint)