Re: [OE-core] [PATCH] oe.types: add 'path' type

2013-08-20 Thread Otavio Salvador
On Mon, Aug 19, 2013 at 11:48 PM, Christopher Larson kerg...@gmail.com wrote:
 From: Christopher Larson chris_lar...@mentor.com

 - 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_lar...@mentor.com

Great addition :-)

 ---
  meta/lib/oe/types.py | 18 ++
  1 file changed, 18 insertions(+)

 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
 +

No need for another new and empty line here.

Rest of code looks alright :-)

-- 
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9981-7854Mobile: +1 (347) 903-9750
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] oe.types: add 'path' type

2013-08-20 Thread Chris Larson
On Tue, Aug 20, 2013 at 8:23 AM, Otavio Salvador ota...@ossystems.com.brwrote:

 On Mon, Aug 19, 2013 at 11:48 PM, Christopher Larson kerg...@gmail.com
 wrote:
  From: Christopher Larson chris_lar...@mentor.com
 
  - 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_lar...@mentor.com

 Great addition :-)

  ---
   meta/lib/oe/types.py | 18 ++
   1 file changed, 18 insertions(+)
 
  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
  +

 No need for another new and empty line here.

 Rest of code looks alright :-)


Good call, will tweak slightly and re-submit. Thanks for the review.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] oe.types: add 'path' type

2013-08-19 Thread Christopher Larson
From: Christopher Larson chris_lar...@mentor.com

- 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_lar...@mentor.com
---
 meta/lib/oe/types.py | 18 ++
 1 file changed, 18 insertions(+)

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
-- 
1.8.3.4

___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core