diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-02-09 06:55:16 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-03-21 17:51:10 +0000 |
commit | 1958b303f98b8db5bab00344823bbb8e086b8dba (patch) | |
tree | 4eb64047ff65aa1f114a458a0469a5d055711953 /meta/lib | |
parent | cefbf3a14fcf87e18f7a63a1f55904d9d612ed3e (diff) | |
download | openembedded-core-1958b303f98b8db5bab00344823bbb8e086b8dba.tar.gz openembedded-core-1958b303f98b8db5bab00344823bbb8e086b8dba.tar.bz2 openembedded-core-1958b303f98b8db5bab00344823bbb8e086b8dba.zip |
oe.path: sync up with current OE
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/path.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 08ddbf22aa..8eaa3c5da4 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py @@ -1,9 +1,12 @@ +import bb +import errno +import glob +import os import shutil import subprocess 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): @@ -18,7 +21,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) @@ -57,21 +59,19 @@ def copytree(src, dst): check_output(cmd, shell=True, stderr=subprocess.STDOUT) -def remove(path): +def remove(path, recurse=True): """Equivalent to rm -f or rm -rf""" - import os, errno, shutil, glob for name in glob.glob(path): try: os.unlink(name) except OSError, exc: - if exc.errno == errno.EISDIR: - shutil.rmtree(path) + if recurse and exc.errno == errno.EISDIR: + shutil.rmtree(name) elif exc.errno != errno.ENOENT: raise def symlink(source, destination, force=False): """Create a symbolic link""" - import os, errno try: if force: remove(destination) @@ -121,3 +121,10 @@ def check_output(*popenargs, **kwargs): raise CalledProcessError(retcode, cmd, output=output) return output +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) |