forked from joke2k/django-environ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: Test on Django 5.0 Bump actions/setup-python from 4.7.0 to 4.7.1 Bump actions/checkout from 4.0.0 to 4.1.1 Add Python 3.12 to the test matrix Make inline comments handling optional and disabled by default Bump actions/checkout from 3.6.0 to 4.0.0 Change version: v0.12.0 -> v0.11.2 Change version: v0.12.0 -> v0.11.2 Update change log Revert "Add variable expansion (fix joke2k#421)" Bump version
- Loading branch information
Showing
16 changed files
with
192 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,17 +24,17 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3.6.0 | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
pip install tox tox-gh-actions setuptools | ||
- name: Check MANIFEST.in for completeness | ||
run: tox -e manifest | ||
|
@@ -64,10 +64,10 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3.6.0 | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
python-version: '3.10' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ jobs: | |
- '3.9' | ||
- '3.10' | ||
- '3.11' | ||
- '3.12' | ||
- 'pypy-3.7' | ||
os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
|
||
|
@@ -66,19 +67,19 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3.6.0 | ||
uses: actions/checkout@v4.1.1 | ||
with: | ||
fetch-depth: 5 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox tox-gh-actions | ||
python -m pip install tox tox-gh-actions setuptools | ||
- name: Setuptools self-test | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,17 +25,17 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3.6.0 | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
pip install tox tox-gh-actions setuptools | ||
- name: Lint with tox | ||
run: tox -e lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,17 +26,17 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3.6.0 | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
pip install tox tox-gh-actions setuptools | ||
- name: Check external links in the package documentation | ||
run: tox -e linkcheck | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# This file is part of the django-environ. | ||
# | ||
# Copyright (c) 2021, Serghei Iakovlev <[email protected]> | ||
# Copyright (c) 2021-2023, Serghei Iakovlev <[email protected]> | ||
# Copyright (c) 2013-2021, Daniele Faraglia <[email protected]> | ||
# | ||
# For the full copyright and license information, please view | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2021, Serghei Iakovlev <[email protected]> | ||
Copyright (c) 2021-2023, Serghei Iakovlev <[email protected]> | ||
Copyright (c) 2013-2021, Daniele Faraglia <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# This file is part of the django-environ. | ||
# | ||
# Copyright (c) 2021-2022, Serghei Iakovlev <[email protected]> | ||
# Copyright (c) 2021-2023, Serghei Iakovlev <[email protected]> | ||
# Copyright (c) 2013-2021, Daniele Faraglia <[email protected]> | ||
# | ||
# For the full copyright and license information, please view | ||
|
@@ -862,8 +862,8 @@ def search_url_config(cls, url, engine=None): | |
return config | ||
|
||
@classmethod | ||
def read_env(cls, env_file=None, overwrite=False, encoding='utf8', | ||
**overrides): | ||
def read_env(cls, env_file=None, overwrite=False, parse_comments=False, | ||
encoding='utf8', **overrides): | ||
r"""Read a .env file into os.environ. | ||
If not given a path to a dotenv path, does filthy magic stack | ||
|
@@ -883,6 +883,8 @@ def read_env(cls, env_file=None, overwrite=False, encoding='utf8', | |
the Django settings module from the Django project root. | ||
:param overwrite: ``overwrite=True`` will force an overwrite of | ||
existing environment variables. | ||
:param parse_comments: Determines whether to recognize and ignore | ||
inline comments in the .env file. Default is False. | ||
:param encoding: The encoding to use when reading the environment file. | ||
:param \**overrides: Any additional keyword arguments provided directly | ||
to read_env will be added to the environment. If the key matches an | ||
|
@@ -927,22 +929,40 @@ def _keep_escaped_format_characters(match): | |
for line in content.splitlines(): | ||
m1 = re.match(r'\A(?:export )?([A-Za-z_0-9]+)=(.*)\Z', line) | ||
if m1: | ||
|
||
# Example: | ||
# | ||
# line: KEY_499=abc#def | ||
# key: KEY_499 | ||
# val: abc#def | ||
key, val = m1.group(1), m1.group(2) | ||
# Look for value in quotes, ignore post-# comments | ||
# (outside quotes) | ||
m2 = re.match(r"\A\s*'(?<!\\)(.*)'\s*(#.*\s*)?\Z", val) | ||
if m2: | ||
val = m2.group(1) | ||
|
||
if not parse_comments: | ||
# Default behavior | ||
# | ||
# Look for value in single quotes | ||
m2 = re.match(r"\A'(.*)'\Z", val) | ||
if m2: | ||
val = m2.group(1) | ||
else: | ||
# For no quotes, find value, ignore comments | ||
# after the first # | ||
m2a = re.match(r"\A(.*?)(#.*\s*)?\Z", val) | ||
if m2a: | ||
val = m2a.group(1) | ||
# Ignore post-# comments (outside quotes). | ||
# Something like ['val' # comment] becomes ['val']. | ||
m2 = re.match(r"\A\s*'(?<!\\)(.*)'\s*(#.*\s*)?\Z", val) | ||
if m2: | ||
val = m2.group(1) | ||
else: | ||
# For no quotes, find value, ignore comments | ||
# after the first # | ||
m2a = re.match(r"\A(.*?)(#.*\s*)?\Z", val) | ||
if m2a: | ||
val = m2a.group(1) | ||
|
||
# Look for value in double quotes | ||
m3 = re.match(r'\A"(.*)"\Z', val) | ||
if m3: | ||
val = re.sub(r'\\(.)', _keep_escaped_format_characters, | ||
m3.group(1)) | ||
|
||
overrides[key] = str(val) | ||
elif not line or line.startswith('#'): | ||
# ignore warnings for empty line-breaks or comments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.