Skip to content

Commit

Permalink
Add generic ENV string cleaner (#32)
Browse files Browse the repository at this point in the history
Closes #29
Closes #31

Co-authored-by: Edward Delaporte <[email protected]>
Co-authored-by: David Riddle <[email protected]>
Co-authored-by: Michelle Pitcel <[email protected]>
Co-authored-by: Zach Carrington <[email protected]>
  • Loading branch information
5 people authored Jul 16, 2024
1 parent 9b4c3b8 commit bd3beee
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/vcr_cleaner/cleaners/env_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,22 @@ def clean_env_helper(dirty):

# Clean response body
for clean_me in clean_strings:
body = body.replace(clean_me, 'CLEANED')
if clean_me.strip() != '':
body = body.replace(clean_me, 'CLEANED')

if 'string' in dirty['body']:
dirty['body']['string'] = body
else:
dirty['body'] = body


def simple_clean_env_string(dirty):
'''Clean any strings set in the CLEAN_STRING environment variable.
export CLEAN_STRINGS='my_name,my_email'
'''
clean_strings = os.environ.get('CLEAN_STRINGS', "").split(',')
for clean_me in clean_strings:
if clean_me.strip() != '':
dirty = dirty.replace(clean_me, 'CLEANED')

return dirty

0 comments on commit bd3beee

Please sign in to comment.