def lsystem(file_name, axiom='', derivationlength=-1, parameters={}): """ Build a lsystem object from file_name """ l = Lsystem(file_name, parameters) if len(axiom): l.makeCurrent() if type(axiom) != AxialTree: axiom = AxialTree(axiom) l.axiom = axiom #l.done() if derivationlength >= 0: l.derivationLength = derivationlength return l
def lsystem(file_name, axiom = '', derivationlength = -1, parameters = {}): """ Build a lsystem object from file_name """ l = Lsystem(file_name, parameters) if len(axiom): l.makeCurrent() if type(axiom) != AxialTree: axiom = AxialTree(axiom) l.axiom = axiom #l.done() if derivationlength >= 0: l.derivationLength = derivationlength return l
def parse_extern_modules(lpyfile): """ Parse an lpyfile to retrieve its modules and expected extern parameters """ lines = list(open(lpyfile).readlines()) externs = set() def f(**kwd): nonlocal externs externs = externs.union(set(kwd.keys())) code = ''.join([l for l in lines if l.startswith('extern')]) n = {'extern' : f, 'externs' : externs} exec(code, n, n) code2 = ''.join([l for l in lines if l.startswith('module')]) from openalea.lpy import Lsystem l = Lsystem() l.setCode(code2) l.makeCurrent() modules = {} for m in l.execContext().declaredModules(): modules[m.name] = m.parameterNames l.done() return externs, modules