[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - include.py:1.9

Fred L. Drake, Jr. fred at zope.com
Tue Mar 30 21:18:43 EST 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv13937

Modified Files:
	include.py 
Log Message:
filter_names() can be a simple function; this is more conducive to
re-using it in a different context


=== Packages/zpkgtools/zpkgtools/include.py 1.8 => 1.9 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.8	Tue Mar 30 21:13:21 2004
+++ Packages/zpkgtools/zpkgtools/include.py	Tue Mar 30 21:18:41 2004
@@ -40,6 +40,17 @@
         ValueError.__init__(self, message)
 
 
+def filter_names(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
+
+
 class InclusionProcessor:
     """Handler for processing inclusion specifications.
 
@@ -113,7 +124,7 @@
             src = self.normalizePathOrURL(src, "source", filename, lineno)
             if src == "-":
                 path = os.path.join(self.source, dest)
-                expansions = self.filter_names(glob.glob(path))
+                expansions = filter_names(glob.glob(path))
                 if not expansions:
                     raise InclusionSpecificationError(
                         "exclusion %r doesn't match any files" % dest,
@@ -172,8 +183,8 @@
             os.mkdir(destination)
         prefix = os.path.join(source, "")
         for dirname, dirs, files in os.walk(source):
-            dirs[:] = self.filter_names(dirs)
-            files = self.filter_names(files)
+            dirs[:] = filter_names(dirs)
+            files = filter_names(files)
 
             # remove excluded directories:
             for dir in dirs[:]:
@@ -214,16 +225,6 @@
     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)




More information about the Zope-CVS mailing list