using Python.Runtime; using System; using static System.Net.Mime.MediaTypeNames; using System.IO; using System.Reflection; using System.Dynamic; namespace dopt.TOM { public class Plugin : SharpPython.BasePlugin { internal const string langMainBaseFolderName = "bin"; internal const string langMainStopSearchFolderName = "python"; internal const string doptTOMPluginLibraryUsage = "1"; protected dynamic tomWrapperPipelines; public Plugin(string runtimePath = "") : base(SharpPython.PyOptimLevels.O, threaded: false, runtimePath: runtimePath, verbose: true) { base.Initialise(); using (Py.GIL()) { dynamic os = Py.Import("os"); os.putenv("LANG_MAIN_BASE_FOLDERNAME", langMainBaseFolderName); os.putenv("LANG_MAIN_STOP_SEARCH_FOLDERNAME", langMainStopSearchFolderName); os.putenv("DOPT_TOM_PLUGIN_LIBRARY_USAGE", doptTOMPluginLibraryUsage); tomWrapperPipelines = Py.Import("tom_plugin.pipeline"); } } public void RunOnCSV(string identifier, string filename) { AssertNotDisposed(); using (Py.GIL()) { tomWrapperPipelines.run_on_csv_data(identifier, filename); } } } }