* [PATCH] oe.types: add 'path' type
@ 2013-08-20 2:48 Christopher Larson
2013-08-20 15:23 ` Otavio Salvador
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2013-08-20 2:48 UTC (permalink / raw)
To: openembedded-core; +Cc: Christopher Larson
From: Christopher Larson <chris_larson@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_larson@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] oe.types: add 'path' type
2013-08-20 2:48 [PATCH] oe.types: add 'path' type Christopher Larson
@ 2013-08-20 15:23 ` Otavio Salvador
2013-08-20 15:45 ` Chris Larson
0 siblings, 1 reply; 3+ messages in thread
From: Otavio Salvador @ 2013-08-20 15:23 UTC (permalink / raw)
To: Christopher Larson
Cc: Christopher Larson,
Patches and discussions about the oe-core layer
On Mon, Aug 19, 2013 at 11:48 PM, Christopher Larson <kergoth@gmail.com> wrote:
> From: Christopher Larson <chris_larson@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_larson@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.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] oe.types: add 'path' type
2013-08-20 15:23 ` Otavio Salvador
@ 2013-08-20 15:45 ` Chris Larson
0 siblings, 0 replies; 3+ messages in thread
From: Chris Larson @ 2013-08-20 15:45 UTC (permalink / raw)
To: Otavio Salvador; +Cc: Patches and discussions about the oe-core layer
[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]
On Tue, Aug 20, 2013 at 8:23 AM, Otavio Salvador <otavio@ossystems.com.br>wrote:
> On Mon, Aug 19, 2013 at 11:48 PM, Christopher Larson <kergoth@gmail.com>
> wrote:
> > From: Christopher Larson <chris_larson@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_larson@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
[-- Attachment #2: Type: text/html, Size: 1859 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-20 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 2:48 [PATCH] oe.types: add 'path' type Christopher Larson
2013-08-20 15:23 ` Otavio Salvador
2013-08-20 15:45 ` Chris Larson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox