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

Fred L. Drake, Jr. fred at zope.com
Thu Apr 1 15:21:32 EST 2004


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

Modified Files:
	app.py include.py 
Log Message:
More changes to the InclusionProcessor API: it knows less than even about
the context of what it does.  This allows the application class to be simpler
as well.


=== Packages/zpkgtools/zpkgtools/app.py 1.8 => 1.9 ===
--- Packages/zpkgtools/zpkgtools/app.py:1.8	Thu Apr  1 14:13:02 2004
+++ Packages/zpkgtools/zpkgtools/app.py	Thu Apr  1 15:21:01 2004
@@ -70,20 +70,20 @@
         # This could be either a package distribution or a collection
         # distribution; it's the former if there's an __init__.py in
         # the source directory.
+        os.mkdir(self.destination)
+        self.ip = include.InclusionProcessor(self.source)
         name = "build_%s_distribution" % self.resource_type
         method = getattr(self, name)
         method()
         self.generate_setup()
 
     def build_package_distribution(self):
-        os.mkdir(self.destination)
         pkgname = self.metadata.name
 
-        self.ip = include.InclusionProcessor(
-            self.source, os.path.join(self.destination, pkgname))
         self.manifest = self.ip.add_manifest(self.destination)
+        pkgdest = os.path.join(self.destination, pkgname)
         try:
-            self.ip.createDistributionTree()
+            self.ip.createDistributionTree(pkgdest)
         except cvsloader.CvsLoadingError, e:
             print >>sys.stderr, e
             sys.exit(1)
@@ -103,11 +103,9 @@
 
     def build_collection_distribution(self):
         # Build the destination directory:
-        self.ip = include.InclusionProcessor(self.source,
-                                             self.destination)
         self.manifest = self.ip.add_manifest(self.destination)
         try:
-            self.ip.createDistributionTree()
+            self.ip.createDistributionTree(self.destination)
         except cvsloader.CvsLoadingError, e:
             print >>sys.stderr, e
             sys.exit(1)
@@ -142,12 +140,12 @@
     def generate_setup(self):
         setup_py = os.path.join(self.destination, "setup.py")
         self.ip.add_output(setup_py)
-        pkgname = self.resource_name
         type = self.resource_type
         f = open(setup_py, "w")
         print >>f, SETUP_HEADER
         print >>f, "context = zpkgtools.setup.%sContext(" % type.capitalize()
-        print >>f, "    %r, %r, __file__)" % (pkgname, self.options.version)
+        print >>f, "    %r, %r, __file__)" % (self.resource_name,
+                                              self.options.version)
         print >>f
         print >>f, "context.setup()"
         f.close()


=== Packages/zpkgtools/zpkgtools/include.py 1.18 => 1.19 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.18	Thu Apr  1 14:40:46 2004
+++ Packages/zpkgtools/zpkgtools/include.py	Thu Apr  1 15:21:01 2004
@@ -150,26 +150,32 @@
     the output tree.
 
     """
-    def __init__(self, source, destination):
+    def __init__(self, source):
         if not os.path.exists(source):
             raise InclusionError("source directory does not exist: %r"
                                  % source)
         self.source = os.path.abspath(source)
-        self.destination = os.path.abspath(destination)
         self.manifests = []
         self.cvs_loader = None
 
-    def createDistributionTree(self, spec=None):
-        """Create the output tree according to the loaded specification.
+    def createDistributionTree(self, destination, spec=None):
+        """Create the output tree according to `specification`.
+
+        :Parameters:
+          - `destination`: Path of the top-level output directory.
+            This directory will be created if it doesn't exist.
+
+          - `spec`: ``Specification`` object that describes what to
+            include and exclude.  If omitted, an empty specification
+            is used.
 
-        The destination directory will be created if it doesn't
-        already exist.
         """
         if spec is None:
             spec = Specification(self.source)
-        self.copyTree(spec.source, self.destination, spec.excludes)
+        destination = os.path.abspath(destination)
+        self.copyTree(spec.source, destination, spec.excludes)
         for relpath, source in spec.includes.iteritems():
-            self.addSingleInclude(relpath, source, self.destination)
+            self.addSingleInclude(relpath, source, destination)
 
     def copyTree(self, source, destination, excludes={}):
         """Populate the destination tree from the source tree.




More information about the Zope-CVS mailing list