6.1.1.2.1.1.1.1.1.2. pycropml.transpiler.antlr_py.apsim.run module

class pycropml.transpiler.antlr_py.apsim.run.CheckingInOut2(env_init=None, isAlgo=False)[source]

Bases: Middleware

_summary_ This code defines a middleware class called “CheckingInOut” that checks the inputs and outputs of a given code block. It does this by keeping track of the current scope and environment, and adding any new variables to the environment. It also keeps track of the inputs and outputs of the code block by checking if a variable is already in the current scope or not. The middleware class has methods for different types of statements and expressions, such as assignment, if statements, for loops, and function calls. The purpose of this middleware is to ensure that the inputs and outputs of a code block are well-defined and can be used by other parts of a program.

action_assignment(tree)[source]
action_binary_op(tree)[source]
action_custom_call(tree)[source]
action_declaration(tree)[source]
action_for_iterator(tree)[source]
action_for_range_statement(tree)[source]
action_for_statement(tree)[source]
action_if_statement(tree)[source]
action_implicit_return(tree)[source]
action_local(tree)[source]
action_member_access(tree)[source]
action_standard_call(tree)[source]
action_standard_method_call(tree)[source]
action_while_statement(tree)[source]
current()[source]
process(tree)[source]
workflow(tree)[source]
class pycropml.transpiler.antlr_py.apsim.run.Custom_call2(vars, extfunc=[], not_declared={}, ext_func_inout={}, member_category={})[source]

Bases: Middleware

action_custom_call(tree)[source]
process(tree)[source]
class pycropml.transpiler.antlr_py.apsim.run.For_statement2[source]

Bases: Middleware

action_for_statement(tree)[source]

_summary_

{‘type’: ‘for_sequence’, ‘sequence’: {‘type’: ‘local’, ‘name’: ‘soilConstituentNames’, ‘pseudo_type’: [‘array’, ‘string’]}}, ‘iterators’: {‘type’: ‘for_iterator’, ‘iterator’: {‘type’: ‘local’, ‘name’: ‘constituentName’, ‘pseudo_type’: ‘var’}}

process(tree)[source]
class pycropml.transpiler.antlr_py.apsim.run.Local2(declnames=[], params={})[source]

Bases: Middleware

action_local(tree)[source]
process(tree)[source]
class pycropml.transpiler.antlr_py.apsim.run.Member_access2(totaltree, all_var)[source]

Bases: Middleware

action_member_access(tree)[source]
process(tree)[source]
pycropml.transpiler.antlr_py.apsim.run.create_package(output)[source]
pycropml.transpiler.antlr_py.apsim.run.extract_io(xfile)[source]

Extract inputs and outputs name and datatype from the xml file

Parameters:

xfile (_type_) – xml file path

Returns:

inputs, outputs

Return type:

Tuple

pycropml.transpiler.antlr_py.apsim.run.function_dependency(st, f)[source]
pycropml.transpiler.antlr_py.apsim.run.inst_dclass(meth)[source]
pycropml.transpiler.antlr_py.apsim.run.redefine_params(m: Node, var_: Dict, member_category, inputs, outputs, extfunc, instance_dclass) List[Node][source]

It allows to change all parameters which are instance of domain class with the explicit attributes required

Parameters:
  • m (Node) – Auxiliary function ASG

  • var (dict) – Metadata from strategy classes and varinfo files: (inputs, parameters, outputs)

  • member_category (_type_) – _description_

  • inputs (List[str]) – Parameter names of the auxiliary function. It can be an instance of domain class

Returns:

New parameters nodes

Return type:

List[Node]

pycropml.transpiler.antlr_py.apsim.run.run_apsim(component, output)[source]

Transform an APSIM component in Crop2ML

Parameters:
  • component (_type_) – Apsim component path

  • output (_type_) – Crop2ML package path

pycropml.transpiler.antlr_py.apsim.run.transform_io(inputs, res, out=False)[source]
pycropml.transpiler.antlr_py.apsim.run.translate(total_tree, varinfo, algo, not_declared, res_inout={}, member_category={}, pa={})[source]

Transform specific nodes based on class of subnodes of node. It also allows to extract some usefull information. At finish the modified node contains only the constructs of CyML and converted in CyML after applying translate_simple function.

Parameters:
  • total_tree (Node) – ASG of all the component

  • varinfo (Node) – ASG of the Var info files

Returns:

transform algo

Return type:

ASG