mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
21a3b6de9d
commit
c9d1e20ab7
|
@ -1,9 +1,12 @@
|
||||||
|
import bb
|
||||||
|
import errno
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def join(*paths):
|
def join(*paths):
|
||||||
"""Like os.path.join but doesn't treat absolute RHS specially"""
|
"""Like os.path.join but doesn't treat absolute RHS specially"""
|
||||||
import os.path
|
|
||||||
return os.path.normpath("/".join(paths))
|
return os.path.normpath("/".join(paths))
|
||||||
|
|
||||||
def relative(src, dest):
|
def relative(src, dest):
|
||||||
|
@ -18,7 +21,6 @@ def relative(src, dest):
|
||||||
>>> relative("/tmp", "/tmp/foo/bar")
|
>>> relative("/tmp", "/tmp/foo/bar")
|
||||||
foo/bar
|
foo/bar
|
||||||
"""
|
"""
|
||||||
import os.path
|
|
||||||
|
|
||||||
if hasattr(os.path, "relpath"):
|
if hasattr(os.path, "relpath"):
|
||||||
return os.path.relpath(dest, src)
|
return os.path.relpath(dest, src)
|
||||||
|
@ -57,21 +59,19 @@ def copytree(src, dst):
|
||||||
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
|
||||||
def remove(path):
|
def remove(path, recurse=True):
|
||||||
"""Equivalent to rm -f or rm -rf"""
|
"""Equivalent to rm -f or rm -rf"""
|
||||||
import os, errno, shutil, glob
|
|
||||||
for name in glob.glob(path):
|
for name in glob.glob(path):
|
||||||
try:
|
try:
|
||||||
os.unlink(name)
|
os.unlink(name)
|
||||||
except OSError, exc:
|
except OSError, exc:
|
||||||
if exc.errno == errno.EISDIR:
|
if recurse and exc.errno == errno.EISDIR:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(name)
|
||||||
elif exc.errno != errno.ENOENT:
|
elif exc.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def symlink(source, destination, force=False):
|
def symlink(source, destination, force=False):
|
||||||
"""Create a symbolic link"""
|
"""Create a symbolic link"""
|
||||||
import os, errno
|
|
||||||
try:
|
try:
|
||||||
if force:
|
if force:
|
||||||
remove(destination)
|
remove(destination)
|
||||||
|
@ -121,3 +121,10 @@ def check_output(*popenargs, **kwargs):
|
||||||
raise CalledProcessError(retcode, cmd, output=output)
|
raise CalledProcessError(retcode, cmd, output=output)
|
||||||
return 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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user