< Summary

Information
Class: Elsa.Expressions.Python.Options.PythonOptions
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Options/PythonOptions.cs
Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 61
Line coverage: 83.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_AllowHostCodeExecution()100%11100%
get_PythonDllPath()100%11100%
get_Scripts()100%11100%
get_Scopes()100%11100%
AddScript(...)100%11100%
AddScript(...)100%11100%
ConfigureScriptScope(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Options/PythonOptions.cs

#LineLine coverage
 1using System.Text;
 2using JetBrains.Annotations;
 3using Python.Runtime;
 4
 5namespace Elsa.Expressions.Python.Options;
 6
 7/// <summary>
 8/// Options for the Python expression evaluator.
 9/// </summary>
 10[PublicAPI]
 11public class PythonOptions
 12{
 13    /// <summary>
 14    /// Gets or sets whether workflow-authored Python.NET host-code execution is allowed.
 15    /// Python.NET is not a sandbox and can access host process capabilities.
 16    /// </summary>
 4517    public bool AllowHostCodeExecution { get; set; }
 18
 19    /// <summary>
 20    /// Gets or sets the path to the Python DLL. Alternatively, you can set the PYTHON_DLL environment variable, which i
 21    /// </summary>
 422    public string? PythonDllPath { get; set; }
 23
 24    /// <summary>
 25    /// Gets or sets the Python script files to load.
 26    /// </summary>
 927    public ICollection<string> Scripts { get; } = new List<string>();
 28
 29    /// <summary>
 30    /// Gets or sets a list of callbacks that are invoked when the Python engine is being configured.
 31    /// </summary>
 332    public ICollection<Action<PyModule>> Scopes { get; } = new List<Action<PyModule>>();
 33
 34    /// <summary>
 35    /// Appends a script to the Python engine.
 36    /// </summary>
 37    /// <param name="builder">A builder that builds the script to append.</param>
 38    public void AddScript(Action<StringBuilder> builder)
 39    {
 340        var sb = new StringBuilder();
 341        builder(sb);
 342        AddScript(sb.ToString());
 343    }
 44
 45    /// <summary>
 46    /// Appends a script to the Python engine.
 47    /// </summary>
 48    /// <param name="script">The script to append.</param>
 49    public void AddScript(string script)
 50    {
 351        Scripts.Add(script);
 352    }
 53
 54    /// <summary>
 55    /// Registers a callback that is invoked when the Python engine is being configured.
 56    /// </summary>
 57    public void ConfigureScriptScope(Action<PyModule> configure)
 58    {
 059        Scopes.Add(configure);
 060    }
 61}