Theo Chatzimichos 7cceb8
#!/usr/bin/python3
Theo Chatzimichos 7cceb8
Theo Chatzimichos 18791d
# For description and usage, see the argparse options at the end of the file
Theo Chatzimichos 18791d
Theo Chatzimichos 18791d
import argparse
ac656a
Theo Chatzimichos 7cceb8
import yaml
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
def get_valid_custom_grains():
Theo Chatzimichos 7cceb8
    with open('pillar/valid_custom_grains.yaml', 'r') as f:
Karol Babioch 3016f1
        VALID_CUSTOM_GRAINS = yaml.safe_load(f)
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
    return VALID_CUSTOM_GRAINS
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
def get_valid_global_grains():
Theo Chatzimichos 7cceb8
    return get_valid_custom_grains()['global']
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
04eaa2
def get_countries():
04eaa2
    return get_valid_custom_grains()['countries']
Theo Chatzimichos 12b8f9
Theo Chatzimichos 12b8f9
Theo Chatzimichos 7cceb8
def print_valid_localized_grains():
Theo Chatzimichos 7cceb8
    results = []
04eaa2
    for country in get_countries():
b6186d
        results.append('%s' % (country))
Theo Chatzimichos 7cceb8
    print('\n'.join(results))
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
Theo Chatzimichos 7cceb8
if __name__ == "__main__":
b6186d
    parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description='Loads the pillar/valid_custom_grains.py and returns a list of valid custom grains in the form of "country".')
Theo Chatzimichos 18791d
    args = parser.parse_args()
Theo Chatzimichos 18791d
04eaa2
    print_valid_localized_grains()