Skip to content

Commit

Permalink
dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Jul 28, 2024
1 parent a2cd76f commit ab1c90b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
Binary file modified .github/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Byte-compiled / optimized / DLL files
__pycache__/

SCRAT*/
scra*.py


*.py[cod]
Expand Down
21 changes: 19 additions & 2 deletions evdspy/EVDSlocal/config/apikey_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class ApiKeyDict:
def __init__(self):
self.runtime_apikey = ApiKeyValue("runtime", False, ApiKeyType.runtime)
self.from_file_apikey = ApiKeyValue("fromfile", False, ApiKeyType.from_file)
self.from_file_options_api_key = ApiKeyValue("fromfile_options", False, ApiKeyType.from_file_options)
self.from_file_options_api_key = ApiKeyValue(
"fromfile_options", False, ApiKeyType.from_file_options
)

def set_value(self, type_: Union[str, ApiKeyType], value):
if type_ in ["runtime", ApiKeyType.runtime]:
Expand All @@ -45,7 +47,7 @@ def set_value(self, type_: Union[str, ApiKeyType], value):

class ApikeyClass(object):
def __new__(cls):
if not hasattr(cls, 'instance'):
if not hasattr(cls, "instance"):
cls.instance = super(ApikeyClass, cls).__new__(cls)
cls.post_init(cls)
return cls.instance
Expand Down Expand Up @@ -105,6 +107,7 @@ def key(self):
@staticmethod
def obscure(key=None):
from evdspy.EVDSlocal.utils.utils_general import encode

if key is None:
key = ApikeyClass().key
if not isinstance(key, str):
Expand All @@ -131,7 +134,21 @@ def set_api(cls, key: str):
raise "set api not implemented"

def get_api_keys(cls):
def get_env():
import os

try:
from dotenv import load_dotenv

load_dotenv()
except:
pass
api_key_env = os.getenv("EVDS_API_KEY")
api_key_env = api_key_env if len(str(api_key_env)) > 5 else False
return ApiKeyValue("dotenv", api_key_env)

keys = [
get_env(),
cls.instance.APIKEYDict.runtime_apikey,
cls.instance.APIKEYDict.from_file_apikey,
cls.instance.APIKEYDict.from_file_options_api_key,
Expand Down
6 changes: 3 additions & 3 deletions evdspy/EVDSlocal/index_requests/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def get_categories_data() -> str:
def get_table_header():
from rich.table import Table
table = Table(title="Categories / Kategoriler")
table.add_column("ID/Sayı", justify="right", style="cyan", no_wrap=True)
table.add_column("Title/Başlık (ENG)", style="magenta")
table.add_column("Title/Başlık (TR)", justify="right", style="green")
table.add_column("ID/Sayi", justify="right", style="cyan", no_wrap=True)
table.add_column("Title/Baslik (ENG)", style="magenta")
table.add_column("Title/Baslik (TR)", justify="right", style="green")
return table
from typing import List
import typing as t
Expand Down
3 changes: 2 additions & 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.29"
version = "1.1.30"
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 <sermet.pekin@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -31,6 +31,7 @@ openpyxl = ">3.0.10"
rich = ">=12.5.1"
requests = ">=2.28.1"
pytest = ">=7.0.0"
python-dotenv=">=1.0.0"
[tool.poetry.dev-dependencies]
pygments = ">=2.6.0"
commonmark = ">=0.9.0"
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pytest>=8.1.0
ruff>=0.5.1
tox
black>=24.3.0
python-dotenv>=1.0.0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ openpyxl>=3.0.10
numpy>=1.5.0
pytest>=8.1.0
black>=24.3.0
python-dotenv>=1.0.0

0 comments on commit ab1c90b

Please sign in to comment.