IPythonSerializer.CreateLoaderFromFile

Syntax

CreateLoaderFromFile(FileName: String; Metabase: IMetabase): IPythonSerializerLoader;

Parameters

FileName. File, from which loading is to be executed.

Metabase. Repository, in which the loaded object is to be saved.

Description

The CreateLoaderFromFile method creates an object that is used to load Python modules.

Examples

Executing the example requires a file with code in the Python language: D:\Work\Python\test.py. The repository should have a folder with the F_PYTHON identifier created.

Add links to the Metabase, Python system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Ps: IPythonSerializer;
    Loader: IPythonSerializerLoader;
    CrInfo: IMetabaseObjectCreateInfo;
Begin
    MB := MetabaseClass.Active;
    Ps := 
New PythonSerializer.Create;
    Loader := Ps.CreateLoaderFromFile(
"d:\Work\Python\test.py", MB);
    CrInfo := Loader.CreateInfo;
    
If MB.ItemById(CrInfo.Id) <> Null Then
        CrInfo.Id := MB.GenerateId(CrInfo.Id);
        CrInfo.Name := CrInfo.Name + 
"_Copy";
    
End If;
    CrInfo.Parent := MB.ItemById(
"F_PYTHON");
    Loader.LoadModule;
End Sub UserProc;

After executing the example the Python module will be loaded from the file to the repository. The module will be saved in the specified folder.

See also:

IPythonSerializer