pypi_download_stats.diskdatacache module

class pypi_download_stats.diskdatacache.DiskDataCache(cache_path)[source]

Bases: object

_path_for_file(project_name, date)[source]

Generate the path on disk for a specified project and date.

Parameters:
  • project_name – the PyPI project name for the data
  • date (datetime.datetime) – the date for the data
Returns:

path for where to store this data on disk

Return type:

str

get(project, date)[source]

Get the cache data for a specified project for the specified date. Returns None if the data cannot be found in the cache.

Parameters:
  • project (str) – PyPi project name to get data for
  • date (datetime.datetime) – date to get data for
Returns:

dict of per-date data for project

Return type:

dict or None

get_dates_for_project(project)[source]

Return a list of the dates we have in cache for the specified project, sorted in ascending date order.

Parameters:project (str) – project name
Returns:list of datetime.datetime objects
Return type:datetime.datetime
set(project, date, data, data_ts)[source]

Set the cache data for a specified project for the specified date.

Parameters:
  • project (str) – project name to set data for
  • date (datetime.datetime) – date to set data for
  • data (dict) – data to cache
  • data_ts (int) – maximum timestamp in the BigQuery data table