U fB/ @s0ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZddlmZmZddlmZeedfZeeZeeeed d d ZGd d d Zd.eeeeeedddZ e eeeeee ee efdddZ!d/eeeee"eeeee"eefdddZ#d0eeeeeeee"efdddZ$eeeeefe"eeeefdddZ%eeed d!d"Z&d1ee"e"ed$d%d&Z'd2eeee ee"e"e"eee"d(d)d*Z(d3eeee ee"e"eee eeefd+d,d-Z)dS)4N) OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion)Binding parse_stream)parse_variableszos.PathLike[str])mappingsreturnccs*|D] }|jrtd|jj|VqdS)Nz;Python-dotenv could not parse statement starting at line %s)errorloggerwarningoriginalline)rmappingrsz$resolve_variables..)rupdater)r7join)rnr! new_valuesrQr5resultZatomsrrqrr2s      r2)r*rccsttj|stdtj|r,tj|}d}tj|}||krp|Vtjtj|tjj}||}}q Decide whether this is running in a REPL or IPython notebook __main__N__file__)fromlistF) __import__ModuleNotFoundErrorhasattr)mainrrr_is_interactives z$find_dotenv.._is_interactivefrozenFNzFile not foundr()getattrsysr)getcwd _getframerf_code co_filenamer*rkf_backAssertionErrorryrzr}rur+rx) r~rrrr*frameZ current_fileframe_filenamery check_pathrrr find_dotenvs&     rT)rrrr!r rrcCs2|dkr|dkrt}t||||||d}|S)aParse a .env file and then load all the variables found as environment variables. Parameters: dotenv_path: Absolute or relative path to .env file. stream: Text stream (such as `io.StringIO`) with .env content, used if `dotenv_path` is `None`. verbose: Whether to output a warning the .env file is missing. override: Whether to override the system environment variables with the variables from the `.env` file. encoding: Encoding to be used to read the file. Returns: Bool: True if at least one environment variable is set else False If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the .env file. Nrrrr r!r)rrr:)rrrr!r rZdotenvrrr load_dotenvAsr)rrrr rrcCs.|dkr|dkrt}t||||d|dS)a Parse a .env file and return its content as a dict. The returned dict will have `None` values for keys without values in the .env file. For example, `foo=bar` results in `{"foo": "bar"}` whereas `foo` alone results in `{"foo": None}` Parameters: dotenv_path: Absolute or relative path to the .env file. stream: `StringIO` object with .env content, used if `dotenv_path` is `None`. verbose: Whether to output a warning if the .env file is missing. encoding: Encoding to be used to read the file. If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the .env file. NTr)rrr3)rrrr rrrr dotenv_valuesgsr)rC)rWFrC)rWrC)r'FF)NNFFTrC)NNFTrC)*r.loggingr)rIrOrrL collectionsr contextlibrtypingrrrrrr r r parserr r variablesrrAr@ getLoggerr=rrrrErVrBrirmr2r}rrrrrrrs  (    U  4   /  '