[oe-commits] Christopher Larson : oe.types: add 'path' type
git at git.openembedded.org
git at git.openembedded.org
Mon Aug 26 09:55:51 UTC 2013
Module: openembedded-core.git
Branch: master-next
Commit: 0a7ba71978af281ac56aaa6e10b5af6525c9f861
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=0a7ba71978af281ac56aaa6e10b5af6525c9f861
Author: Christopher Larson <chris_larson at mentor.com>
Date: Mon Aug 19 19:48:00 2013 -0700
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)
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
Signed-off-by: Saul Wold <sgw at linux.intel.com>
---
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 5dac9de..7f47c17 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -1,4 +1,7 @@
+import errno
import re
+import os
+
class OEList(list):
"""OpenEmbedded 'list' type
@@ -133,3 +136,18 @@ def float(value, fromhex='false'):
return _float.fromhex(value)
else:
return _float(value)
+
+def path(value, relativeto='', normalize='true', mustexist='false'):
+ value = os.path.join(relativeto, value)
+
+ if boolean(normalize):
+ value = os.path.normpath(value)
+
+ if boolean(mustexist):
+ try:
+ open(value, 'r')
+ except IOError as exc:
+ if exc.errno == errno.ENOENT:
+ raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT)))
+
+ return value
More information about the Openembedded-commits
mailing list