From 707d79f31f8073f72cdfa57ebd8e05a4eb44a6e0 Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Feb 05 2018 22:50:50 +0000 Subject: bin/get_valid_custom_grains.py: minor improvement based on cboltz comment --- diff --git a/bin/get_valid_custom_grains.py b/bin/get_valid_custom_grains.py index 783b99d..d83b160 100755 --- a/bin/get_valid_custom_grains.py +++ b/bin/get_valid_custom_grains.py @@ -23,10 +23,13 @@ def print_valid_localized_grains(): all_valid_localized_grains = get_all_valid_localized_grains() for country, items in all_valid_localized_grains.items(): if type(items['virt_cluster']) == str: - results.append('%s,%s,%s' % (country, items['city'], items['virt_cluster'])) - elif type(items['virt_cluster']) == list: + # convert to list + items['virt_cluster'] = [ items['virt_cluster'] ] + if type(items['virt_cluster']) == list: for virt_cluster in items['virt_cluster']: results.append('%s,%s,%s' % (country, items['city'], virt_cluster)) + else: + raise Exception('virt_cluster "%s" is not a string or a list' % items['virt_cluster']) print('\n'.join(results))