< 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
81%
Covered lines: 9
Uncovered lines: 2
Coverable lines: 11
Total lines: 55
Line coverage: 81.8%
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_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 the path to the Python DLL. Alternatively, you can set the PYTHON_DLL environment variable, which i
 15    /// </summary>
 216    public string? PythonDllPath { get; set; }
 17
 18    /// <summary>
 19    /// Gets or sets the Python script files to load.
 20    /// </summary>
 321    public ICollection<string> Scripts { get; } = new List<string>();
 22
 23    /// <summary>
 24    /// Gets or sets a list of callbacks that are invoked when the Python engine is being configured.
 25    /// </summary>
 126    public ICollection<Action<PyModule>> Scopes { get; } = new List<Action<PyModule>>();
 27
 28    /// <summary>
 29    /// Appends a script to the Python engine.
 30    /// </summary>
 31    /// <param name="builder">A builder that builds the script to append.</param>
 32    public void AddScript(Action<StringBuilder> builder)
 33    {
 134        var sb = new StringBuilder();
 135        builder(sb);
 136        AddScript(sb.ToString());
 137    }
 38
 39    /// <summary>
 40    /// Appends a script to the Python engine.
 41    /// </summary>
 42    /// <param name="script">The script to append.</param>
 43    public void AddScript(string script)
 44    {
 145        Scripts.Add(script);
 146    }
 47
 48    /// <summary>
 49    /// Registers a callback that is invoked when the Python engine is being configured.
 50    /// </summary>
 51    public void ConfigureScriptScope(Action<PyModule> configure)
 52    {
 053        Scopes.Add(configure);
 054    }
 55}