| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| using System; | ||
|
|
||
| namespace Python.Runtime | ||
| { | ||
| public class PyModule : PyScope | ||
| { | ||
| internal PyModule(ref NewReference reference) : base(ref reference, PyScopeManager.Global) { } | ||
| public PyModule(PyObject o) : base(o.Reference, PyScopeManager.Global) { } | ||
|
|
||
| /// <summary> | ||
| /// Given a module or package name, import the | ||
| /// module and return the resulting module object as a <see cref="PyModule"/>. | ||
| /// </summary> | ||
| /// <param name="name">Fully-qualified module or package name</param> | ||
| public static PyModule Import(string name) | ||
| { | ||
| NewReference op = Runtime.PyImport_ImportModule(name); | ||
| PythonException.ThrowIfIsNull(op); | ||
| return new PyModule(ref op); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Reloads the module, and returns the updated object | ||
| /// </summary> | ||
| public PyModule Reload() | ||
| { | ||
| NewReference op = Runtime.PyImport_ReloadModule(this.Reference); | ||
| PythonException.ThrowIfIsNull(op); | ||
| return new PyModule(ref op); | ||
| } | ||
|
|
||
| public static PyModule FromString(string name, string code) | ||
| { | ||
| using NewReference c = Runtime.Py_CompileString(code, "none", (int)RunFlagType.File); | ||
| PythonException.ThrowIfIsNull(c); | ||
| NewReference m = Runtime.PyImport_ExecCodeModule(name, c); | ||
| PythonException.ThrowIfIsNull(m); | ||
| return new PyModule(ref m); | ||
| } | ||
| } | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.