Skip to content

Commit

Permalink
dotenv path problem
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Jul 31, 2024
1 parent 726df3e commit 392e67e
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 76 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Byte-compiled / optimized / DLL files
__pycache__/

*Chat*/
*chat*

SCRAT*/
scra*.py
*.ipynb
Expand Down
419 changes: 366 additions & 53 deletions Example_get_series_exp.ipynb

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions evdspy/EVDSlocal/config/apikey_class.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
from .dotenv import load_env
from ..common.common_imports import *
from dataclasses import dataclass
from typing import Union
from enum import Enum, auto
import os
import traceback

try :

from dotenv import load_dotenv
load_dotenv()
except Exception:
print("""[solution]
$ pip install python-dotenv
""")
traceback.print_exc()
raise ModuleNotFoundError()
# try :
#
# from dotenv import load_dotenv
# load_dotenv()
# except Exception:
#
# print("""[solution]
# $ pip install python-dotenv
# """)
# traceback.print_exc()
# raise ModuleNotFoundError()
from ..config.config import config

from ..messages.error_classes import ApiKeyNotSetError

"""
========================== load_env ==========================
"""
load_env()




Expand Down
26 changes: 26 additions & 0 deletions evdspy/EVDSlocal/config/dotenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import traceback

# from dotenv import load_dotenv
from pathlib import Path

try:

from dotenv import load_dotenv


def load_env(verbose=True):
"""Load environment variables from a .env file in the current directory."""
dotenv_path = Path(".") / '.env'
if verbose:
print(f"reading apikey from [{dotenv_path}]")
load_dotenv(dotenv_path)

except Exception:

print("""[solution]
$ pip install python-dotenv
""")
traceback.print_exc()

raise ModuleNotFoundError()
30 changes: 19 additions & 11 deletions evdspy/EVDSlocal/index_requests/get_series_indexes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@

import traceback

try :

from dotenv import load_dotenv
load_dotenv()
except Exception:

print("""[solution]
$ pip install python-dotenv
""")
traceback.print_exc()
raise ModuleNotFoundError()
from evdspy.EVDSlocal.config.dotenv import load_env
#
# try :
#
# from dotenv import load_dotenv
# load_dotenv()
# except Exception:
#
# print("""[solution]
# $ pip install python-dotenv
# """)
# traceback.print_exc()
# raise ModuleNotFoundError()


"""
========================== load_env ==========================
"""
load_env()


def check_env(key_name: str, default_=None):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.poetry]
name = "evdspy"
version = "1.1.34"
version = "1.1.35"
description = "A versatile interface for the 'EDDS' (EVDS) API of the Central Bank of the Republic of Türkiye (https://evds2.tcmb.gov.tr/index.php?/evds/userDocs). This package allows users to easily access and manage economic data through a user-friendly menu function. It features a robust caching mechanism to enhance the efficiency of data requests by storing frequently accessed data for selected periods. Required API keys can be obtained by registering on the EVDS website."
authors = ["Sermet Pekin <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 392e67e

Please sign in to comment.