Coverage for gidappdata\utility\extended_dotenv.py : 73%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import os
2from dotenv import load_dotenv, find_dotenv
5def _is_appdata_object(in_object):
6 try:
7 _name = in_object.__class__.__name__
8 return _name == 'AppDataStorager'
9 except AttributeError:
10 return False
13def find_dotenv_everywhere(filename: str = '.env', start_dir=None, lower_folder: bool = True, upper_folder=True, raise_error_if_not_found: bool = False):
14 start_dir = os.getcwd() if start_dir is None else start_dir
15 start_dir = str(start_dir) if _is_appdata_object(start_dir) is True else start_dir
16 dotfile = None
17 if lower_folder:
18 for dirname, _, filelist in os.walk(start_dir):
19 for file in filelist:
20 if file == filename:
21 print()
22 dotfile = os.path.join(dirname, file)
23 if dotfile is None and upper_folder:
24 _old_dir = os.getcwd()
25 os.chdir(start_dir)
26 dotfile = find_dotenv(filename, raise_error_if_not_found, usecwd=True)
28 os.chdir(_old_dir)
29 if dotfile is None:
30 dotfile = ''
31 return dotfile