Added repo cloning to this script

This commit is contained in:
Gregory Ballantine 2016-09-26 16:48:51 -04:00
parent 73d9420950
commit d6f031b495

View File

@ -30,11 +30,32 @@ def check_formula_dir(conf):
# loops through the array of repos and downloads them
def get_formulas(conf):
# loop through the defined formulas
for formula in conf['formulas']:
git_url = ''
local_path = ''
# check if the formula entry is a string or a dictionary
if isinstance(formula, dict):
print('Downloading ' + str(formula['url']) + ' into ' + str(conf['formulas_dir']) + '/' + str(formula['name']))
# entry is a dictionary
git_url = str(formula['url'])
local_path = str(conf['formulas_dir']) + '/' + str(formula['name'])
elif isinstance(formula, str):
print('Downloading ' + str(conf['formulas_url']) + str(formula) + '-formula into ' + str(conf['formulas_dir']) + '/' + str(formula) + '-formula')
# entry is a string
git_url = str(conf['formulas_url']) + str(formula) + '-formula'
local_path = str(conf['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.')
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)
# main program
def main():