#! bpy
"""
Name: 'berlin-clock.py'
Blender: 27x
Group: 'Example'
Tooltip: 'Labelcreator--Blend4Web-Berlin-Clock'
"""
import bpy


def create_labels():
    "Create and compose labels for the berlin-clock"

    clock_labels = [["seconds",
                     "Sekunden",
                     "Blinkt im zwei Sekunden-Takt"],
                    ["hour_01",
                     "Stunden",
                     "Ein Block = 5 Stunden"],
                    ["hour_05",
                     "Stunden",
                     "Ein Block = 1 Stunden"],
                    ["minute_01",
                     "Minuten",
                     "Ein Block = 5 Min./alle 15 Min. eine andere Farbe"],
                    ["minute_12",
                     "Minuten", "Ein block = 1 Minute"]]

    scn = bpy.context.scene
    for row in clock_labels:
        cube = bpy.data.objects[row[0]]
        coords = cube.location
        bpy.ops.object.empty_add(type='PLAIN_AXES',
                                 location=(coords.x,
                                           coords.y,
                                           coords.z+1))

        obj = bpy.context.object
        obj.name = row[0]+"_label"
        obj.b4w_object_tags.title = row[1]
        obj.b4w_object_tags.description = row[2]
        obj.b4w_enable_object_tags = True
        obj.b4w_enable_anchor = True


if __name__ == '__main__':
    scn = bpy.context.scene
    for ob in scn.objects:
        if ob.type == 'EMPTY':
            scn.objects.unlink(ob)
            bpy.data.objects.remove(ob)

    create_labels()