<commit_before>/* 
 * Copyright (C) 2007 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#define NO_IMPORT_PYGOBJECT
#include "py_midgard.h"
//#include "frameobject.h"

PyTypeObject G_GNUC_INTERNAL Pymidgard_replicator_Type;

#define REPLICATOR_DEBUG(__name) \
	CHECK_MGD; \
	CLASS_METHOD_DEBUG(Pymidgard_replicator_Type.tp_name, __name);
	
static PyObject *
pymidgard_replicator_serialize(PyGObject *self, PyObject *args) 
{
	REPLICATOR_DEBUG("serialize");
        // MidgardObject *mobject; 
	PyObject *pobject; 

	if(!PyArg_ParseTuple(args, "O", &pobject))
		return NULL;

	gchar *srld = midgard_replicator_serialize(G_OBJECT(((PyGObject *)pobject)->obj));

	PyObject *ret = Py_BuildValue("s", srld);
	g_free(srld);

	return ret;
}

static PyObject *
pymidgard_replicator_export(PyGObject *self, PyObject *args) 
{	
	REPLICATOR_DEBUG("export");
	PyObject *pobject;

	if(!PyArg_ParseTuple(args, "O", &pobject))
		return NULL;
	
	gboolean exported =
		midgard_replicator_export(MIDGARD_DBOBJECT(((PyGObject *)pobject)->obj));

	if(exported)
		Py_RETURN_TRUE;

	Py_RETURN_FALSE;
}

static PyObject *
pymidgard_replicator_export_purged(PyGObject *self, PyObject *args) 
{
	REPLICATOR_DEBUG("export_purged");
	const gchar *classname, *startdate = NULL, *enddate = NULL;

	if(!PyArg_ParseTuple(args, "s|ss", &classname, &startdate, &enddate))
		return NULL;
	
	MidgardObjectClass *klass = 
		MIDGARD_OBJECT_GET_CLASS_BY_NAME(classname);

	if(!klass) { 
		PyErr_SetString(PyExc_SystemError, "Can not replicate object. Invalid class name");
		return NULL;
	}

	MidgardConnection *mgd = 
		_py_midgard_connection_singleton_get();

	gchar *xml = midgard_replicator_export_purged (mgd, klass, startdate, enddate);
	
	PyObject *ret = Py_BuildValue("s", xml);
	g_free(xml);

	return ret;
}

static PyObject *
pymidgard_replicator_export_blob(PyGObject *self, PyObject *args) 
{<commit_msg>midgard_replicator accepts classname instaed of class pointer<commit_after>/* 
 * Copyright (C) 2007 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#define NO_IMPORT_PYGOBJECT
#include "py_midgard.h"
//#include "frameobject.h"

PyTypeObject G_GNUC_INTERNAL Pymidgard_replicator_Type;

#define REPLICATOR_DEBUG(__name) \
	CHECK_MGD; \
	CLASS_METHOD_DEBUG(Pymidgard_replicator_Type.tp_name, __name);
	
static PyObject *
pymidgard_replicator_serialize(PyGObject *self, PyObject *args) 
{
	REPLICATOR_DEBUG("serialize");
        // MidgardObject *mobject; 
	PyObject *pobject; 

	if(!PyArg_ParseTuple(args, "O", &pobject))
		return NULL;

	gchar *srld = midgard_replicator_serialize(G_OBJECT(((PyGObject *)pobject)->obj));

	PyObject *ret = Py_BuildValue("s", srld);
	g_free(srld);

	return ret;
}

static PyObject *
pymidgard_replicator_export(PyGObject *self, PyObject *args) 
{	
	REPLICATOR_DEBUG("export");
	PyObject *pobject;

	if(!PyArg_ParseTuple(args, "O", &pobject))
		return NULL;
	
	gboolean exported =
		midgard_replicator_export(MIDGARD_DBOBJECT(((PyGObject *)pobject)->obj));

	if(exported)
		Py_RETURN_TRUE;

	Py_RETURN_FALSE;
}

static PyObject *
pymidgard_replicator_export_purged(PyGObject *self, PyObject *args) 
{
	REPLICATOR_DEBUG("export_purged");
	const gchar *classname, *startdate = NULL, *enddate = NULL;

	if(!PyArg_ParseTuple(args, "s|ss", &classname, &startdate, &enddate))
		return NULL;	

	MidgardConnection *mgd = 
		_py_midgard_connection_singleton_get();

	gchar *xml = midgard_replicator_export_purged (mgd, classname, startdate, enddate);
	
	PyObject *ret = Py_BuildValue("s", xml);
	g_free(xml);

	return ret;
}

static PyObject *
pymidgard_replicator_export_blob(PyGObject *self, PyObject *args) 
{
{'fraction_non_alphanumeric': 0.10023492560689115, 'fraction_numerical': 0.0074393108848864525, 'mean_word_length': 5.307407407407408, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '7425571', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1734, 'n_words': 482}