forked from manusimidt/py-xbrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
24 lines (22 loc) · 763 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
This module contains helper functions used by the unit test
"""
def get_bot_header(env_path: str = './tests/.env') -> dict or None:
try:
f = open(env_path, "r")
from_header: str or None = None
user_agent_header: str or None = None
for line in f:
env_name, env_value = [x.strip() for x in line.strip().split('=')]
if env_name == 'FROM':
from_header = env_value
elif env_name == 'USER_AGENT':
user_agent_header = env_value
if from_header and user_agent_header:
return {
'From': from_header,
'User-Agent': user_agent_header
}
except FileNotFoundError:
return None
return None