def get_result_list(query_str):

    query_str = shared.format_query_str(query_str)
    query = get_query_object(query_str)
    results = []

    if not query:
        return results

    prefs = shared.get_prefs()
    bible = shared.get_bible_data(prefs['language'])
    chapters = shared.get_chapter_data()
    matching_books = get_matching_books(bible['books'], query)

    if 'chapter' not in query:
        query['chapter'] = 1

    chosen_version = choose_best_version(prefs, bible, query)

    # Build result list from books matching the query
    for book in matching_books:

        # Skip result if given chapter exceeds number of chapters in book
        if query['chapter'] > chapters[book['id']]:
            continue

        # Result information
        results.append(get_result(book, query, chosen_version))

    return results
def get_result_list(query_str):

    query_str = shared.format_query_str(query_str)
    query = get_query_object(query_str)
    results = []

    if not query:
        return results

    prefs = shared.get_prefs()
    bible = shared.get_bible_data(prefs['language'])
    chapters = shared.get_chapter_data()
    matching_books = get_matching_books(bible['books'], query)

    if 'chapter' not in query:
        query['chapter'] = 1

    chosen_version = choose_best_version(prefs, bible, query)

    # Build result list from books matching the query
    for book in matching_books:

        # Skip result if given chapter exceeds number of chapters in book
        if query['chapter'] > chapters[book['id']]:
            continue

        # Result information
        results.append(get_result(book, query, chosen_version))

    return results
def set_pref(key, value):

    prefs = shared.get_prefs()
    prefs[key] = value

    if key == 'language':
        bible = shared.get_bible_data(language=value)
        # Set version to default version of new language
        prefs['version'] = bible['default_version']

    shared.update_prefs(prefs)