//==============================================================================
// %(Identifier)s - python module definition - <MModuleDef>
//==============================================================================
#ifndef __Module__%(PreprocIdentifier)s__PYTHON__H__
#define __Module__%(PreprocIdentifier)s__PYTHON__H__

#include <Python.h>

PyMODINIT_FUNC init%(Identifier)s( void );

%(OpenNamespace)s

PyObject *Py%(Identifier)s_exception( );

%(CloseNamespace)s

#endif

<<<<<<<SPLIT>>>>>>>
//==============================================================================
// %(Identifier)s : python module definition - <MModuleDef>
//==============================================================================

#include "Python_Converter/%(Identifier)s_python.h"
%(MModuleDefHomeInclude)s
%(MModuleDefStructInclude)s
%(MModuleDefEnumInclude)s
#include <CCM_Python/HomeFinder.h>

%(OpenNamespace)s

// ---------- casac.aipserror ----------
static PyObject *Py%(Identifier)s_aipserror_ = 0;
PyObject *casac_aipserror( ) { return Py%(Identifier)s_aipserror_; }
// ---------- casac.indexerror ----------
static PyObject *Py%(Identifier)s_indexerror_ = 0;
PyObject *casac_indexerror( ) { return Py%(Identifier)s_indexerror_; }

static PyObject *%(Identifier)s_contents( PyObject *self, PyObject *args );

static PyMethodDef Py%(Identifier)s_methods[] = {
    { "contents", %(Identifier)s_contents, METH_NOARGS,
      "contents a(n) %(Identifier)s module"
    },
    { NULL, NULL, 0, NULL }
};

static PyObject *
%(Identifier)s_contents( PyObject *self, PyObject *args ) {

    char *strings[] = {
%(MModuleDefStructString)s
%(MModuleDefEnumString)s
			0
		      };

    int length = 0;
    while ( strings[length] ) {
        ++length;
    }

    PyObject *ret = PyList_New(length);
    if ( ret == NULL ) return NULL;

    for ( int i=0; i < length; ++i )
        PyList_SetItem(ret, i, PyString_FromString(strings[i]));
	
    return ret;
}

%(CloseNamespace)s

%(UsingNamespace)s

PyMODINIT_FUNC
init%(Identifier)s( void ) {

    PyObject *m = Py_InitModule( "%(Identifier)s", Py%(Identifier)s_methods );

    PyObject *global_dict = NULL;
    PyObject *global_module = PyImport_AddModule("__main__");
    Py_XINCREF(global_module);

    if ( global_module != NULL )
	global_dict = PyModule_GetDict(global_module);

    PyObject *dict = 0;
    if ( ! (dict = PyModule_GetDict(m)) ) {
	PyErr_SetString(PyExc_ImportError, "%(Identifier)s: init failed" );
	return;
    }

    // ---------- casac.aipserror ----------
    if ( ! Py%(Identifier)s_aipserror_ ) {
	Py%(Identifier)s_aipserror_ = PyErr_NewException("%(Identifier)s.aipserror", PyExc_StandardError, NULL);
	PyDict_SetItemString(dict, "aipserror", Py%(Identifier)s_aipserror_);
    }
    if ( ! Py%(Identifier)s_aipserror_ ) {
	PyErr_SetString(PyExc_ImportError, "%(Identifier)s: init failed" );
	return;
    }

    // ---------- casac.indexerror ----------
    if ( ! Py%(Identifier)s_indexerror_ ) {
	Py%(Identifier)s_indexerror_ = PyErr_NewException("%(Identifier)s.indexerror", Py%(Identifier)s_aipserror_, NULL);
	PyDict_SetItemString(dict, "indexerror", Py%(Identifier)s_indexerror_);
    }
    if ( ! Py%(Identifier)s_indexerror_ ) {
	PyErr_SetString(PyExc_ImportError, "%(Identifier)s: init failed" );
	return;
    }

%(MModuleDefHomeInit)s
%(MModuleDefStructInit)s
%(MModuleDefEnumInit)s

    Py_XDECREF(global_module);
    global_module = NULL;
    global_dict = NULL;

    home_info homefinder_init_struct[] = {
%(MModuleDefHomeFinderInit)s
        { NULL }
    };
    CCM_Python::homefinder_init( m, homefinder_init_struct );

}


