from jinja2 import Environment, FileSystemLoader
# import templating
from .templating import return_function
import os




def generate_script(node):
    """
    Generate script for processing data.
    # """
   
    output =  return_function(node)
    return output

    

# def aa():
#     test = """{"nodes": [{"id": "999",
#    "type": "custom",
#    "position": {"x": 261, "y": 134},
#    "data": {"name": "Raw Data",
#     "value": "Raw Data",
#     "color": "pink.400",
#     "isInput": true,
#     "parameters": {"Dataset": "Test"},
#     "node_type": "preprocess"},
#    "width": 400,
#    "height": 76,
#    "selected": false,
#    "positionAbsolute": {"x": 261, "y": 134},
#    "dragging": false,
#    "target": "1"},
#   {"id": "998",
#    "type": "custom",
#    "position": {"x": 462.7212309761019, "y": 816.3344123088411},
#    "data": {"name": "Clean Data",
#     "value": "Clean Data",
#     "color": "green.400",
#     "isOutput": true,
#     "parameters": {"Dataset": "Test"},
#     "node_type": "preprocess"},
#    "width": 400,
#    "height": 76,
#    "selected": false,
#    "positionAbsolute": {"x": 462.7212309761019, "y": 816.3344123088411},
#    "dragging": false,
#    "source": "5"},
#   {"id": "1",
#    "type": "custom",
#    "position": {"x": 482.9480535053194, "y": 273.0009967292071},
#    "data": {"name": "Remove NAN values",
#     "value": "Remove NAN values",
#     "parameters": {"axis": 0, "how": "any", "subset": [], "inplace": false},
#     "node_type": "preprocess",
#     "color": "orange.400"},
#    "width": 400,
#    "height": 76,
#    "selected": false,
#    "positionAbsolute": {"x": 482.9480535053194, "y": 273.0009967292071},
#    "dragging": false,
#    "source": "999",
#    "target": "2"},
#   {"id": "2",
#    "type": "custom",
#    "position": {"x": 445.882683707091, "y": 423.57906153451086},
#    "data": {"name": "Dropping rows or columns",
#     "value": "Dropping rows or columns",
#     "parameters": {"labels": [{"value": "home.dest", "label": "home.dest"},
#       {"value": "name", "label": "name"}],
#      "axis": 0,
#      "index": [],
#      "columns": [],
#      "inplace": false,
#      "errors": "raise"},
#     "node_type": "preprocess",
#     "color": "teal.400"},
#    "width": 400,
#    "height": 76,
#    "source": "1",
#    "target": "4",
#    "selected": false,
#    "positionAbsolute": {"x": 445.882683707091, "y": 423.57906153451086},
#    "dragging": false},
#   {"id": "4",
#    "type": "custom",
#    "position": {"x": 412.2921923274464, "y": 554.4661486345054},
#    "data": {"name": "One Hot Encoding",
#     "value": "One Hot Encoding",
#     "parameters": {"columns": [{"value": "sex", "label": "sex"}],
#      "categories": "auto",
#      "dtype": "np.float",
#      "handle_unknown": "ignore",
#      "sparse": true,
#      "min_frequency": "null",
#      "max_categories": "null"},
#     "node_type": "preprocess",
#     "color": "teal.400"},
#    "width": 400,
#    "height": 76,
#    "selected": false,
#    "positionAbsolute": {"x": 412.2921923274464, "y": 554.4661486345054},
#    "dragging": false,
#    "source": "2",
#    "target": "5"},
#   {"id": "5",
#    "type": "custom",
#    "position": {"x": 398.3926786531106, "y": 676.086893284943},
#    "data": {"name": "Remove Outliers",
#     "value": "Remove Outliers",
#     "parameters": {"columns": [{"value": "fare", "label": "fare"}]},
#     "node_type": "preprocess",
#     "color": "yellow.400"},
#    "width": 400,
#    "height": 76,
#    "source": "4",
#    "selected": true,
#    "positionAbsolute": {"x": 398.3926786531106, "y": 676.086893284943},
#    "dragging": false,
#    "target": "998"}],
#  "edges": [{"source": "999",
#    "sourceHandle": null,
#    "target": "1",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "pink.400", "targetColor": "orange.400"},
#    "id": "reactflow__edge-999-1"},
#   {"source": "1",
#    "sourceHandle": null,
#    "target": "2",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "orange.400", "targetColor": "teal.400"},
#    "id": "reactflow__edge-1-2"},
#   {"source": "2",
#    "sourceHandle": null,
#    "target": "3",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "teal.400", "targetColor": "#805AD5"},
#    "id": "reactflow__edge-2-3"},
#   {"source": "3",
#    "sourceHandle": null,
#    "target": "998",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "#805AD5", "targetColor": "green.400"},
#    "id": "reactflow__edge-3-998"},
#   {"source": "2",
#    "sourceHandle": null,
#    "target": "4",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "teal.400", "targetColor": "teal.400"},
#    "id": "reactflow__edge-2-4"},
#   {"source": "4",
#    "sourceHandle": null,
#    "target": "5",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "teal.400", "targetColor": "yellow.400"},
#    "id": "reactflow__edge-4-5"},
#   {"source": "5",
#    "sourceHandle": null,
#    "target": "998",
#    "targetHandle": null,
#    "type": "custom",
#    "data": {"sourceColor": "yellow.400", "targetColor": "green.400"},
#    "id": "reactflow__edge-5-998"}]}"""
#     import json
#     graph = json.loads(test)

#     res=generate_script(graph)
#     print(res)

