-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7aa4d3
commit ea990e4
Showing
12 changed files
with
243 additions
and
67 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
Binary file not shown.
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,28 @@ | ||
|
||
clear_cache Function | ||
======================= | ||
|
||
The ``clear_cache`` function deletes cache files that were saved inside .caches/evdspy folder | ||
|
||
.. code-block:: bash | ||
from evdspy import clear_cache | ||
clear_cache() | ||
If cache parameter is True this function will save time by using previously saved content in caches folder. | ||
default cache period is daily. It will only used if the previous successful request was made the current day. | ||
|
||
.. code-block:: python | ||
index = """ | ||
TP.DK.USD.A | ||
TP.DK.EUR.A | ||
TP.DK.CHF.A | ||
TP.DK.GBP.A | ||
TP.DK.JPY.A | ||
""" | ||
df = get_series(index, cache=True , start_date="01-01-2017", end_date="31-12-2017" ) | ||
print(df.head()) |
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,30 @@ | ||
import os | ||
import shutil | ||
from pathlib import Path | ||
|
||
def clear_cache_folder(cache_folder_path : Path ): | ||
if 'cache/evdspy' not in str(cache_folder_path) : | ||
|
||
print('This does not look like cache folder. I can only delete content of cache folder of evdspy package') | ||
return | ||
if not os.path.exists(cache_folder_path): | ||
print(f"The folder {cache_folder_path} does not exist.") | ||
return | ||
|
||
for filename in os.listdir(cache_folder_path): | ||
file_path = os.path.join(cache_folder_path, filename) | ||
try: | ||
if os.path.isfile(file_path) or os.path.islink(file_path): | ||
os.unlink(file_path) | ||
elif os.path.isdir(file_path): | ||
shutil.rmtree(file_path) | ||
except Exception as e: | ||
print(f"Failed to delete {file_path}. Reason: {e}") | ||
|
||
print(f"All files and subdirectories in [{cache_folder_path}] have been deleted.") | ||
|
||
|
||
def clear_cache(): | ||
from pathlib import Path | ||
cache_folder = Path.home() / ".cache" / "evdspy" | ||
clear_cache_folder(cache_folder) |
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.