def _cache_lookup(word, data_dir, native=False):
    """Checks if word is in cache.

    Parameters
    ----------
    word : str
        Word to check in cache.
    data_dir : pathlib.Path
        Cache directory location.

    Returns
    -------
    translation : str or None
        Translation of given word.
    """
    trans_dir = "translations"
    if native:
        trans_dir += "_native"
    logger.debug("Cache lookup: %s", word)
    filename = data_dir.joinpath(trans_dir, "{}.html".format(word))
    if filename.is_file():
        with open(filename, mode="r") as f:
            logger.debug("Cache found: %s", word)
            # TODO: not sure if we should parse data here
            translation = _parse_cached(f.read())
            return translation
    logger.debug("Cache miss: %s", word)
    return None
def _cache_lookup ( word , data_dir , native = False ) : trans_dir = "translations" if native : trans_dir += "_native" logger . debug ( "Cache lookup: %s" , word ) filename = data_dir . joinpath ( trans_dir , "{}.html" . format ( word ) ) if filename . is_file ( ) : with open ( filename , mode = "r" ) as f : logger . debug ( "Cache found: %s" , word ) translation = _parse_cached ( f . read ( ) ) return translation logger . debug ( "Cache miss: %s" , word ) return None
Checks if word is in cache.

    Parameters
    ----------
    word : str
        Word to check in cache.
    data_dir : pathlib.Path
        Cache directory location.

    Returns
    -------
    translation : str or None
        Translation of given word.