Branch 'maintenance' - genpkgmetadata.py

[email protected] (Seth Vidal)
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 genpkgmetadata.py |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit b5f78272f80a792d33f9155b61bd5e132bbafdea
Author: Seth Vidal <[email protected]>
Date:   Mon Nov 26 12:44:45 2007 -0500

    import local os.walk and fix symlink problem in it
    finally closes: rh bug 228827

diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index 3b7eff6..bef0225 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -76,6 +76,21 @@ class MetaDataGenerator:
         self.pkgcount = 0
         self.files = []
 
+    def _os_path_walk(self, top, func, arg):
+        """Directory tree walk with callback function.
+         copy of os.path.walk, fixes the link/stating problem
+         """
+
+        try:
+            names = os.listdir(top)
+        except os.error:
+            return
+        func(arg, top, names)
+        for name in names:
+            name = os.path.join(top, name)
+            if os.path.isdir(name):
+                self._os_path_walk(name, func, arg)
+
     def getFileList(self, basepath, directory, ext):
         """Return all files in path matching ext, store them in filelist,
         recurse dirs. Returns a list object"""
@@ -95,7 +110,7 @@ class MetaDataGenerator:
 
         filelist = []
         startdir = os.path.join(basepath, directory) + '/'
-        os.path.walk(startdir, extension_visitor, filelist)
+        self._os_path_walk(startdir, extension_visitor, filelist)
         return filelist
 
     def checkTimeStamps(self, directory):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.