diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2023-04-05 15:27:38 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2023-04-05 15:27:38 -0400 |
commit | e5fa089379d750298886d5576de8dd93cd1cbbe3 (patch) | |
tree | 8b57f0e1d2f1b2ba85c9c72b59b29e1819950799 | |
parent | fec93955bf015348492fe0f6902dcb10b42df75a (diff) | |
download | bugspray-e5fa089379d750298886d5576de8dd93cd1cbbe3.tar.gz |
Better fix bugs without a config-defined component
This should fix other instances where we're working with bugs that have
a product/component that isn't known to us from the config file.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | peebz/__init__.py | 16 | ||||
-rw-r--r-- | peebz/bz2pi.py | 11 |
2 files changed, 14 insertions, 13 deletions
diff --git a/peebz/__init__.py b/peebz/__init__.py index eb24111..b380c59 100644 --- a/peebz/__init__.py +++ b/peebz/__init__.py @@ -63,7 +63,10 @@ def get_config() -> Dict: def get_component_config(product: str, component: str) -> Dict: config = get_config() - return config['components'][product][component] + try: + return config['components'][product][component] + except KeyError: + return dict() def get_template_by_bid(tptname: str, bid: int) -> Template: @@ -757,6 +760,14 @@ def get_recipients_by_subsystem(subsystem: str) -> Set[str]: return set() +def get_privacy_mode(product: str, component: str) -> bool: + config = get_config() + if config['bugzilla'].get('privacy_mode', False): + return True + cconf = get_component_config(product, component) + return cconf.get('bz_privacy_mode', False) + + def get_bug_recipients(bid: int) -> Set[str]: # Get all db-stored recipients # TODO: implement "onlyto" @@ -770,9 +781,8 @@ def get_bug_recipients(bid: int) -> Set[str]: product = bdata['product'] component = bdata['component'] config = get_config() - cconf = get_component_config(product, component) bugr = get_recipients_by_product_component(product, component) - if config['bugzilla'].get('privacy_mode', False) or cconf.get('bz_privacy_mode', False): + if get_privacy_mode(product, component): logger.debug('Privacy mode on, not adding addresses from the bug') else: bugr.update(bdata['cc']) diff --git a/peebz/bz2pi.py b/peebz/bz2pi.py index 373b589..fd16dd1 100644 --- a/peebz/bz2pi.py +++ b/peebz/bz2pi.py @@ -121,16 +121,7 @@ def main(cmdargs: argparse.Namespace) -> None: for bdata in buglist: logger.debug('Looking at %s: %s', bdata['id'], bdata['summary']) bid = bdata['id'] - privacy_mode = False - if config['bugzilla'].get('privacy_mode', False): - privacy_mode = True - else: - try: - cconf = peebz.get_component_config(bdata['product'], bdata['component']) - if cconf.get('bz_privacy_mode', False): - privacy_mode = True - except KeyError: - pass + privacy_mode = peebz.get_privacy_mode(bdata['product'], bdata['component']) process_new_comments(bid, privacy_mode=privacy_mode, dry_run=cmdargs.dry_run) seen.add(bid) else: |