MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / IPythonDotEnv

Class IPythonDotEnv

src/dotenv/ipython.py:9–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8@magics_class
9class IPythonDotEnv(Magics):
10
11 @magic_arguments()
12 @argument(
13 '-o', '--override', action='store_true',
14 help="Indicate to override existing variables"
15 )
16 @argument(
17 '-v', '--verbose', action='store_true',
18 help="Indicate function calls to be verbose"
19 )
20 @argument('dotenv_path', nargs='?', type=str, default='.env',
21 help='Search in increasingly higher folders for the `dotenv_path`')
22 @line_magic
23 def dotenv(self, line):
24 args = parse_argstring(self.dotenv, line)
25 # Locate the .env file
26 dotenv_path = args.dotenv_path
27 try:
28 dotenv_path = find_dotenv(dotenv_path, True, True)
29 except IOError:
30 print("cannot find .env file")
31 return
32
33 # Load the .env file
34 load_dotenv(dotenv_path, verbose=args.verbose, override=args.override)
35
36
37def load_ipython_extension(ipython):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected