From 0fcf086e0d88812fa1fcc4169da43f04c31a997d Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 19 Jul 2017 14:41:58 -0400 Subject: [PATCH] Added a check to make sure a formula's name was defined --- salt-formula-manager.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/salt-formula-manager.py b/salt-formula-manager.py index 257f66e..afc8122 100644 --- a/salt-formula-manager.py +++ b/salt-formula-manager.py @@ -40,7 +40,7 @@ def get_formulas(formulas, formulas_dir, formulas_url): else: print('Downloading ' + git_url + ' into ' + local_path) # clone git repo - Repo.clone_from(git_url, local_path) + #Repo.clone_from(git_url, local_path) # parses a formula entry, and then returns the target git URL and the destination for the clone def parse_formula_entry(formula, formulas_dir, formulas_url): @@ -51,7 +51,15 @@ def parse_formula_entry(formula, formulas_dir, formulas_url): # check if the formula entry is a string or a dictionary if isinstance(formula, dict): # entry is a dictionary - git_url = str(formula.get('url', formulas_url)) # get the 'url' value if it is defined, otherwise use the default + # check if the formula's name was defined + if not 'name' in formula: + # set the formula's name if need be + formula['name'] = [k for (k, v) in formula.iteritems() if v == 0] + # check if the dictionary has a git URL defined + if 'url' in formula: + git_url = str(formula['url']) + else: + git_url = str(formulas_url) + str(formula) + '-formula' local_path = str(formulas_dir) + '/' + str(formula['name']) elif isinstance(formula, str): # entry is a string