<commit_before>import logging

import dropbox

from .drobpox_utils import (
    filepaths_from_metadata,
    dicts_from_pairs,
)
from moonreader_tools.books import Book
from moonreader_tools.utils import (
    get_moonreader_files_from_filelist,
    get_same_book_files
)


class DropboxDownloader(object):
    """Class to obtain bookdata from dropbox syncronized account"""
    DEFAULT_DROPBOX_PATH = 'Books/.Moon+/Cache'

    def __init__(self, access_token,
                 books_path="",
                 workers=8,
                 logger=None):
        if not access_token:
            raise ValueError("Access token must be specified.")
        if not books_path:
            books_path = DropboxDownloader.DEFAULT_DROPBOX_PATH
        self.access_token = access_token
        self.books_path = books_path
        self.workers = workers
        self.logger = logger if logger else logging.getLogger(__name__)

    def get_books(self, path="", book_count=None):
        """Obtains book objects from dropbox folder"""
        if not path and not self.books_path:
            raise ValueError("Path to read data from is not specified")
        if not path:
            path = self.books_path

        client = dropbox.client.DropboxClient(self.access_token)
        meta = client.metadata(path)
        files = filepaths_from_metadata(meta)
        moonreader_files = get_moonreader_files_from_filelist(files)

        if book_count is not None:
            file_pairs = get_same_book_files(moonreader_files)[:book_count]
        else:
            file_pairs = get_same_book_files(moonreader_files)
<commit_msg>Extra doc-strings added.<commit_after>import logging

import dropbox

from .drobpox_utils import (
    filepaths_from_metadata,
    dicts_from_pairs,
)
from moonreader_tools.books import Book
from moonreader_tools.utils import (
    get_moonreader_files_from_filelist,
    get_same_book_files
)


class DropboxDownloader(object):
    """Class to obtain bookdata from dropbox syncronized account"""
    DEFAULT_DROPBOX_PATH = 'Books/.Moon+/Cache'

    def __init__(self, access_token,
                 books_path="",
                 workers=8,
                 logger=None):
        """

        :param access_token: Dropbox access token
        :param books_path: Absolute path to dropbox's \
        dir with syncronized notes
        :param workers: number of concurrent workers to download\
        data from Dropbox
        :param logger: class responsible for logging
        """
        if not access_token:
            raise ValueError("Access token must be specified.")
        if not books_path:
            books_path = DropboxDownloader.DEFAULT_DROPBOX_PATH
        self.access_token = access_token
        self.books_path = books_path
        self.workers = workers
        self.logger = logger if logger else logging.getLogger(__name__)

    def get_books(self, path="", book_count=None):
        """Obtains book objects from dropbox folder
        :param path: Dropbox directory with syncronized\
        book data
        :param book_count: number of books to read
        """
        if not path and not self.books_path:
            raise ValueError("Path to read data from is not specified")
        if not path:
            path = self.books_path

        client = dropbox.client.DropboxClient(self.access_token)
        meta = client.metadata(path)
        files = filepaths_from_metadata(meta)
        moonreader_files = get_moonreader_files_from_filelist(files)

        if book_count is not None:
            file_pairs = get_same_book_files(moonreader_files)[:book_count]
        else:
            file_pairs = get_same_book_files(moonreader_files)

{'fraction_non_alphanumeric': 0.06722689075630252, 'fraction_numerical': 0.0005421523448088912, 'mean_word_length': 2.63905325443787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '392920', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1029, 'n_words': 269}