[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - include.py:1.8
Fred L. Drake, Jr.
fred at zope.com
Tue Mar 30 21:13:22 EST 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv11977
Modified Files:
include.py
Log Message:
- use names_with_underscores for internal helpers
- add chokepoint for individual file copying
- add hook for building MANIFEST files
=== Packages/zpkgtools/zpkgtools/include.py 1.7 => 1.8 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.7 Tue Mar 30 16:37:06 2004
+++ Packages/zpkgtools/zpkgtools/include.py Tue Mar 30 21:13:21 2004
@@ -113,7 +113,7 @@
src = self.normalizePathOrURL(src, "source", filename, lineno)
if src == "-":
path = os.path.join(self.source, dest)
- expansions = self.filterNames(glob.glob(path))
+ expansions = self.filter_names(glob.glob(path))
if not expansions:
raise InclusionSpecificationError(
"exclusion %r doesn't match any files" % dest,
@@ -123,16 +123,6 @@
else:
self.includes[dest] = src
- def filterNames(self, names):
- names = [n for n in names
- if n not in EXCLUDE_NAMES]
- # This is needed when building a distro from a working
- # copy (likely a checkout) rather than a pristine export:
- for pattern in EXCLUDE_PATTERNS:
- names = [n for n in names
- if not fnmatch.fnmatch(n, pattern)]
- return names
-
def normalizePath(self, path, type, filename, lineno):
if ":" in path:
scheme, rest = urllib.splittype(path)
@@ -182,8 +172,8 @@
os.mkdir(destination)
prefix = os.path.join(source, "")
for dirname, dirs, files in os.walk(source):
- dirs[:] = self.filterNames(dirs)
- files = self.filterNames(files)
+ dirs[:] = self.filter_names(dirs)
+ files = self.filter_names(files)
# remove excluded directories:
for dir in dirs[:]:
@@ -206,7 +196,7 @@
destname = os.path.join(destdir, file)
# Copy file data, permission bits, and stat info;
# owner/group are not copied.
- shutil.copy2(srcname, destname)
+ self.copy_file(srcname, destname)
for dir in dirs:
srcname = os.path.join(dirname, dir)
@@ -217,6 +207,24 @@
shutil.copymode(srcname, destname)
shutil.copystat(srcname, destname)
+ def copy_file(self, source, destination):
+ shutil.copy2(source, destination)
+ self.add_output(destination)
+
+ def add_output(self, path):
+ # we're going to build the manifest here
+ pass
+
+ def filter_names(self, names):
+ names = [n for n in names
+ if n not in EXCLUDE_NAMES]
+ # This is needed when building a distro from a working
+ # copy (likely a checkout) rather than a pristine export:
+ for pattern in EXCLUDE_PATTERNS:
+ names = [n for n in names
+ if not fnmatch.fnmatch(n, pattern)]
+ return names
+
def addSingleInclude(self, relpath, source):
dirname, basename = os.path.split(relpath)
if dirname:
@@ -254,7 +262,7 @@
# Check for file-ness here since copyTree() doesn't handle
# individual files at all.
if os.path.isfile(source):
- shutil.copy2(source, destination)
+ self.copy_file(source, destination)
else:
self.copyTree(source, destination)
@@ -267,6 +275,7 @@
shutil.copyfileobj(inf, outf)
finally:
outf.close()
+ self.add_output(destination)
finally:
inf.close()
More information about the Zope-CVS
mailing list