Broke the parsing of the formula entry into a separate functions
This commit is contained in:
parent
805758c295
commit
9b0c48a8e1
@ -32,6 +32,19 @@ def check_formula_dir(formulas_dir):
|
||||
def get_formulas(formulas, formulas_dir, formulas_url):
|
||||
# loop through the defined formulas
|
||||
for formula in formulas:
|
||||
git_url, local_path = parse_formula_entry(formula, formulas_dir, formulas_url)
|
||||
|
||||
# check if the destination directory exists
|
||||
if os.path.exists(local_path):
|
||||
print(local_path + ' already exists, so we\'re skipping this.')
|
||||
else:
|
||||
print('Downloading ' + git_url + ' into ' + local_path)
|
||||
# clone git repo
|
||||
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):
|
||||
# define our variables to be returned
|
||||
git_url = ''
|
||||
local_path = ''
|
||||
|
||||
@ -49,13 +62,8 @@ def get_formulas(formulas, formulas_dir, formulas_url):
|
||||
print('One of your entries is not a dict or a string (' + str(formula) + ') - please fix this.')
|
||||
sys.exit(1)
|
||||
|
||||
# check if the destination directory exists
|
||||
if os.path.exists(local_path):
|
||||
print(local_path + ' already exists, so we\'re skipping this.')
|
||||
else:
|
||||
print('Downloading ' + git_url + ' into ' + local_path)
|
||||
# clone git repo
|
||||
Repo.clone_from(git_url, local_path)
|
||||
# return the values here
|
||||
return git_url, local_path
|
||||
|
||||
# purge un-managed formulas
|
||||
def clean_formulas(conf):
|
||||
|
Loading…
Reference in New Issue
Block a user