Skip to content

Commit

Permalink
Renaming method to get_setting()
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Oct 8, 2021
1 parent 863e5a7 commit 388fb90
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion armi/cli/entryPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def createOptionFromSetting(
particularly beneficial when many options are being added as they can clutter the :code:`--help` to be
almost unusable.
"""
settingsInstance = self.cs.get(settingName)
settingsInstance = self.cs.get_setting(settingName)

if settings.isBoolSetting(settingsInstance):
helpMessage = (
Expand Down
14 changes: 9 additions & 5 deletions armi/operators/settingsValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,17 @@ def addQueryBadLocationWillLikelyFail(self, settingName):
def addQueryCurrentSettingMayNotSupportFeatures(self, settingName):
"""Add a query that the current value for ``settingName`` may not support certain features."""
self.addQuery(
lambda: self.cs[settingName] != self.cs.get(settingName).default,
lambda: self.cs[settingName] != self.cs.get_setting(settingName).default,
"{} set as:\n{}\nUsing this location instead of the default location\n{}\n"
"may not support certain functions.".format(
settingName, self.cs[settingName], self.cs.get(settingName).default
settingName,
self.cs[settingName],
self.cs.get_setting(settingName).default,
),
"Revert to default location?",
lambda: self._assignCS(settingName, self.cs.get(settingName).default),
lambda: self._assignCS(
settingName, self.cs.get_setting(settingName).default
),
)

def _assignCS(self, key, value):
Expand Down Expand Up @@ -636,7 +640,7 @@ def createQueryRevertBadPathToDefault(inspector, settingName, initialLambda=None
if initialLambda is None:
initialLambda = lambda: (
not os.path.exists(pathTools.armiAbsPath(inspector.cs[settingName]))
and inspector.cs.get(settingName).offDefault
and inspector.cs.get_setting(settingName).offDefault
) # solution is to revert to default

query = Query(
Expand All @@ -645,6 +649,6 @@ def createQueryRevertBadPathToDefault(inspector, settingName, initialLambda=None
settingName, inspector.cs[settingName]
),
"Revert to default location?",
inspector.cs.get(settingName).revertToDefault,
inspector.cs.get_setting(settingName).revertToDefault,
)
return query
2 changes: 1 addition & 1 deletion armi/physics/fuelCycle/fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, r, cs):
@staticmethod
def specifyInputs(cs):
files = {
cs.get(settingName).label: [
cs.get_setting(settingName).label: [
cs[settingName],
]
for settingName in ["shuffleLogic", "explicitRepeatShuffles"]
Expand Down
8 changes: 2 additions & 6 deletions armi/settings/caseSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,8 @@ def __getitem__(self, key):
else:
raise NonexistentSetting(key)

def get(self, key):
"""This helper method exists for when users need the entire setting object, not just the value
NOTE: This breaks the default-value paradigm of the dict.get() method, in favor of internal
consistency for raising NonexistentSetting
"""
def get_setting(self, key):
"""This helper method exists for when users need the entire setting object, not just the value"""
if key in self.__settings:
return deepcopy(self.__settings[key])
else:
Expand Down
2 changes: 1 addition & 1 deletion armi/settings/settingsIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _applySettings(self, name, val):
self.invalidSettings.add(settingName)
else:
# apply validations
settingObj = self.cs.get(settingName)
settingObj = self.cs.get_setting(settingName)
if value:
value = applyTypeConversions(settingObj, value)

Expand Down
2 changes: 1 addition & 1 deletion armi/settings/settingsRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def applyVerbosity(cs, name, value):
# rather than erroring on poor inputs because these used to be integers, just go to the default
# this isn't a high risk setting that terribly needs protection. 'value' should only be fed in after
# a valid definition has been supplied so we can look at the existing options.
if name in cs and value not in cs.get("verbosity").options:
if name in cs and value not in cs.get_setting("verbosity").options:
value = cs["verbosity"]

return {name: value}
Expand Down
2 changes: 1 addition & 1 deletion armi/tests/test_fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def test_settingsAreDiscovered(self):
nm = settings.CONF_CIRCULAR_RING_ORDER
self.assertEqual(cs[nm], "angle")

setting = cs.get(nm)
setting = cs.get_setting(nm)
self.assertIn("distance", setting.options)


Expand Down

0 comments on commit 388fb90

Please sign in to comment.