Add set_if(), prepend_if(), and append_if() support

Use set_if(), to conditionally set a specific value.  This will be
supported for all variable types.  Example:
   FOOBAR = "foo"
   BAR = "f"
   FOOBAR.set_if(BAR=='f', 'bar')
which should yield FOOBAR='bar'.

For sequence types, prepend_if and append_if will conditionally prepend
and append values.

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Change str() function behavior on unset Variables

Instead of returning None, return empty string ('').

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Add Bool, Int and Float variable support

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
tests: Add test recipes for bool, int and float parsing

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Add support for implicit string type on string formating op

Add support for assigning a string using string formatting without first
declaring (assigning) as a string.

So instead of having to write
    FOOBAR=String()
    FOOBAR="%s and %s"%(FOO, BAR)
or
    FOOBAR=String("%s and %s"%(FOO, BAR))

you can just do
    FOOBAR="%s and %s"%(FOO, BAR)

and the parser will implicitly wrap it in a String() function call.

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Simplify Sequence API, removing a bunch of wrapper methods

This commit drops all the convenience wrappers for __getitem__, __len__,
and so on.  They were simply calling get() and the variable, and then
calling the underlying method.

Let's not waste time adding and maintaining all this.

Also, the API is a bit clearer when you can see that you are actually
calling get(), instead of having it done implicitly.  Especially since we
cannot wrap the most important access method, namely the get().

And for recipe/eval context, it is all wrapped nicely by the EvalWrapper
class.

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Cleanup Variable code

Put common code into methods, making it easier to add more variable types.

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Redefine Variable __str__ API

Instead of giving a human readable representation of the get() value, just
return a representation of the class name and variable name (if set).

Using str() on Variable instances will yield values like:
    String(FOO)
    String()
    Int(I)

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
A few extra unittests

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Add List variable support

In recipe context, you can do stuff like:

    LIST = ['foo', 'bar', 'bad stuff']
    LIST.remove('bad stuff')
    LIST.remove_if(BAR, 'bar')
    LIST.remove_if(FOO, 'foo')
    LIST.sort()
    OTHER = List(LIST)
    OTHER.extend(['hello', 'world'])
    BAR = True
    OTHER.prepend('before')
    OTHER.append('after')

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
tests: Add test recipe for list parsing

Signed-off-by: Esben Haabendal <esben@haabendal.dk>
Merge pull request #4 from esben/master

Conditional ops (set_if, append_if, prepend_if), Bool, Int, Float and List types, and a minor String improvement