mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Remove dotenv.ipython
Fixes #1321 Ref: https://github.com/theskumar/python-dotenv/pull/84
This commit is contained in:
committed by
Nate Prewitt
parent
1a8d158713
commit
c4aad85e1b
@@ -1,8 +1,4 @@
|
||||
from .cli import get_cli_string
|
||||
from .main import load_dotenv, get_key, set_key, unset_key, find_dotenv
|
||||
try:
|
||||
from .ipython import load_ipython_extension
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
__all__ = ['get_cli_string', 'load_dotenv', 'get_key', 'set_key', 'unset_key', 'find_dotenv', 'load_ipython_extension']
|
||||
__all__ = ['get_cli_string', 'load_dotenv', 'get_key', 'set_key', 'unset_key', 'find_dotenv']
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
from __future__ import print_function
|
||||
from .main import load_dotenv, find_dotenv
|
||||
|
||||
from IPython.core.magic import Magics, magics_class, line_magic
|
||||
from IPython.core.magic_arguments import (argument, magic_arguments,
|
||||
parse_argstring)
|
||||
|
||||
|
||||
@magics_class
|
||||
class IPythonDotEnv(Magics):
|
||||
|
||||
@magic_arguments()
|
||||
@argument(
|
||||
'-o', '--override', action='store_true',
|
||||
help="Indicate to override existing variables"
|
||||
)
|
||||
@argument(
|
||||
'-v', '--verbose', action='store_true',
|
||||
help="Indicate function calls to be verbose"
|
||||
)
|
||||
@argument('dotenv_path', nargs='?', type=str, default='.env',
|
||||
help='Search in increasingly higher folders for the `dotenv_path`')
|
||||
@line_magic
|
||||
def dotenv(self, line):
|
||||
args = parse_argstring(self.dotenv, line)
|
||||
# Locate the .env file
|
||||
dotenv_path = args.dotenv_path
|
||||
try:
|
||||
dotenv_path = find_dotenv(dotenv_path, True, True)
|
||||
except IOError:
|
||||
print("cannot find .env file")
|
||||
return
|
||||
|
||||
# Load the .env file
|
||||
load_dotenv(dotenv_path, verbose=args.verbose, override=args.override)
|
||||
|
||||
|
||||
def load_ipython_extension(ipython):
|
||||
"""Register the %dotenv magic."""
|
||||
ipython.register_magics(IPythonDotEnv)
|
||||
Reference in New Issue
Block a user