Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Nov 11, 2024
1 parent 9481bdd commit a1b873c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/fprime/fbuild/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class EnvironmentVariableInterpolation(configparser.BasicInterpolation):
""" Interpolation for environment variables embedded in setting.ini
"""Interpolation for environment variables embedded in setting.ini
settings.ini will extrapolate $/${} as an environment variable. This will allow basic environment variable
replacement. It is illegal to supply an environment variable with a $ or %( as part of the value because that might
Expand All @@ -29,7 +29,7 @@ class EnvironmentVariableInterpolation(configparser.BasicInterpolation):
"""

def before_get(self, parser, section, option, value, defaults):
""" Pre-process sections to replace environment variables
"""Pre-process sections to replace environment variables
Runs before the value is gotten to replace environment variables. It will use os.path.expandvars to do the
actual substitution on any value in the "environment" section. Other pre-processing is done first.
Expand Down Expand Up @@ -202,7 +202,9 @@ def load(settings_file: Path, platform: str = "native", is_ut: bool = False):
# Setup a config parser, or none if the settings file does not exist
confparse = None
if settings_file.exists():
confparse = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation())
confparse = configparser.ConfigParser(
interpolation=EnvironmentVariableInterpolation()
)
confparse.read(settings_file)
else:
print(f"[WARNING] {settings_file} does not exist", file=sys.stderr)
Expand Down Expand Up @@ -266,7 +268,9 @@ def load_environment(env_file):
:param env_file: load environment from this file
:return: environment dictionary
"""
parser = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation())
parser = configparser.ConfigParser(
interpolation=EnvironmentVariableInterpolation()
)
parser.optionxform = str
parser.read(env_file)
env_dict = {}
Expand Down
5 changes: 1 addition & 4 deletions test/fprime/fbuild/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ def test_settings():
"install_destination": full_path("settings-data/build-artifacts"),
"library_locations": [],
"environment_file": full_path("settings-data/settings-environment.ini"),
"environment": {
"MY_VARIABLE": "my value",
"MY_VARIABLE_2": "abc:123"
},
"environment": {"MY_VARIABLE": "my value", "MY_VARIABLE_2": "abc:123"},
"component_cookiecutter": "default",
"deployment_cookiecutter": "default",
"project_root": full_path(".."),
Expand Down

0 comments on commit a1b873c

Please sign in to comment.