-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Export cache directory and rest url functions * update package meta
- Loading branch information
Showing
22 changed files
with
157 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
[metadata] | ||
name = gypsum-client | ||
description = Python cline to gypsum | ||
description = Python client to gypsum REST API | ||
author = Jayaram Kancherla | ||
author_email = [email protected] | ||
license = MIT | ||
|
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
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,52 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
__author__ = "Jayaram Kancherla" | ||
__copyright__ = "Jayaram Kancherla" | ||
__license__ = "MIT" | ||
|
||
CURRENT_CACHE_DIRECTORY = None | ||
|
||
|
||
def cache_directory(dir: Optional[str] = None): | ||
"""Cache directory. | ||
Specify the cache directory in the local filesystem | ||
for gypsum-related data. | ||
If the ``GYPSUM_CACHE_DIR`` environment variable is set | ||
before the first call to ``cache_directory()``, it is used | ||
as the initial location of the cache directory. | ||
Otherwise, the initial location is set to user's home | ||
directory defined by ``Path.home()``. | ||
Args: | ||
dir: | ||
Path to the cache directory. | ||
If `None`, a default cache location is used. | ||
Returns: | ||
Path to the cache directory. | ||
""" | ||
global CURRENT_CACHE_DIRECTORY | ||
|
||
if CURRENT_CACHE_DIRECTORY is None: | ||
_from_env = os.environ.get("GYPSUM_CACHE_DIR", None) | ||
if _from_env is not None: | ||
if not os.path.exists(_from_env): | ||
raise FileNotFoundError( | ||
f"Path {_from_env} does not exist or is not accessible." | ||
) | ||
|
||
CURRENT_CACHE_DIRECTORY = _from_env | ||
else: | ||
CURRENT_CACHE_DIRECTORY = os.path.join(str(Path.home()), "gypsum", "cache") | ||
os.makedirs(CURRENT_CACHE_DIRECTORY, exist_ok=True) | ||
|
||
if dir is not None: | ||
if not os.path.exists(dir): | ||
raise FileNotFoundError(f"Path {dir} does not exist or is not accessible.") | ||
CURRENT_CACHE_DIRECTORY = dir | ||
|
||
return CURRENT_CACHE_DIRECTORY |
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
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
Oops, something went wrong.