Read Mongodb Source configuration from the provided settings

def from_settings(cls, settings):
        """Read Mongodb Source configuration from the provided settings"""
        if not 'mongodb' in settings or not 'collection' in settings or \
                settings['mongodb'] == '' or settings['collection'] == '':
            raise Exception(
                "Erroneous mongodb settings, "
                "needs a collection and mongodb setting",
                settings)

        cx_uri = urlparse.urlsplit(settings["mongodb"])
        db_name = cx_uri.path

        if '?' in db_name:
            db_name, query = db_name.split('?', 1)

        db_name = db_name[1:]

        if db_name == "":
            raise Exception(
                "Erroneous mongodb settings, "
                "missing db_name", settings)

        cx_uri = urlparse.urlunsplit(
            (cx_uri.scheme, cx_uri.netloc, "/", cx_uri.query, cx_uri.fragment))
        options = copy.deepcopy(settings)
        del options['mongodb']
        del options['collection']

        return Mongodb(
            cls.connection_for_uri(cx_uri),
            db_name, settings['collection'], options)