Skip to content

Commit

Permalink
actually fix get_path behavior for defaults, version bump
Browse files Browse the repository at this point in the history
As it turns out #3 was caused by yet another manifestation of the
issue that was encountered in a8ef37a -- the incorrectly handled
branches inside of get. The internal implementation is pretty much
entirely inside out, the version where we retain the sources, rank by
source and then pick the resulting value will end up being much less
code, the inner block that this commit touches how has the same
pattern repeated something like 8 times varying across string vs list
and path vs not path, and probably one other variable, but all the
logic is the same, it was just hard to track.

Closes #3.
  • Loading branch information
tgbugs committed Feb 21, 2020
1 parent 9a3b4eb commit 19a9c69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion orthauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
configure,
configure_relative,)

__version__ = '0.0.8'
__version__ = '0.0.9'
20 changes: 20 additions & 0 deletions orthauth/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,18 @@ def get(self, variable_name, *args, **kwargs):
elif 'default' in user_variable_value:
d = user_variable_value['default']
if isinstance(d, list):
if not for_path:
log.warning(f'attempting to get a default value for {variable_name} '
'that is a list did you want get_path?')
else:
d = [self.user_config._pathit(p) for p in d if p is not None]

defaults.extend(d)

else:
if for_path and d is not None:
d = self.user_config._pathit(d)

defaults.append(d)

if not isinstance(auth_variable_value, dict):
Expand All @@ -656,8 +666,18 @@ def get(self, variable_name, *args, **kwargs):
elif 'default' in auth_variable_value:
d = auth_variable_value['default']
if isinstance(d, list):
if not for_path:
log.warning(f'attempting to get a default value for {variable_name} '
'that is a list did you want get_path?')
else:
d = [self._pathit(p) for p in d if p is not None]

defaults.extend(d)

else:
if for_path and d is not None:
d = self._pathit(d)

defaults.append(d)

envars = self._envars(user_variable_value)
Expand Down

0 comments on commit 19a9c69

Please sign in to comment.