[Zope-Checkins] CVS: Zope/inst - install.py:1.1.2.7

Fred L. Drake, Jr. fred@zope.com
Tue, 3 Dec 2002 14:33:13 -0500


Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv2904

Modified Files:
      Tag: chrism-install-branch
	install.py 
Log Message:
- Simplify default_omitpattern; it only needs to match a path's
  basename
- copydir():  Filter the list of names copied using omit()
- omit():  Don't compile the RE every time through, just let the re
  module take care of caching.


=== Zope/inst/install.py 1.1.2.6 => 1.1.2.7 ===
--- Zope/inst/install.py:1.1.2.6	Tue Dec  3 14:06:44 2002
+++ Zope/inst/install.py	Tue Dec  3 14:33:13 2002
@@ -23,10 +23,9 @@
 import stat
 import sys
 
-default_omitpattern = r'(.*~|CVS|\.[^./].*)$'
-# the last pattern in the group above allows relative paths
-# eg. "../../some/file" but attempts to prevent dotfiles from
-# making their way in.
+# RE that, if a pathname's base name matches, causes it to be ignored
+# when copying that file or directory.
+default_omitpattern = r'(\..*|CVS|.*~)$'
 
 def main(src, dst, symlinks=1, dirmode=0755, fmode=0644,
          omitpattern=default_omitpattern, retain_xbit=1):
@@ -76,7 +75,7 @@
             pass
         else:
             raise
-    for name in names:
+    for name in omit(names, omitpattern):
         srcname = os.path.join(src, name)
         dstname = os.path.join(dst, name)
         if symlinks and os.path.islink(srcname):
@@ -109,8 +108,8 @@
 omitcache = {}
 
 def omit(names, omitpattern):
-    match = omitcache.setdefault(omitpattern, re.compile(omitpattern).match)
-    return [ n for n in names if not match(n) ]
+    return [ n for n in names
+             if not re.match(omitpattern, os.path.basename(n)) ]
 
 def usage():
     print "%s [opts] source dest" % sys.argv[0]
@@ -182,4 +181,3 @@
         if o == '--dontcopyxbit':
             retain_xbit = 0
     main(source, dest, symlinks, dirmode, fmode, omitpattern, retain_xbit)
-