# Path: lems/run.py
# def run(file_path, include_dirs=[], dlems=False, nogui=False):
#     """
#     Function for running from a script or shell.
#     """
#     import argparse
# 
#     args = argparse.Namespace()
#     args.lems_file = file_path
#     args.I = include_dirs
#     args.dlems = dlems
#     args.nogui = nogui
#     main(args=args)


import unittest
import os
import textwrap
import tempfile
import typing
from lems.run import run as lems_run
            """<Lems>
        <!-- regression test data for https://github.com/LEMS/pylems/issues/20 -->
        <Target component="sim1"/>

        <Include file="Simulation.xml"/>
        <Include file="Cells.xml"/>
        <Include file="{}"/>

        <Simulation id="sim1" length="100ms" step="0.1ms" target="cell1">
          <!-- (x|y)(min|max) don't appear to do anything with PyLEMS, but error if not included... -->
            <OutputFile path="." fileName="reg_20.dat">
                <OutputColumn quantity="v" />
            </OutputFile>
        </Simulation>
    </Lems>
            """.format(
                nml_file.name
            )
        )

        xml_file = tempfile.NamedTemporaryFile(mode="w+b")
        xml_file.write(str.encode(reg_20_xml))
        xml_file.flush()

        # TODO: replace this with pynml's extract LEMS files function when that has
        # been merged and released. We won't need to carry a copy of the coretypes
        # then.
        coretype_files_dir = (
            os.path.dirname(os.path.abspath(__file__)) + "/NeuroML2CoreTypes"
        )

# Path: lems/run.py
# def run(file_path, include_dirs=[], dlems=False, nogui=False):
#     """
#     Function for running from a script or shell.
#     """
#     import argparse
# 
#     args = argparse.Namespace()
#     args.lems_file = file_path
#     args.I = include_dirs
#     args.dlems = dlems
#     args.nogui = nogui
#     main(args=args)


# Path: lems/test/reg_test_20.py
import unittest
import os
import textwrap
import tempfile
import typing
from lems.run import run as lems_run

            """<Lems>
        <!-- regression test data for https://github.com/LEMS/pylems/issues/20 -->
        <Target component="sim1"/>

        <Include file="Simulation.xml"/>
        <Include file="Cells.xml"/>
        <Include file="{}"/>

        <Simulation id="sim1" length="100ms" step="0.1ms" target="cell1">
          <!-- (x|y)(min|max) don't appear to do anything with PyLEMS, but error if not included... -->
            <OutputFile path="." fileName="reg_20.dat">
                <OutputColumn quantity="v" />
            </OutputFile>
        </Simulation>
    </Lems>
            """.format(
                nml_file.name
            )
        )

        xml_file = tempfile.NamedTemporaryFile(mode="w+b")
        xml_file.write(str.encode(reg_20_xml))
        xml_file.flush()

        # TODO: replace this with pynml's extract LEMS files function when that has
        # been merged and released. We won't need to carry a copy of the coretypes
        # then.
        coretype_files_dir = (
            os.path.dirname(os.path.abspath(__file__)) + "/NeuroML2CoreTypes"
        )

        lems_run(xml_file.name, include_dirs=[coretype_files_dir])