salt-formula-manager/lib/FormulaRepo.py

27 lines
846 B
Python
Raw Normal View History

from git import Repo
import os
class FormulaRepo():
# class variables
repo_url = ''
repo_path = ''
repo = None
# class constructor
def __init__(self, formula):
self.repo_url = formula.git_url
self.repo_path = formula.local_path
# retrieves repo from remote location
def retrieve(self):
# check if the destination directory exists
if not os.path.exists(self.repo_path):
# clone git repo
print('Downloading ' + self.repo_url + ' into ' + self.repo_path)
self.repo = Repo.clone_from(self.repo_url, self.repo_path)
else:
# let the user know it's already downloaded so we'll update it later
print(self.repo_path + ' already exists, so we\'re not downloading it again.')
self.repo = Repo(self.repo_path)