Improve repo.Base.py:syncfoldersto parameter/var names

Name parameter that hands us a Status Repository 'status_repo' and not
'copyfolders' as was before:

a) make it clear that we pass in a repository and not folder
instances. That was very confusing before.
b) We were always only using one 'copyfolders' item anyway, so let us
not make it a list.

Go through the list and make the variable nameing consistent:
dst_repo rather than dest (is it a folder?) to match the status_repo
naming scheme.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-08-29 16:00:11 +02:00 committed by Nicolas Sebrecht
parent f0869e5c0f
commit fe1391084b

View File

@ -114,36 +114,32 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
def getfolder(self, foldername): def getfolder(self, foldername):
raise NotImplementedError raise NotImplementedError
def syncfoldersto(self, dest, status): def syncfoldersto(self, dst_repo, status_repo):
"""Syncs the folders in this repository to those in dest. """Syncs the folders in this repository to those in dest.
It does NOT sync the contents of those folders.
Whenever makefolder() is called, also call makefolder() on status It does NOT sync the contents of those folders."""
folder.""" src_repo = self
src = self src_folders = src_repo.getfolders()
srcfolders = src.getfolders() dst_folders = dst_repo.getfolders()
destfolders = dest.getfolders()
# Create hashes with the names, but convert the source folders # Create hashes with the names, but convert the source folders
# to the dest folder's sep. # to the dest folder's sep.
src_hash = {}
srchash = {} for folder in src_folders:
for folder in srcfolders: src_hash[folder.getvisiblename().replace(
srchash[folder.getvisiblename().replace(src.getsep(), dest.getsep())] = \ src_repo.getsep(), dst_repo.getsep())] = folder
folder dst_hash = {}
desthash = {} for folder in dst_folders:
for folder in destfolders: dst_hash[folder.getvisiblename()] = folder
desthash[folder.getvisiblename()] = folder
# #
# Find new folders. # Find new folders.
# for key in src_hash.keys():
if not key in dst_hash:
for key in srchash.keys():
if not key in desthash:
try: try:
dest.makefolder(key) dst_repo.makefolder(key)
status.makefolder(key.replace(dest.getsep(), status.getsep())) status_repo.makefolder(key.replace(dst_repo.getsep(),
status_repo.getsep()))
except (KeyboardInterrupt): except (KeyboardInterrupt):
raise raise
except: except: