-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Henri Rosten <[email protected]>
- Loading branch information
1 parent
408704a
commit 8dd6755
Showing
6 changed files
with
76 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-FileCopyrightText: 2022-2023 Technology Innovation Institute (TII) | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
"""Cache nixpkgs meta information""" | ||
|
||
from dfdiskcache import DataFrameDiskCache | ||
|
||
from common.utils import ( | ||
LOG, | ||
df_from_csv_file, | ||
) | ||
|
||
############################################################################### | ||
|
||
_NIXMETA_CSV_URL = "https://github.com/henrirosten/nixmeta/raw/main/data/nixmeta.csv" | ||
_NIXMETA_CSV_URL_TTL = 60 * 60 * 24 | ||
|
||
############################################################################### | ||
|
||
|
||
class NixMeta: | ||
"""Cache nixpkgs meta information""" | ||
|
||
def __init__(self): | ||
LOG.debug("") | ||
self.cache = DataFrameDiskCache() | ||
self.df_nixmeta = self.cache.get(_NIXMETA_CSV_URL) | ||
if self.df_nixmeta is None: | ||
LOG.debug("nixmeta cache miss, downloading: %s", _NIXMETA_CSV_URL) | ||
self.df_nixmeta = df_from_csv_file(_NIXMETA_CSV_URL) | ||
self.cache.set(_NIXMETA_CSV_URL, self.df_nixmeta, ttl=_NIXMETA_CSV_URL_TTL) | ||
else: | ||
LOG.debug("read nixmeta from cache") | ||
|
||
def get_df(self): | ||
"""Return nix meta information as pandas dataframe""" | ||
return self.df_nixmeta | ||
|
||
|
||
############################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters