Skip to content

Commit

Permalink
update python-dotenv dependecy version to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nsnguyen authored and nguyen committed Aug 1, 2023
1 parent 6e7bf4b commit b1c8ca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/dotenv_vault/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
from base64 import b64decode
import io
import os
import logging

from typing import (IO, Optional, Union)
from urllib.parse import urlparse, parse_qsl

from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.exceptions import InvalidTag
import dotenv.main as dotenv

logger = logging.getLogger(__name__)

def load_dotenv_vault() -> str:
path = dotenv.find_dotenv()
if not path:
return path
path = os.path.dirname(path)
if '.env.vault' not in os.listdir(path):
raise FileNotFoundError('.env.vault is not in same directory as .env')
# we fall back to .env
logger.warning("No .env.vault file found. Falling back to .env")
return f"{path}/.env"
return f"{path}/.env.vault"


Expand Down
4 changes: 2 additions & 2 deletions src/dotenv_vault/test_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ def test_load_dotenv_vault_not_there(self, find_dotenv):
find_dotenv.return_value = '/some/path/'
with mock.patch('os.listdir') as mocked_listdir:
mocked_listdir.return_value = ['.env', 'some_file']
with self.assertRaises(FileNotFoundError):
vault.load_dotenv_vault()
path = vault.load_dotenv_vault()
self.assertEqual(path, '/some/path/.env')

0 comments on commit b1c8ca8

Please sign in to comment.