From 805758c2951b3494771700332433c8d90e36da10 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 19 Jul 2017 13:06:00 -0400 Subject: [PATCH] Changed the functions so that they only take what parameters they need to work --- salt-formula-manager.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/salt-formula-manager.py b/salt-formula-manager.py index a73857f..fc7ef05 100644 --- a/salt-formula-manager.py +++ b/salt-formula-manager.py @@ -17,21 +17,21 @@ def read_config(): return conf # makes the formulas directory if it doesn't exist -def check_formula_dir(conf): +def check_formula_dir(formulas_dir): # check if the formulas directory is actually a directory - if not os.path.isdir(conf['formulas_dir']): + if not os.path.isdir(formulas_dir): # check if it's a file - if os.path.exists(conf['formulas_dir']): - print(str(conf['formulas_dir']) + ' exists but is not a directory. Please fix this.') + if os.path.exists(formulas_dir): + print(str(formulas_dir) + ' exists but is not a directory. Please fix this.') sys.exit(1) # create it if not else: - os.makedirs(conf['formulas_dir']) + os.makedirs(formulas_dir) # loops through the array of repos and downloads them -def get_formulas(conf): +def get_formulas(formulas, formulas_dir, formulas_url): # loop through the defined formulas - for formula in conf['formulas']: + for formula in formulas: git_url = '' local_path = '' @@ -39,11 +39,11 @@ def get_formulas(conf): if isinstance(formula, dict): # entry is a dictionary git_url = str(formula['url']) - local_path = str(conf['formulas_dir']) + '/' + str(formula['name']) + local_path = str(formulas_dir) + '/' + str(formula['name']) elif isinstance(formula, str): # entry is a string - git_url = str(conf['formulas_url']) + str(formula) + '-formula' - local_path = str(conf['formulas_dir']) + '/' + str(formula) + '-formula' + git_url = str(formulas_url) + str(formula) + '-formula' + local_path = str(formulas_dir) + '/' + str(formula) + '-formula' else: # entry type is not supported print('One of your entries is not a dict or a string (' + str(formula) + ') - please fix this.') @@ -71,13 +71,13 @@ def main(): conf = read_config() # make sure the formulas directory exists - check_formula_dir(conf) + check_formula_dir(conf['formulas_dir']) # do the formula stuff - get_formulas(conf) + get_formulas(conf['formulas'], conf['formulas_dir'], conf['formulas_url']) # clean unmanaged formulas - clean_formulas(conf) + #clean_formulas(conf) # run main main()