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

Fred L. Drake, Jr. fred at zope.com
Mon May 17 12:12:18 EDT 2004


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

Modified Files:
	include.py 
Log Message:
factor out common directory creation code, creating the directory only if it
does not already exist


=== Packages/zpkgtools/zpkgtools/include.py 1.40 => 1.41 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.40	Tue May 11 01:04:56 2004
+++ Packages/zpkgtools/zpkgtools/include.py	Mon May 17 12:12:16 2004
@@ -305,10 +305,7 @@
         """
         destination = os.path.abspath(destination)
         if spec.includes:
-            if not os.path.exists(destination):
-                os.mkdir(destination)
-                shutil.copymode(spec.source, destination)
-                shutil.copystat(spec.source, destination)
+            self.create_directory(spec.source, destination)
             self.addIncludes(destination, spec)
         else:
             self.copyTree(spec.source, destination)
@@ -327,10 +324,7 @@
         Files and directories will be created with the same permission
         bits and stat info as the source tree.
         """
-        if not os.path.exists(destination):
-            os.mkdir(destination)
-            shutil.copymode(source, destination)
-            shutil.copystat(source, destination)
+        self.create_directory(source, destination)
         prefix = os.path.join(source, "")
         for dirname, dirs, files in os.walk(source, topdown=True):
             dirs[:] = filter_names(dirs)
@@ -357,11 +351,15 @@
                 if publication.PUBLICATION_CONF in os.listdir(srcname):
                     dirs.remove(dir)
                     continue
-                # Create the directory, copying over the permission
-                # bits and stat info.
-                os.mkdir(destname)
-                shutil.copymode(srcname, destname)
-                shutil.copystat(srcname, destname)
+                self.create_directory(srcname, destname)
+
+    def create_directory(self, source, destination):
+        if not os.path.exists(destination):
+            # Create the directory, copying over the permission
+            # bits and stat info.
+            os.mkdir(destination)
+            shutil.copymode(source, destination)
+            shutil.copystat(source, destination)
 
     def copy_file(self, source, destination):
         """Copy a single file into the output tree."""




More information about the Zope-CVS mailing list