diff options
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/types.py | 18 |
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 @@ | |||
1 | import errno | ||
1 | import re | 2 | import re |
3 | import os | ||
4 | |||
2 | 5 | ||
3 | class OEList(list): | 6 | class 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 | |||
140 | def 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 | ||