Skip to content

Commit

Permalink
Allow an empty config value
Browse files Browse the repository at this point in the history
e.g. this enables to configure

gitlab.default_priority =
  • Loading branch information
fmauch committed Apr 29, 2021
1 parent ea2c04e commit f2ec29b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bugwarrior/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from builtins import str
from builtins import object

import ast
import copy
import multiprocessing
import time
Expand Down Expand Up @@ -73,11 +74,14 @@ def __init__(self, main_config, main_section, target):
log.info("Working on [%s]", self.target)


def _get_config_or_default(self, key, default, as_type=lambda x: x):
def _get_config_or_default(self, key, default, as_type=None):
"""Return a main config value, or default if it does not exist."""

if self.main_config.has_option(self.main_section, key):
return as_type(self.main_config.get(self.main_section, key))
if as_type:
return as_type(self.main_config.get(self.main_section, key))
else:
return ast.literal_eval(self.main_config.get(self.main_section, key))
return default


Expand Down

0 comments on commit f2ec29b

Please sign in to comment.