(version_cache_path: Path)
return None
Reads version cache file and returns Version stored in it
        if time cache was written was within the last day.

        Returns None if version cache is invalid for any reason
        or file does not exist
Reads version cache file and returns Version stored in it
        if time cache was written was within the last day.
Reads version cache file and returns Version stored in it if time cache was written was within the last day .
def _get_version_from_cache(version_cache_path: Path) -> Optional[Version]:
    """
        Reads version cache file and returns Version stored in it
        if time cache was written was within the last day.

        Returns None if version cache is invalid for any reason
        or file does not exist
    """
    now = time.time()
    if version_cache_path.is_file():
        with version_cache_path.open() as f:
            timestamp_str = f.readline().strip()
            latest_version_str = f.readline().strip()
            try:
                latest_version = Version(latest_version_str)
            except InvalidVersion:
                logging.debug(
                    f"Version Cache invalid version string: {latest_version_str}"
                )
                return None

            try:
                # Treat time as integer seconds so no need to deal with str float conversion
                timestamp = int(timestamp_str)
            except ValueError:
                logging.debug(f"Version Cache invalid timestamp: {timestamp_str}")
                return None

            if now - timestamp > 86400:
                logging.debug(f"Version Cache expired {timestamp}:{now}")
                return None

            logging.debug(f"Version Cache returning {latest_version}")
            return latest_version
    logging.debug("Version Cache does not exist")
    return None
def _get_version_from_cache ( version_cache_path : Path ) -> Optional [ Version ] : now = time . time ( ) if version_cache_path . is_file ( ) : with version_cache_path . open ( ) as f : timestamp_str = f . readline ( ) . strip ( ) latest_version_str = f . readline ( ) . strip ( ) try : latest_version = Version ( latest_version_str ) except InvalidVersion : logging . debug ( f"Version Cache invalid version string: {latest_version_str}" ) return None try : # Treat time as integer seconds so no need to deal with str float conversion timestamp = int ( timestamp_str ) except ValueError : logging . debug ( f"Version Cache invalid timestamp: {timestamp_str}" ) return None if now - timestamp > 86400 : logging . debug ( f"Version Cache expired {timestamp}:{now}" ) return None logging . debug ( f"Version Cache returning {latest_version}" ) return latest_version logging . debug ( "Version Cache does not exist" ) return None