Exemplo n.º 1
0
void add_known_environment(string const & environment, string const & o1,
                           bool o2, docstring const & beg, docstring const &end)
{
	vector<ArgumentType> arguments;
	convertArgs(o1, o2, arguments);
	known_environments[environment] = arguments;
	if (!beg.empty() || ! end.empty())
		possible_textclass_environments[environment] =
			FullEnvironment(arguments, beg, end);
}
Exemplo n.º 2
0
void add_known_command(string const & command, string const & o1,
                       bool o2, docstring const & definition)
{
	vector<ArgumentType> arguments;
	convertArgs(o1, o2, arguments);
	known_commands[command] = arguments;
	if (!definition.empty())
		possible_textclass_commands[command] =
			FullCommand(arguments, definition);
}
Exemplo n.º 3
0
bool JsonRpcServer::call(QObject* object,
                         const QMetaMethod& meta_method,
                         const QVariantMap& args,
                         QVariant& return_value)
{
    return_value = QVariant();

    QVariantList converted_args;
    if (!convertArgs(meta_method, args, converted_args)) {
        return false;
    }

    return doCall(object, meta_method, converted_args, return_value);
}
Exemplo n.º 4
0
static PyObject* liblevenshtein_sequential_levensthein(PyObject *self, PyObject *args)
{
	unsigned int len_s;
	unsigned int len_t;

	long* s;
	long* t;
	MatrixMap* equality_map;

	unsigned short int distance;

	convertArgs(args, &s, &len_s, &t, &len_t, &equality_map);

	/*calling function*/
	distance = sequential_levenshtein(s, len_s, t, len_t, equality_map);

	free(s);
	free(t);
	freeMatrixMap(equality_map);

	/*return in Python type*/
	return Py_BuildValue("H", distance);
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    int res = 0;
    QString appIni;
    QMap<QString, QString> args = convertArgs(QCoreApplication::arguments());

    if (!args.value("-f").isEmpty()) {
        appIni = args.value("-f");
        devIni = QFileInfo(appIni).dir().path() + QDir::separator() + "development.ini";
    } else {
        QString dir = QLatin1String("..") + QDir::separator() + QLatin1String("..") + QDir::separator() + "config" +  QDir::separator();
        appIni = dir + "application.ini";
        devIni = dir + "development.ini";
    }

    if (!QFile::exists(appIni)) {
        usage();
        return 1;
    }

    QSettings appSetting(appIni, QSettings::IniFormat);
    QSettings devSetting(devIni, QSettings::IniFormat);

    // Default codec
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QString codecName = appSetting.value("InternalEncoding").toString();
    if (!codecName.isEmpty()) {
        QTextCodec *c = QTextCodec::codecForName(codecName.toLatin1().constData());
        if (c) {
            codec = c;
        }
    }
    QTextCodec::setCodecForLocale(codec);

    defaultTrimMode = devSetting.value("Erb.DefaultTrimMode", "1").toInt();
    printf("Erb.DefaultTrimMode: %d\n", defaultTrimMode);

    QDir viewDir(".");
    if (!args.value("-v").isEmpty()) {
        viewDir.setPath(args.value("-v"));
    }
    if (!viewDir.exists()) {
        usage();
        return 1;
    }

    QDir outputDir(DEFAULT_OUTPUT_DIR);
    if (!args.value("-d").isEmpty()) {
        outputDir.setPath(args.value("-d"));
    }

    if (outputDir.exists()) {
        if (outputDir.path() != ".") {
            printf("  exists   %s\n", qPrintable(outputDir.path()));
        }
    } else {
        if (outputDir.mkpath(".")) {
            printf("  created  %s\n", qPrintable(outputDir.path()));
        } else {
            usage();
            return 1;
        }
    }

    bool createProFile = (args.contains("-p") || !args.contains("-P"));
    ViewConverter conv(viewDir, outputDir, createProFile);
    QString templateSystem = devSetting.value("TemplateSystem").toString();
    if (templateSystem.isEmpty()) {
        templateSystem = appSetting.value("TemplateSystem", "Erb").toString();
    }

    res = conv.convertView(templateSystem);
    return res;
}  
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
    TWebApplication webapp(argc, argv);

    // Setup loggers
    tSetupSystemLogger();
    tSetupLoggers();
    qInstallMsgHandler(messageOutput);

#if defined(Q_OS_UNIX)
    webapp.watchUnixSignal(SIGTERM);
    webapp.ignoreUnixSignal(SIGINT);

    // Setup signal handlers for SIGSEGV, SIGILL, SIGFPE, SIGABRT and SIGBUS
    setupFailureWriter(writeFailure);
    setupSignalHandler();
#endif

    // Sets codec
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");  // default value
    QByteArray codecName = webapp.treefrogSettings().value("InternalEncoding").toByteArray().trimmed();
    if (!codecName.isEmpty()) {
        QTextCodec *c = QTextCodec::codecForName(codecName);
        if (c) {
            codec = c;
        } else {
            tWarn("no codec matching the name could be found: %s", codecName.data());
        }
    }
    QTextCodec::setCodecForTr(codec);
    QTextCodec::setCodecForLocale(codec);
    tSystemDebug("setCodecForTr: %s", codec->name().data());

    if (!webapp.webRootExists()) {
        tSystemError("No such directory");
        return 1;
    }
    tSystemDebug("Web Root: %s", qPrintable(webapp.webRootPath()));

    if (!webapp.settingsFileExists()) {
        tSystemError("Settings file not found");
        return 2;
    }
  
    QHash<QString, QString> args = convertArgs(QCoreApplication::arguments());
    TApplicationServer *server = new TApplicationServer(&webapp);
    QString arg = args.value("-s");
    if (!arg.isEmpty()) {
        // Sets a listening socket descriptor
        int sd = arg.toInt();
        if (sd > 0) {
            if (server->setSocketDescriptor(sd)) {
                tSystemDebug("Set socket descriptor: %d", sd);
            } else {
                tSystemError("Failed to set socket descriptor: %d", sd);
                return 3;
            }
        } else {
            tSystemError("Invalid socket descriptor: %d", sd);
            return 4;
        }
    }
    
    server->open();
    return webapp.exec();
}