summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2013-08-19 19:48:00 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-26 11:47:18 +0100
commit66eac2df0ccd0c7e17bf7f1117a7612d6151629c (patch)
treefd05559e9ab26c3952bcef3de683cd257ce90d9d /meta/lib
parent78012a289a0dac339b72ad14434dcd541e80e42c (diff)
downloadpoky-66eac2df0ccd0c7e17bf7f1117a7612d6151629c.tar.gz
oe.types: add 'path' type
- path normalization ('normalize' flag, defaults to enabled) - existence verification for paths we know should exist ('mustexist' flag) - supports clean handling of relative paths ('relativeto' flag) (From OE-Core rev: a598242197312fa6d43179c283da2d0873de2919) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/types.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py
index 5dac9de239..7f47c17d0e 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -1,4 +1,7 @@
1import errno
1import re 2import re
3import os
4
2 5
3class OEList(list): 6class OEList(list):
4 """OpenEmbedded 'list' type 7 """OpenEmbedded 'list' type
@@ -133,3 +136,18 @@ def float(value, fromhex='false'):
133 return _float.fromhex(value) 136 return _float.fromhex(value)
134 else: 137 else:
135 return _float(value) 138 return _float(value)
139
140def path(value, relativeto='', normalize='true', mustexist='false'):
141 value = os.path.join(relativeto, value)
142
143 if boolean(normalize):
144 value = os.path.normpath(value)
145
146 if boolean(mustexist):
147 try:
148 open(value, 'r')
149 except IOError as exc:
150 if exc.errno == errno.ENOENT:
151 raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT)))
152
153 return value