[Zope3-checkins] CVS: Zope3/src/zope/fssync - fssync.py:1.14
Guido van Rossum
guido@python.org
Wed, 14 May 2003 10:42:43 -0400
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv7725
Modified Files:
fssync.py
Log Message:
Minor refactoring: add methods to compute the name of the original,
extra, and annotations file/directory.
=== Zope3/src/zope/fssync/fssync.py 1.13 => 1.14 ===
--- Zope3/src/zope/fssync/fssync.py:1.13 Tue May 13 16:56:44 2003
+++ Zope3/src/zope/fssync/fssync.py Wed May 14 10:42:43 2003
@@ -408,8 +408,7 @@
return
if not isfile(target):
raise Error("diff target '%s' is file nor directory", target)
- head, tail = self.split(target)
- orig = join(head, "@@Zope", "Original", tail)
+ orig = self.getorig(target)
if not isfile(orig):
raise Error("can't find original for diff target '%s'", target)
if self.cmp(target, orig):
@@ -530,18 +529,14 @@
self.metadata.flush()
def merge_extra(self, local, remote):
- lhead, ltail = split(local)
- rhead, rtail = split(remote)
- lextra = join(lhead, "@@Zope", "Extra", ltail)
- rextra = join(rhead, "@@Zope", "Extra", rtail)
+ lextra = self.getextra(local)
+ rextra = self.getextra(remote)
if isdir(rextra):
self.merge_dirs(lextra, rextra)
def merge_annotations(self, local, remote):
- lhead, ltail = split(local)
- rhead, rtail = split(remote)
- lannotations = join(lhead, "@@Zope", "Annotations", ltail)
- rannotations = join(rhead, "@@Zope", "Annotations", rtail)
+ lannotations = self.getannotations(local)
+ rannotations = self.getannotations(remote)
if isdir(rannotations):
self.merge_dirs(lannotations, rannotations)
@@ -578,12 +573,22 @@
except (os.error, IOError):
return False
- def copyfile(self, src, dst):
- shutil.copyfile(src, dst)
-
def ensuredir(self, dir):
if not isdir(dir):
os.makedirs(dir)
+
+ def getextra(self, path):
+ return self.getspecial(path, "Extra")
+
+ def getannotations(self, path):
+ return self.getspecial(path, "Annotations")
+
+ def getorig(self, path):
+ return self.getspecial(path, "Original")
+
+ def getspecial(self, path, what):
+ head, tail = self.split(path)
+ return join(head, "@@Zope", what, tail)
def split(self, path):
head, tail = split(path)