Bases: object
>>> from openalea.oalab.model.parse import InputObj
>>> obj = InputObj('a:float=1')
>>> obj.name
'a'
>>> obj.default
'1'
>>> obj.interface
IFloat
>>> obj
InputObj('a:IFloat=1')
Parameters: | string -- string object with format "input_name:input_type=input_default_value" or "input_name=input_default_value" or "input_name:input_type" or "input_name" |
---|
parse the code codestring and detect what are the functions defined inside :return: dict name -> code
Parse a docstring.
Returns: | model, inputs, outputs |
---|
parse a string (not a docstring), get the docstring and return information on the model.
Use: | model, inputs, outputs = parse_docstring(multiline_string_to_parse) |
---|---|
Parameters: | string -- docstring to parse (string) |
Returns: | model, inputs, outputs |
parse a string (not a docstring), get the docstring and return information on the model.
Use: | model, inputs, outputs = parse_docstring_r(multiline_string_to_parse) |
---|---|
Parameters: | string -- docstring to parse (string) |
Returns: | model, inputs, outputs |
Unused.
Returns: | model, inputs, outputs |
---|
parse the code codestring and detect what are the functions defined inside (search init, step, animate and run) :return: init, step, animate, run functions (code or False)
Unused.
Returns: | model, inputs, outputs |
---|
Use: | >>> from openalea.oalab.model.parse import parse_input_and_output
>>> comment = '''
... input = a:int=4, b
... output = r:float'''
>>> inputs, outputs = parse_input_and_output(comment)
>>> inputs
['a:int=4', 'b']
>>> outputs
['r:float']
|
---|---|
Returns: | inputs, outputs |
Take a lpy string_file, parse it and return only the docstring of the file.
Parameters: | string -- string representation of lpy file |
---|---|
Returns: | docstring of the file if exists (must be a multiline docstring!). If not found, return None. |
Use: | >>> f = open(lpyfilename, "r")
>>> lpystring = f.read()
>>> f.close()
>>>
>>> docstring = parse_lpy(lpystring)
>>>
>>> from openalea.oalab.model.parse import parse_doc
>>> if docstring is not None:
... model, inputs, outputs = parse_doc(docstring)
... print "model : ", model
... print "inputs : ", inputs
... print "outputs : ", outputs
|
>>> from openalea.oalab.model.parse import InputObj
>>> inputs_info = [InputObj('a:int=1'), InputObj('b:int=2')]
>>> prepare_inputs(inputs_info)
{'a':1, 'b':2}
>>> prepare_inputs(inputs_info, 10)
{'a':10, 'b':2}
>>> prepare_inputs(inputs_info, 10, 20)
{'a':10, 'b':20}