from coral.cgen.python.PyCodeGenerator import PyCodeGenerator
from coral import kernel as coral
import sys


if len(sys.argv) > 1:
    storage = coral.loadDocument(sys.argv[1])
    roots = storage.getRoots()
else:
    L = coral.Language.__getLanguage__("UML", 1, 4)
    
    m = L.Model()
    c1 = L.Class()
    c2 = L.Class()
    c3 = L.Class()
    g = L.Generalization()
    m.ownedElement = [ c1, c2, c3, g ]
    m.name = "My Model"
    c1.name = "Class A Space Is Escaped Like This"
    c2.name = "Class2"
    c3.name = "Class3"
    g.parent = c1
    g.child = c2
    roots = [ m ]

    o = L.Operation()
    c1.feature.add(o)
    method = L.Method()
    c1.feature.add(method)
    method.body.body = "foo\nbar\n"
    method.body.language = "python"
    method.specification = o
    o.ownerScope = "classifier"
    o.name = "mymethod"

import locale
locale.setlocale(locale.LC_ALL, "")

p = PyCodeGenerator("results")
p.generateCode( roots )
p.streamOut()

