Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream as any text file? #308

Closed
lmmarsano opened this issue Mar 25, 2021 · 2 comments · Fixed by #348
Closed

Stream as any text file? #308

lmmarsano opened this issue Mar 25, 2021 · 2 comments · Fixed by #348

Comments

@lmmarsano
Copy link

lmmarsano commented Mar 25, 2021

As noted before
#208
#156
the code spec

- *stream*: `StringIO` object with .env content.

is unusually restrictive.
It'd be useful to accept any text file as a stream.
My use case would be packaging a .env.defaults file opened by importlib.resources.open_text, so you can uniformly manage/document environment & defaults via .env files.

@linclelinkpart5
Copy link

Yes, I agree with this change. Having to slurp up the contents of the .env file in order to immediately repackage it as a StringIO is awkward and prohibits lazy loading of files. I'd love to instead be able to do this:

dotenv_fp = Path('path/to/.env')
with dotenv_fp.open('r') as f:
    config = dotenv.dotenv_values(stream=f)

@bbc2
Copy link
Collaborator

bbc2 commented Jul 14, 2021

I've created #348 to fix this. Let me know if there's any problem with that PR. Otherwise I'll merge it in a few days.

@bbc2 bbc2 closed this as completed in #348 Jul 24, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants