Classes

Node

class Node

Node class for creating directory trees.

Needed for some projects that have to store file entries in nested trees

Public Functions

__init__(self, value, children=None)

Create a node with an initial value.

Parameters
  • value – Object to be the value of this node

  • children – Array of nodes to be added as children to this one

__repr__(self, level=0)

Display this node as a string.

Parameters

level – Recursion depth (Used internally)

__str__(self, level=0)

Display this node as a string.

Parameters

level – Recursion depth (Used internally)

Public Members

value

Value contained in this node.

children

Array of children nodes to this node.

Interceptstdout

burger.Interceptstdout : public list

Handy class for capturing stdout from tools and python itself.

Examples

# Import the class
from burger import Interceptstdout

# Instanciate the class, which intercepts stdout
with Interceptstdout() as output: do_somethingthatprints()
    print("capture me!")

# Once out of scope, output has a list of strings
# of the captured stdout output.
print(output)

Public Functions

__init__(self)

Declares the internal variables.

__enter__(self)

Invoked on “with” which intercepts all future stdout.

__exit__(self, *args)

Disconnect the stdout and store the items into a list of lines.

Using splitlines(), output the buffer into a list of lines into the output field.

BooleanProperty

burger.validators.BooleanProperty : public burger.validators.Property

Class to enforce bool in member variable.

Examples

"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to false"
    x = BooleanProperty(False)
    "Init to true"
    y = BooleanProperty(True)
    "Init to None"
    z = BooleanProperty()

"Create the class"
f = foo()

"Print True"
print(f.x)

"Print False"
f.x = False
print(f.x)

"f.x is set to bool False with string"
f.x = "False"
print(f.x)

"Exception on bad write"
f.x = "not boolean"
Traceback (most recent call last):
    ...
ValueError: Not boolean value

Public Functions

__set__(self, instance, value)

Set the boolean value.

Exception

ValueError on invalid input.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool

IntegerProperty

burger.validators.IntegerProperty : public burger.validators.Property

Class to enforce 64 bit integer in variable.

Examples

"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to 1"
    x = IntegerProperty(1.0)
    "Init to 55"
    y = IntegerProperty("55")
    "Init to None"
    z = IntegerProperty()

"Create the class"
f = foo()

"Print 1"
print(f.x)

"Print 0"
f.x = False
print(f.x)

"f.x is set to 99 with string"
f.x = "99.00"
print(f.x)

"Exception on bad write"
f.x = "not boolean"
Traceback (most recent call last):
    ...
ValueError: Not integer value

Public Functions

__set__(self, instance, value)

Set the integer value.

Exception

ValueError on invalid input.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool

StringProperty

burger.validators.StringProperty : public burger.validators.Property

Class to enforce string in member variable.

Examples

"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to \"foo\""
    x = StringProperty("foo")
    "Init to None"
    y = StringProperty()

"Create the class"
f = foo()

"Print foo"
print(f.x)

"Print False"
f.x = "False"
print(f.x)

"Print True"
f.x = True
print(f.x)

Public Functions

__set__(self, instance, value)

Set the string value.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool

StringListProperty

burger.validators.StringListProperty : public burger.validators.Property

Class to enforce string list in member variable.

Examples

"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to [\"foo\"]"
    x = StringListProperty("foo")
    "Init to None"
    y = StringListProperty()
    "Init to [\"a\",\"b\",\"c\"]"
    z = StringListProperty(["a","b","c"])

"Create the class"
f = foo()

"Print [\"foo\"]"
print(f.x)

"Print [\"False\"]"
f.x = "False"
print(f.x)

"Print True"
f.x = True
print(f.x)

Public Functions

__get__(self, instance, owner=None)

Return value.

Parameters
  • instance – Reference to object containing data

  • owner – Not used

Returns

None, or verified data

__set__(self, instance, value)

Set the string value.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool

EnumProperty

burger.validators.EnumProperty : public burger.validators.Property

Class to enforce string list in member variable.

Examples

j = (("a", "b", "c"), "d", "e", ["f", "g", "h"], "i")
"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to 0"
    x = EnumProperty(j, "a")
    "Init to 0"
    y = EnumProperty(j)
    "Init to 4"
    z = EnumProperty(j, "i")

"Create the class"
f = foo()

"Print 0"
print(f.x)

"Print 2"
f.x = "g"
print(f.x)

"Print 2"
f.x = "h"
print(f.x)

Public Functions

__init__(self, name, enums)

Initialize to default.

Parameters
  • name – Name of the instance storage index

  • enums – list of enumeration strings

__set__(self, instance, value)

Set the string value.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool

NoneProperty

class NoneProperty

Class to enforce None in member variable.

Examples

"Inherit from (object) for Python 2.7"
>>> class foo(object):
    "Init to None"
    x = NoneProperty()

"Create the class"
f = foo()

"Print None"
print(f.x)

"Exception on non None data"
f.x = "not None"
Traceback (most recent call last):
    ...
ValueError: Not None value

Public Functions

__init__(self, name)

Initialize to default.

Parameters

name – Name of the instance storage index

__get__(self, instance, owner=None)

Return None.

Parameters
  • instance – Reference to object containing data

  • owner – Not used

Returns

None, or verified data

__set__(self, instance, value)

Throw if not None.

Parameters
  • instance – Reference to object containing data

  • value – None or value the can be converted to bool