Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Make config.get_boolean return given default value
Returning a default value (presumably a boolean) in case the configuration
option is not set, helps to implement opt-in / opt-out options that should
be false / true, unless explicitly set otherwise.

closes #3352
https://pulp.plan.io/issues/3352
  • Loading branch information
Matthias Dellweg committed Feb 12, 2018
1 parent d6b1dd5 commit 8b6b11e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -19,6 +19,7 @@ Patrick Creech (pcreech@redhat.com)
David Davis (daviddavis@redhat.com)
Michael DeHaan (mdehaan@redhat.com)
Elijah DeLee (kdelee@redhat.com)
Matthias Dellweg (dellweg@atix.de)
Jay Dobies (jason.dobies@redhat.com)
Filip Dobrovolny (fdobrovo@redhat.com)
Máirín Duffy (duffy@redhat.com)
Expand Down
8 changes: 4 additions & 4 deletions server/pulp/plugins/config.py
Expand Up @@ -86,11 +86,11 @@ def get(self, key, default=None):

return default

def get_boolean(self, key):
def get_boolean(self, key, default=None):
"""
Parses the given key as a boolean value. If the key is not present or
is not one of the acceptable values for representing a boolean, None
is returned.
is not one of the acceptable values for representing a boolean, a default
value (defaulting to None) is returned.
:param key: key to look up in the configuration
:type key: str
Expand All @@ -112,7 +112,7 @@ def get_boolean(self, key):
return True
elif str_bool == 'false':
return False
return None
return default

def flatten(self):
"""
Expand Down

0 comments on commit 8b6b11e

Please sign in to comment.