implements importing of python files into PythonQt More...
#include <PythonQtImporter.h>
Classes | |
struct | ModuleInfo |
Public Types | |
enum | ModuleType { MI_NOT_FOUND, MI_MODULE, MI_PACKAGE, MI_SHAREDLIBRARY } |
Static Public Member Functions | |
static void | init () |
initialize | |
static void | writeCompiledModule (PyCodeObject *co, const QString &filename, long mtime) |
writes the python code to disk, marshalling and writing the time stamp | |
static PyObject * | unmarshalCode (const QString &path, const QByteArray &data, time_t mtime) |
static PyObject * | compileSource (const QString &path, const QByteArray &data) |
static PyObject * | getCodeFromData (const QString &path, int isbytecode=0, int ispackage=0, time_t mtime=0) |
static PyObject * | getModuleCode (PythonQtImporter *self, const char *fullname, QString &modpath) |
static PyObject * | getCodeFromPyc (const QString &file) |
gets the compiled code for the given *.py file if there is a valid pyc file, otherwise compiles the file and writes the pyc | |
static ModuleInfo | getModuleInfo (PythonQtImporter *self, const QString &fullname) |
Return if module exists and is a package or a module. | |
static QString | getSubName (const QString &str) |
get the last name of a dot chain (first.second.last) | |
static long | getLong (unsigned char *buf) |
static time_t | getMTimeOfSource (const QString &path) |
get time stamp of file | |
static QString | replaceExtension (const QString &str, const QString &ext) |
replace extension of file |
implements importing of python files into PythonQt
also compiles/marshalls/unmarshalls py/pyc files and handles time stamps correctly
Definition at line 66 of file PythonQtImporter.h.
Definition at line 70 of file PythonQtImporter.h.
{ MI_NOT_FOUND, MI_MODULE, MI_PACKAGE, MI_SHAREDLIBRARY };
static PyObject* PythonQtImport::compileSource | ( | const QString & | path, | |
const QByteArray & | data | |||
) | [static] |
Given a string buffer containing Python source code, compile it return and return a code object as a new reference.
static PyObject* PythonQtImport::getCodeFromData | ( | const QString & | path, | |
int | isbytecode = 0 , |
|||
int | ispackage = 0 , |
|||
time_t | mtime = 0 | |||
) | [static] |
Return the code object for the module named by 'fullname' from the Zip archive as a new reference.
static PyObject* PythonQtImport::getCodeFromPyc | ( | const QString & | file | ) | [static] |
gets the compiled code for the given *.py file if there is a valid pyc file, otherwise compiles the file and writes the pyc
static long PythonQtImport::getLong | ( | unsigned char * | buf | ) | [static] |
Given a buffer, return the long that is represented by the first 4 bytes, encoded as little endian. This partially reimplements marshal.c:r_long()
static PyObject* PythonQtImport::getModuleCode | ( | PythonQtImporter * | self, | |
const char * | fullname, | |||
QString & | modpath | |||
) | [static] |
Get the code object associated with the module specified by 'fullname'.
static ModuleInfo PythonQtImport::getModuleInfo | ( | PythonQtImporter * | self, | |
const QString & | fullname | |||
) | [static] |
Return if module exists and is a package or a module.
static time_t PythonQtImport::getMTimeOfSource | ( | const QString & | path | ) | [static] |
get time stamp of file
static QString PythonQtImport::getSubName | ( | const QString & | str | ) | [static] |
get the last name of a dot chain (first.second.last)
static void PythonQtImport::init | ( | ) | [static] |
initialize
static QString PythonQtImport::replaceExtension | ( | const QString & | str, | |
const QString & | ext | |||
) | [static] |
replace extension of file
static PyObject* PythonQtImport::unmarshalCode | ( | const QString & | path, | |
const QByteArray & | data, | |||
time_t | mtime | |||
) | [static] |
Given the contents of a .py[co] file in a buffer, unmarshal the data and return the code object. Return None if it the magic word doesn't match (we do this instead of raising an exception as we fall back to .py if available and we don't want to mask other errors). Returns a new reference.
static void PythonQtImport::writeCompiledModule | ( | PyCodeObject * | co, | |
const QString & | filename, | |||
long | mtime | |||
) | [static] |
writes the python code to disk, marshalling and writing the time stamp