[oe-commits] Chris Larson : oe.path: add 'find' convenience function

git version control git at git.openembedded.org
Sun Oct 10 04:17:12 UTC 2010


Module: openembedded.git
Branch: master
Commit: 7e76f8041cdc6ae588383193c320ff417be8a8b0
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=7e76f8041cdc6ae588383193c320ff417be8a8b0

Author: Chris Larson <chris_larson at mentor.com>
Date:   Sat Oct  9 17:47:28 2010 -0700

oe.path: add 'find' convenience function

find is simply an os.walk in generator form, yielding the absolute path to
each file.

Signed-off-by: Chris Larson <chris_larson at mentor.com>

---

 classes/package_dbg.bbclass |   13 +------------
 lib/oe/path.py              |   12 ++++++++++--
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/classes/package_dbg.bbclass b/classes/package_dbg.bbclass
index 19ab04f..4f4dd2f 100644
--- a/classes/package_dbg.bbclass
+++ b/classes/package_dbg.bbclass
@@ -12,17 +12,6 @@ PACKAGE_DBG_DESC = "Debugging files for %s"
 PACKAGE_DBG_EXCLUDE = "${PN}-locale* ${PN}-doc ${PN}-dev *-dbg"
 
 
-def __find(dir):
-    """ Given a directory, recurses into that directory,
-    returning all files. """
-
-    from os import walk
-    from os.path import join
-
-    for root, dirs, files in walk(dir):
-        for file in files:
-            yield join(root, file)
-
 def __package_get_files(pkg, d):
     """ Obtains a list of files to be included in a package.
 
@@ -42,7 +31,7 @@ def __package_get_files(pkg, d):
     for globbed in (glob(join(installdir, file[1:])) for file in files):
         for path in globbed:
             if isdir(path) and not islink(path):
-                for file in __find(path):
+                for file in oe.path.find(path):
                     yield file[installdirlen:]
             else:
                 yield path[installdirlen:]
diff --git a/lib/oe/path.py b/lib/oe/path.py
index 3d64cfa..65b438a 100644
--- a/lib/oe/path.py
+++ b/lib/oe/path.py
@@ -1,6 +1,7 @@
+import os
+
 def join(*paths):
     """Like os.path.join but doesn't treat absolute RHS specially"""
-    import os.path
     return os.path.normpath("/".join(paths))
 
 def relative(src, dest):
@@ -15,7 +16,6 @@ def relative(src, dest):
     >>> relative("/tmp", "/tmp/foo/bar")
     foo/bar
     """
-    import os.path
 
     if hasattr(os.path, "relpath"):
         return os.path.relpath(dest, src)
@@ -64,3 +64,11 @@ def symlink(source, destination, force=False):
     except OSError, e:
         if e.errno != errno.EEXIST or os.readlink(destination) != source:
             raise
+
+def find(dir, **walkoptions):
+    """ Given a directory, recurses into that directory,
+    returning all files as absolute paths. """
+
+    for root, dirs, files in os.walk(dir, **walkoptions):
+        for file in files:
+            yield os.path.join(root, file)





More information about the Openembedded-commits mailing list