in o2a/utils/el_utils.py [0:0]
def extract_evaluate_properties(properties_file: Optional[str], props: PropertySet):
"""
Parses the job_properties file into a dictionary, if the value has
and EL function in it, it gets replaced with the corresponding
value that has already been parsed. For example, a file like:
job.job_properties
host=user@google.com
command=ssh ${host}
The job_properties would be parsed like:
PROPERTIES = {
host: 'user@google.com',
command='ssh user@google.com',
}
"""
copy_of_props = deepcopy(props)
properties_read_from_file: Dict[str, str] = {}
if not properties_file:
return properties_read_from_file
if not os.path.isfile(properties_file):
logging.warning(f"The job_properties file is missing: {properties_file}")
return properties_read_from_file
with open(properties_file) as prop_file:
for line in prop_file.readlines():
if line.startswith("#") or line.startswith(" ") or line.startswith("\n"):
continue
key, value = _evaluate_properties_line(
line, known_values=properties_read_from_file, props=copy_of_props
)
# Set the value of property in the copy of property set for further reference
copy_of_props.action_node_properties[key] = value
properties_read_from_file[key] = value
return properties_read_from_file