<commit_before>/***************************************************************************
 * main.cpp
 * copyright (C)2003 by <NAME> (<EMAIL>)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 ***************************************************************************/

#include <Python.h>

//#include <stdlib.h>
//#include <cstdlib>
//#include <string>
//#include <sstream>
#include <iostream>

//#include <qobject.h>
#include <qstring.h>
#include <qstringlist.h>
//#include <qmap.h>
#include <qfile.h>

#include <kinstance.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>

#include "../kexidb/pythonkexidb.h"
#include "../kexidb/pythonkexidbdriver.h"

#include "../CXX/Objects.hxx"

KApplication *app = 0;
KInstance *instance = 0;

bool test_simple(int argc, char **argv)
{
    PyEval_AcquireLock();
    PyThreadState *tstate = Py_NewInterpreter();
    if(! tstate) {
        std::cerr << "Py_NewInterpreter() failed" << std::endl;
        exit(1);
    }
    PySys_SetArgv(argc, argv) ;

    Kross::PythonKexiDB* database = new Kross::PythonKexiDB();
    Py::Module module = database->module();
    //std::cout << "module->as_string() = " << module.as_string() << std::endl;

    QFile f( QFile::encodeName("test/test.py") );
    if(! f.open(IO_ReadOnly)) return false;
    QString data = f.readAll();
    f.close();

    if(! data.isEmpty())
        PyRun_SimpleString(data.latin1());

    delete database;

    Py_EndInterpreter(tstate);
    PyEval_ReleaseLock();

    return true;
}

int main(int argc, char **argv)
{
    KCmdLineArgs::init(argc, argv,
        new KAboutData("test", "KrossTest",
            "0.1", "", KAboutData::License_GPL,
            "(c) 2004, <NAME> (<EMAIL>)\n"
            "http://www.koffice.org/kexi\n"
            "http://www.dipe.org/kross",
            "<EMAIL>"
        )
    );
    app = new KApplication(true, true);
    instance = new KInstance("test");
<commit_msg>handle not existing file nicer.<commit_after>/***************************************************************************
 * main.cpp
 * copyright (C)2003 by <NAME> (<EMAIL>)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 ***************************************************************************/

#include <Python.h>

//#include <stdlib.h>
//#include <cstdlib>
//#include <string>
//#include <sstream>
#include <iostream>

//#include <qobject.h>
#include <qstring.h>
#include <qstringlist.h>
//#include <qmap.h>
#include <qfile.h>

#include <kinstance.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>

#include "../kexidb/pythonkexidb.h"
#include "../kexidb/pythonkexidbdriver.h"

#include "../CXX/Objects.hxx"

KApplication *app = 0;
KInstance *instance = 0;

bool test_simple(int argc, char **argv)
{
    PyEval_AcquireLock();
    PyThreadState *tstate = Py_NewInterpreter();
    if(! tstate) {
        std::cerr << "Py_NewInterpreter() failed" << std::endl;
        exit(1);
    }
    PySys_SetArgv(argc, argv) ;

    Kross::PythonKexiDB* database = new Kross::PythonKexiDB();
    Py::Module module = database->module();
    //std::cout << "module->as_string() = " << module.as_string() << std::endl;

    QFile f( QFile::encodeName("test/test.py") );
    if(f.exists() && f.open(IO_ReadOnly)) {
        QString data = f.readAll();
        f.close();

        if(! data.isEmpty())
            PyRun_SimpleString(data.latin1());
    }

    delete database;

    Py_EndInterpreter(tstate);
    PyEval_ReleaseLock();

    return true;
}

int main(int argc, char **argv)
{
    KCmdLineArgs::init(argc, argv,
        new KAboutData("test", "KrossTest",
            "0.1", "", KAboutData::License_GPL,
            "(c) 2004, <NAME> (<EMAIL>)\n"
            "http://www.koffice.org/kexi\n"
            "http://www.dipe.org/kross",
            "<EMAIL>"
        )
    );
    app = new KApplication(true, true);
    instance = new KInstance("test");

{'fraction_non_alphanumeric': 0.22253000923361035, 'fraction_numerical': 0.006925207756232687, 'mean_word_length': 3.448665297741273, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4783124', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1416, 'n_words': 332}