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-23 15:43:54 +0000 |
commit | c9d1e20ab75fa21606c38f7f9d88d879117b3ce9 (patch) | |
tree | 886c38bd51f1bb802a57e30b197d5919bde1f8b7 /meta/lib/oe | |
parent | 21a3b6de9d6b6a47f2019150875c5ff75c5d2822 (diff) | |
download | poky-c9d1e20ab75fa21606c38f7f9d88d879117b3ce9.tar.gz |
oe.path: sync up with current OE
(From OE-Core rev: 1958b303f98b8db5bab00344823bbb8e086b8dba)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-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 @@ | |||
1 | import bb | ||
2 | import errno | ||
3 | import glob | ||
4 | import os | ||
1 | import shutil | 5 | import shutil |
2 | import subprocess | 6 | import subprocess |
3 | 7 | ||
4 | def join(*paths): | 8 | def join(*paths): |
5 | """Like os.path.join but doesn't treat absolute RHS specially""" | 9 | """Like os.path.join but doesn't treat absolute RHS specially""" |
6 | import os.path | ||
7 | return os.path.normpath("/".join(paths)) | 10 | return os.path.normpath("/".join(paths)) |
8 | 11 | ||
9 | def relative(src, dest): | 12 | def relative(src, dest): |
@@ -18,7 +21,6 @@ def relative(src, dest): | |||
18 | >>> relative("/tmp", "/tmp/foo/bar") | 21 | >>> relative("/tmp", "/tmp/foo/bar") |
19 | foo/bar | 22 | foo/bar |
20 | """ | 23 | """ |
21 | import os.path | ||
22 | 24 | ||
23 | if hasattr(os.path, "relpath"): | 25 | if hasattr(os.path, "relpath"): |
24 | return os.path.relpath(dest, src) | 26 | return os.path.relpath(dest, src) |
@@ -57,21 +59,19 @@ def copytree(src, dst): | |||
57 | check_output(cmd, shell=True, stderr=subprocess.STDOUT) | 59 | check_output(cmd, shell=True, stderr=subprocess.STDOUT) |
58 | 60 | ||
59 | 61 | ||
60 | def remove(path): | 62 | def remove(path, recurse=True): |
61 | """Equivalent to rm -f or rm -rf""" | 63 | """Equivalent to rm -f or rm -rf""" |
62 | import os, errno, shutil, glob | ||
63 | for name in glob.glob(path): | 64 | for name in glob.glob(path): |
64 | try: | 65 | try: |
65 | os.unlink(name) | 66 | os.unlink(name) |
66 | except OSError, exc: | 67 | except OSError, exc: |
67 | if exc.errno == errno.EISDIR: | 68 | if recurse and exc.errno == errno.EISDIR: |
68 | shutil.rmtree(path) | 69 | shutil.rmtree(name) |
69 | elif exc.errno != errno.ENOENT: | 70 | elif exc.errno != errno.ENOENT: |
70 | raise | 71 | raise |
71 | 72 | ||
72 | def symlink(source, destination, force=False): | 73 | def symlink(source, destination, force=False): |
73 | """Create a symbolic link""" | 74 | """Create a symbolic link""" |
74 | import os, errno | ||
75 | try: | 75 | try: |
76 | if force: | 76 | if force: |
77 | remove(destination) | 77 | remove(destination) |
@@ -121,3 +121,10 @@ def check_output(*popenargs, **kwargs): | |||
121 | raise CalledProcessError(retcode, cmd, output=output) | 121 | raise CalledProcessError(retcode, cmd, output=output) |
122 | return output | 122 | return output |
123 | 123 | ||
124 | def find(dir, **walkoptions): | ||
125 | """ Given a directory, recurses into that directory, | ||
126 | returning all files as absolute paths. """ | ||
127 | |||
128 | for root, dirs, files in os.walk(dir, **walkoptions): | ||
129 | for file in files: | ||
130 | yield os.path.join(root, file) | ||