diff --git a/pyproject.toml b/pyproject.toml index 4a73736..638df78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "githubdata" -version = "16.0.0" +version = "16.1.0" authors = [{ name = "Mahdi Mir", email = "imahdimir@gmail.com" }] description = "A simple Python package to easily download from and manage a GitHub \"Data repository\"" readme = "README.md" diff --git a/src/githubdata/__init__.py b/src/githubdata/__init__.py index d3fef45..502aa19 100644 --- a/src/githubdata/__init__.py +++ b/src/githubdata/__init__.py @@ -1,4 +1,7 @@ from .github_data_repo import default_githubdata_dir from .github_data_repo import GitHubDataRepo from .utils import clone_overwrite_a_repo__ret_gdr_obj +from .utils import commit_and_push_by_u_repo from .utils import get_data_wo_double_clone +from .utils import make_data_fn +from .utils import upload_2_github diff --git a/src/githubdata/utils.py b/src/githubdata/utils.py index 38c0dec..88b81ba 100644 --- a/src/githubdata/utils.py +++ b/src/githubdata/utils.py @@ -26,3 +26,21 @@ def clone_overwrite_a_repo__ret_gdr_obj(gd_url) : gdr = GitHubDataRepo(gd_url) gdr.clone_overwrite() return gdr + +def commit_and_push_by_u_repo(gdr: GitHubDataRepo) : + msg = 'Updated by associated \"u-\" repo/code' + gdr.commit_and_push(msg) + +def upload_2_github(df , fn: str , gdr: GitHubDataRepo) : + if hasattr(gdr , "data_fp") : + dfp = gdr.data_fp + dfp.unlink() + + nfp = gdr.local_path / fn + + df.to_parquet(nfp , index = False) + + commit_and_push_by_u_repo(gdr) + +def make_data_fn(dn , iso_date) : + return "{}_{}.parquet".format(dn , iso_date)