summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-06-27 10:12:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-07-01 08:49:37 +0100
commit58b0a65ada340fda3bc04fa9fcb648eb43246402 (patch)
tree982cfef481827b0f46d5bc753730604bb71323d8 /bitbake/lib/bb/utils.py
parentc02b7accd54ea657da9d771814b3dc92d0591127 (diff)
downloadpoky-58b0a65ada340fda3bc04fa9fcb648eb43246402.tar.gz
bitbake: utils: Refactor filemode variable conversion to a function
We have other places in the code where we need to take filemode/mask information from a bitbake variable and turn it into a real python number. Turn this internal code into public API in bb.utils and add some tests for it. (Bitbake rev: d89e30fb2fb15b09f2cb95c4e5aa9f749ca257ea) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index a2806fd360..1cc74ed546 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1211,6 +1211,23 @@ def which(path, item, direction = 0, history = False, executable=False):
1211 return "", hist 1211 return "", hist
1212 return "" 1212 return ""
1213 1213
1214def to_filemode(input):
1215 """
1216 Take a bitbake variable contents defining a file mode and return
1217 the proper python representation of the number
1218
1219 Arguments:
1220
1221 - ``input``: a string or number to convert, e.g. a bitbake variable
1222 string, assumed to be an octal representation
1223
1224 Returns the python file mode as a number
1225 """
1226 # umask might come in as a number or text string..
1227 if type(input) is int:
1228 return input
1229 return int(input, 8)
1230
1214@contextmanager 1231@contextmanager
1215def umask(new_mask): 1232def umask(new_mask):
1216 """ 1233 """