Skip to content

Commit

Permalink
fixed new linting issue, improved example in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
lvanderree committed Jul 6, 2023
1 parent 756a7e9 commit fc5b410
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Added
`#463 <https://github.com/joke2k/django-environ/pull/463>`_.
- Added variable expansion
`#468 <https://github.com/joke2k/django-environ/pull/468>`_.
- Added capability to handle comments after #, after quoted values, like `KEY= 'value_1 # value_2' # comment`
- Added capability to handle comments after #, after quoted values, like `KEY= 'part1 # part2' # comment`
`#475 <https://github.com/joke2k/django-environ/pull/475>`_.

Changed
Expand Down
6 changes: 4 additions & 2 deletions environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,14 @@ def _keep_escaped_format_characters(match):
m1 = re.match(r'\A(?:export )?([A-Za-z_0-9]+)=(.*)\Z', line)
if m1:
key, val = m1.group(1), m1.group(2)
# search for value within quotes, ignore comments after # (outside quotes)
# search for value within quotes,
# ignore comments after # (outside quotes)
m2 = re.match(r"\A\s*'(?<!\\)(.*)'\s*(#.*\s*)?\Z", val)
if m2:
val = m2.group(1)
else:
# if no quotes, search for value, ignore comments after first #
# if no quotes, search for value,
# ignore comments after first #
m2a = re.match(r"\A(.*?)(#.*\s*)?\Z", val)
if m2a:
val = m2a.group(1)
Expand Down

0 comments on commit fc5b410

Please sign in to comment.