diff options
Diffstat (limited to 'lib/oe/_types.py')
-rw-r--r-- | lib/oe/_types.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/oe/_types.py b/lib/oe/_types.py index 91afb8ab5d..b36060ff47 100644 --- a/lib/oe/_types.py +++ b/lib/oe/_types.py @@ -1,6 +1,13 @@ import re class OEList(list): + """OpenEmbedded 'list' type + + Acts as an ordinary list, but is constructed from a string value and a + separator (optional), and re-joins itself when converted to a string with + str(). Set the variable type flag to 'list' to use this type, and the + 'separator' flag may be specified (defaulting to whitespace).""" + name = "list" def __init__(self, value, separator = None): @@ -18,6 +25,11 @@ class OEList(list): return self.separator.join(self) def choice(value, choices): + """OpenEmbedded 'choice' type + + Acts as a multiple choice for the user. To use this, set the variable + type flag to 'choice', and set the 'choices' flag to a space separated + list of valid values.""" if not isinstance(value, basestring): raise TypeError("choice accepts a string, not '%s'" % type(value)) @@ -29,6 +41,15 @@ def choice(value, choices): return value def regex(value, regexflags=None): + """OpenEmbedded 'regex' type + + Acts as a regular expression, returning the pre-compiled regular + expression pattern object. To use this type, set the variable type flag + to 'regex', and optionally, set the 'regexflags' type to a space separated + list of the flags to control the regular expression matching (e.g. + FOO[regexflags] += 'ignorecase'). See the python documentation on the + 're' module for a list of valid flags.""" + flagval = 0 if regexflags: for flag in regexflags.split(): @@ -45,6 +66,12 @@ def regex(value, regexflags=None): (value, exc.args[0])) def boolean(value): + """OpenEmbedded 'boolean' type + + Valid values for true: 'yes', 'y', 'true', 't', '1' + Valid values for false: 'no', 'n', 'false', 'f', '0' + """ + if not isinstance(value, basestring): raise TypeError("boolean accepts a string, not '%s'" % type(value)) @@ -56,4 +83,5 @@ def boolean(value): raise ValueError("Invalid boolean value '%s'" % value) def integer(value): + """OpenEmbedded 'integer' type""" return int(value) |