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

Fred L. Drake, Jr. fred at zope.com
Wed Mar 31 13:32:49 EST 2004


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

Modified Files:
	include.py 
Log Message:
clean up the API for handling manifest lists, and add a comment
explaining why this approach is used


=== Packages/zpkgtools/zpkgtools/include.py 1.13 => 1.14 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.13	Wed Mar 31 01:02:03 2004
+++ Packages/zpkgtools/zpkgtools/include.py	Wed Mar 31 13:32:48 2004
@@ -144,8 +144,7 @@
                                  % source)
         self.source = os.path.abspath(source)
         self.destination = os.path.abspath(destination)
-        self.manifest = []
-        self.manifest_prefix = os.path.join(self.destination, "")
+        self.manifests = []
         prefix = os.path.commonprefix([self.source, self.destination])
         if prefix == self.source:
             raise InclusionError("destination directory may not be"
@@ -220,14 +219,36 @@
         self.add_output(destination)
 
     def add_output(self, path):
-        # we're going to build the manifest here
-        assert path.startswith(self.manifest_prefix)
-        relpath = path[len(self.manifest_prefix):]
-        parts = relpath.split(os.sep)
-        if len(parts) == 1:
-            self.manifest.append(parts[0])
-        else:
-            self.manifest.append(posixpath.join(*parts))
+        """Add 'path' to each of the relevant manifests."""
+        for prefix, manifest in self.manifests:
+            if path.startswith(prefix):
+                relpath = path[len(prefix):]
+                parts = relpath.split(os.sep)
+                if len(parts) == 1:
+                    manifest.append(parts[0])
+                else:
+                    manifest.append(posixpath.join(*parts))
+
+    # This pair of methods handles the creation and removal of
+    # manifest lists.  We use this approach since we need to support
+    # multiple manifests for collection distributions (each component
+    # will have a manifest of it's own, as well as the package as a
+    # whole).  This makes managing manifests a function of the client
+    # rather than being implicit.
+
+    def add_manifest(self, destination):
+        manifest = []
+        prefix = os.path.join(destination, "")
+        self.manifests.append((prefix, manifest))
+        return manifest
+
+    def drop_manifest(self, destination):
+        prefix = os.path.join(destination, "")
+        for i in range(len(self.manifests)):
+            if self.manifests[i][0] == prefix:
+                del self.manifests[i]
+                return
+        raise ValueError("no manifest for %s" % destination)
 
     def addSingleInclude(self, relpath, source):
         dirname, basename = os.path.split(relpath)




More information about the Zope-CVS mailing list