Skip to content

Commit

Permalink
added dynamic regex with export
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcguinness committed Jun 11, 2024
1 parent b8dd227 commit 86e31db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/wxflow/configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob
import os
import re
import random
import shutil
import subprocess
Expand Down Expand Up @@ -98,8 +99,9 @@ def _get_script_env(cls, scripts: List) -> Dict[str, Any]:
default_env = cls._get_shell_env([])
and_script_env = cls._get_shell_env(scripts)
keys_in_scripts = set()
regex_pattern = 'export\\s+\\b(' + '|'.join(map(re.escape, default_env.keys())) + ')(?==)'
for script in scripts:
result = subprocess.run(['grep', '-o', '-P', '\\b(' + '|'.join(default_env.keys()) + ')(?==)', script], stdout=subprocess.PIPE)
result = subprocess.run(['grep', '-o', '-P', regex_pattern, script], stdout=subprocess.PIPE)
keys_in_scripts.update(result.stdout.decode().split())
vars_just_in_script = set(and_script_env) - set(default_env) | keys_in_scripts
union_env = dict(default_env)
Expand Down

0 comments on commit 86e31db

Please sign in to comment.