def compareAndMakeDirectories(userPath, newVersion, versionDirectoryContents, userDirectoryContents): # think of the paramaters this way for now: # source = userPath # destination = newVersion # recentVersionCont = versionDirectoryContents # sourceFiles = userDirectoryContents versionContentList = [] userContentList = [] # go through contents of old directory for x in range(0, len(versionDirectoryContents)): file = recentVersion + '/' + str(versionDirectoryContents[x]) versionContents = makeFiles.readFiles(file) versionContentList.append(versionContents) # go through contents of user-given directory for x in range(0, len(userDirectoryContents)): # the reason we're putting userPath in here is so that # the program will have the path to the file file = userPath + '/' + str(userDirectoryContents[x]) userContents = makeFiles.readFiles(file) userContentList.append(userContents) #Ignore this, it is there incase we need to do more troubleshooting # print "userContentList" # print userContentList # print "sorted user" # print sorted(userContentList) # print "versionContentList" # print versionContentList # print "sorted version" # print sorted(versionContentList) # if there are no changes then return no changes if sorted(versionContentList) == sorted(userContentList): print "no change" for fileName in userDirectoryContents: os.remove(userPath + "/" + fileName) return # newVersion will eventually come from repo (being the path for the # user's repo) + '.' + timeStamp (so that it will be named so that it # is after lastDir, and becomes the NEW most recent directory, or # lastDir the NEXT time you run this function. elif sorted(userContentList) != sorted(versionContentList): distutils.dir_util.copy_tree(userPath, newVersion) for fileName in userDirectoryContents: os.remove(userPath + "/" + fileName) return else: print "something went wrong" return
def compareAndMakeDirectories(userPath, newVersion, repoDirectoryContents, userDirectoryContents): # think of the paramaters this way for now: # source = userPath # destination = newVersion # repoCont = repoDirectoryContents # srcCont = userDirectoryContents repoContentList = [] userContentList = [] # go through contents of old directory for x in range(0, len(repoDirectoryContents)): file = str(repoDirectoryContents[x]) repoContents = makeFiles.readFiles(file) repoContentList.append(repoContents) # go through contents of user-given directory for x in range(0, len(userDirectoryContents)): # the reason we're putting userPath in here is so that # the program will have the path to the file file = userPath+'/'+str(userDirectoryContents[x]) userContents = makeFiles.readFiles(file) userContentList.append(userContents) # if there are no changes then return no changes if repoContentList == userContentList: print "no change" return # newVersion will eventually come from repo (being the path for the # user's repo) + '.' + timeStamp (so that it will be named so that it # is after lastDir, and becomes the NEW most recent directory, or # lastDir the NEXT time you run this function. elif userContentList != repoContentList: distutils.dir_util.copy_tree(userPath, newVersion) return else: print "something went wrong" return
# def compareAndMakeDirectories(userPath, newVersion, repoDirectoryContents, userDirectoryContents): # think of the paramaters this way for now: # source = userPath # destination = newVersion # repoCont = repoDirectoryContents # srcCont = userDirectoryContents repoContentList = [] userContentList = [] # go through contents of old directory for x in repoCont: repoFile = x repoContents = makeFiles.readFiles(repoFile) repoContentList.append(repoContents) print repoContentList # go through contents of user-given directory for y in srcCont: userFile = y userContents = makeFiles.readFiles(userFile) userContentList.append(userContents) print userContentList # if there are no changes then return no changes if repoContentList == userContentList: print "no change"