File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11__pycache__ /
22* .pyc
3+ .env
4+ .env. *
5+ ! .env.example
Original file line number Diff line number Diff line change 5353""" .strip ()
5454
5555
56+ def load_local_env () -> None :
57+ env_path = ROOT / ".env"
58+ if not env_path .exists ():
59+ return
60+
61+ for raw_line in env_path .read_text ().splitlines ():
62+ line = raw_line .strip ()
63+ if not line or line .startswith ("#" ) or "=" not in line :
64+ continue
65+
66+ key , value = line .split ("=" , 1 )
67+ key = key .strip ()
68+ value = value .strip ().strip ('"' ).strip ("'" )
69+ os .environ .setdefault (key , value )
70+
71+
5672def extract_section_body (content : str , heading : str ) -> str :
5773 pattern = rf"## { re .escape (heading )} \n(.*?)(?=\n## |\Z)"
5874 match = re .search (pattern , content , flags = re .S )
@@ -239,6 +255,7 @@ def parse_args() -> argparse.Namespace:
239255
240256
241257def main () -> int :
258+ load_local_env ()
242259 args = parse_args ()
243260 api_key = os .getenv ("OPENAI_API_KEY" )
244261 if not api_key :
You can’t perform that action at this time.
0 commit comments