gplugin/gplugin

rename all of the python symbols to be python3 instead of python
feature/python3-naming
2020-02-22, Gary Kramlich
26051396614c
Parents ce494367e404
Children c5a9655fbd5b
rename all of the python symbols to be python3 instead of python
--- a/python/gplugin-python3-core.c Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-core.c Sat Feb 22 04:00:07 2020 -0600
@@ -52,10 +52,10 @@
gplugin_load(GPluginNativePlugin *plugin,
G_GNUC_UNUSED GError **error)
{
- gplugin_python_plugin_register(plugin);
- gplugin_python_loader_register(plugin);
+ gplugin_python3_plugin_register(plugin);
+ gplugin_python3_loader_register(plugin);
- gplugin_manager_register_loader(GPLUGIN_PYTHON_TYPE_LOADER);
+ gplugin_manager_register_loader(GPLUGIN_PYTHON3_TYPE_LOADER);
return TRUE;
}
--- a/python/gplugin-python3-loader.c Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-loader.c Sat Feb 22 04:00:07 2020 -0600
@@ -28,27 +28,27 @@
#include <pygobject.h>
-struct _GPluginPythonLoader {
+struct _GPluginPython3Loader {
GPluginLoader parent;
PyThreadState *py_thread_state;
guint gc_id;
};
-G_DEFINE_DYNAMIC_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_TYPE_LOADER);
+G_DEFINE_DYNAMIC_TYPE(GPluginPython3Loader, gplugin_python3_loader, GPLUGIN_TYPE_LOADER);
/******************************************************************************
* GPluginLoader Implementation
*****************************************************************************/
static GSList *
-gplugin_python_loader_class_supported_extensions(G_GNUC_UNUSED GPluginLoaderClass *klass) {
+gplugin_python3_loader_class_supported_extensions(G_GNUC_UNUSED GPluginLoaderClass *klass) {
return g_slist_append(NULL, "py");
}
static GPluginPlugin *
-gplugin_python_loader_query(GPluginLoader *loader,
- const gchar *filename,
- G_GNUC_UNUSED GError **error)
+gplugin_python3_loader_query(GPluginLoader *loader,
+ const gchar *filename,
+ G_GNUC_UNUSED GError **error)
{
GPluginPlugin *plugin = NULL;
GObject *info = NULL;
@@ -65,11 +65,11 @@
package_list = PyTuple_New(0);
/* now figure out the module name from the filename */
- module_name = gplugin_python_filename_to_module(filename);
+ module_name = gplugin_python3_filename_to_module(filename);
/* grab the dirname since we need it on sys.path to import the module */
dir_name = g_path_get_dirname(filename);
- gplugin_python_add_module_path(dir_name);
+ gplugin_python3_add_module_path(dir_name);
g_free(dir_name);
/* import the module */
@@ -169,7 +169,7 @@
info = pygobject_get(pyinfo);
/* now that we have everything, create the plugin */
- plugin = g_object_new(GPLUGIN_PYTHON_TYPE_PLUGIN,
+ plugin = g_object_new(GPLUGIN_PYTHON3_TYPE_PLUGIN,
"filename", filename,
"loader", loader,
"module", module,
@@ -188,9 +188,9 @@
}
static gboolean
-gplugin_python_loader_load(G_GNUC_UNUSED GPluginLoader *loader,
- GPluginPlugin *plugin,
- GError **error)
+gplugin_python3_loader_load(G_GNUC_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
+ GError **error)
{
PyObject *load = NULL, *pyplugin = NULL, *result = NULL;
gboolean ret = FALSE;
@@ -206,7 +206,7 @@
Py_XDECREF(result);
if (error) {
- *error = gplugin_python_exception_to_gerror();
+ *error = gplugin_python3_exception_to_gerror();
}
return FALSE;
@@ -224,9 +224,9 @@
}
static gboolean
-gplugin_python_loader_unload(G_GNUC_UNUSED GPluginLoader *loader,
- GPluginPlugin *plugin,
- GError **error)
+gplugin_python3_loader_unload(G_GNUC_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
+ GError **error)
{
PyObject *unload = NULL, *pyplugin = NULL, *result = NULL;
gboolean ret = FALSE;
@@ -258,10 +258,10 @@
}
/******************************************************************************
- * Python Stuff
+ * Python3 Stuff
*****************************************************************************/
static gboolean
-gplugin_python_loader_init_pygobject(void) {
+gplugin_python3_loader_init_pygobject(void) {
pygobject_init(3, 0, 0);
if(PyErr_Occurred()) {
PyObject *type = NULL, *value = NULL, *tb = NULL, *obj = NULL;
@@ -289,7 +289,7 @@
}
static gboolean
-gplugin_python_loader_init_gettext(void) {
+gplugin_python3_loader_init_gettext(void) {
PyObject *module_dict = NULL, *install = NULL;
PyObject *gettext = NULL, *result = NULL;
@@ -310,7 +310,7 @@
}
static gboolean
-gplugin_python_loader_init_python(void) {
+gplugin_python3_loader_init_python(void) {
wchar_t *argv[] = { NULL, NULL };
/* Initializes Python */
@@ -330,8 +330,8 @@
PyMem_RawFree(argv[0]);
/* initialize pygobject */
- if(gplugin_python_loader_init_pygobject()) {
- if(gplugin_python_loader_init_gettext()) {
+ if(gplugin_python3_loader_init_pygobject()) {
+ if(gplugin_python3_loader_init_gettext()) {
return TRUE;
}
}
@@ -340,34 +340,34 @@
}
/******************************************************************************
- * Object Stuff
+ * GObject Implementation
*****************************************************************************/
static void
-gplugin_python_loader_init(G_GNUC_UNUSED GPluginPythonLoader *loader) {
+gplugin_python3_loader_init(G_GNUC_UNUSED GPluginPython3Loader *loader) {
}
static void
-gplugin_python_loader_class_finalize(G_GNUC_UNUSED GPluginPythonLoaderClass *klass)
+gplugin_python3_loader_class_finalize(G_GNUC_UNUSED GPluginPython3LoaderClass *klass)
{
}
static void
-gplugin_python_loader_class_init(GPluginPythonLoaderClass *klass) {
+gplugin_python3_loader_class_init(GPluginPython3LoaderClass *klass) {
GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
loader_class->supported_extensions =
- gplugin_python_loader_class_supported_extensions;
- loader_class->query = gplugin_python_loader_query;
- loader_class->load = gplugin_python_loader_load;
- loader_class->unload = gplugin_python_loader_unload;
+ gplugin_python3_loader_class_supported_extensions;
+ loader_class->query = gplugin_python3_loader_query;
+ loader_class->load = gplugin_python3_loader_load;
+ loader_class->unload = gplugin_python3_loader_unload;
}
/******************************************************************************
* API
*****************************************************************************/
void
-gplugin_python_loader_register(GPluginNativePlugin *native) {
- gplugin_python_loader_register_type(G_TYPE_MODULE(native));
+gplugin_python3_loader_register(GPluginNativePlugin *native) {
+ gplugin_python3_loader_register_type(G_TYPE_MODULE(native));
- gplugin_python_loader_init_python();
+ gplugin_python3_loader_init_python();
}
--- a/python/gplugin-python3-loader.h Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-loader.h Sat Feb 22 04:00:07 2020 -0600
@@ -15,19 +15,19 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GPLUGIN_PYTHON_LOADER_H
-#define GPLUGIN_PYTHON_LOADER_H
+#ifndef GPLUGIN_PYTHON3_LOADER_H
+#define GPLUGIN_PYTHON3_LOADER_H
#include <gplugin.h>
#include <gplugin-native.h>
G_BEGIN_DECLS
-#define GPLUGIN_PYTHON_TYPE_LOADER (gplugin_python_loader_get_type())
-G_DECLARE_FINAL_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_PYTHON, LOADER, GPluginLoader)
+#define GPLUGIN_PYTHON3_TYPE_LOADER (gplugin_python3_loader_get_type())
+G_DECLARE_FINAL_TYPE(GPluginPython3Loader, gplugin_python3_loader, GPLUGIN_PYTHON3, LOADER, GPluginLoader)
-void gplugin_python_loader_register(GPluginNativePlugin *native);
+void gplugin_python3_loader_register(GPluginNativePlugin *native);
G_END_DECLS
-#endif /* GPLUGIN_PYTHON_LOADER_H */
+#endif /* GPLUGIN_PYTHON3_LOADER_H */
--- a/python/gplugin-python3-plugin.c Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-plugin.c Sat Feb 22 04:00:07 2020 -0600
@@ -24,7 +24,7 @@
/******************************************************************************
* Typedefs
*****************************************************************************/
-struct _GPluginPythonPlugin {
+struct _GPluginPython3Plugin {
GObject parent;
PyObject *module;
@@ -57,29 +57,29 @@
static GParamSpec *properties[N_PROPERTIES] = {NULL,};
/* I hate forward declarations... */
-static void gplugin_python_plugin_iface_init(GPluginPluginInterface *iface);
+static void gplugin_python3_plugin_iface_init(GPluginPluginInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED(
- GPluginPythonPlugin,
- gplugin_python_plugin,
+ GPluginPython3Plugin,
+ gplugin_python3_plugin,
G_TYPE_OBJECT,
0,
- G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_python_plugin_iface_init)
+ G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_python3_plugin_iface_init)
);
/******************************************************************************
* GPluginPlugin Implementation
*****************************************************************************/
static void
-gplugin_python_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface) {
+gplugin_python3_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface) {
}
/******************************************************************************
* Private Stuff
*****************************************************************************/
static void
-gplugin_python_plugin_set_module(GPluginPythonPlugin *plugin,
- PyObject *module)
+gplugin_python3_plugin_set_module(GPluginPython3Plugin *plugin,
+ PyObject *module)
{
g_return_if_fail(GPLUGIN_IS_PLUGIN(plugin));
g_return_if_fail(module);
@@ -90,17 +90,17 @@
}
static gpointer
-gplugin_python_plugin_get_load_func(GPluginPythonPlugin *plugin) {
- g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL);
+gplugin_python3_plugin_get_load_func(GPluginPython3Plugin *plugin) {
+ g_return_val_if_fail(GPLUGIN_PYTHON3_IS_PLUGIN(plugin), NULL);
return plugin->load;
}
static void
-gplugin_python_plugin_set_load_func(GPluginPythonPlugin *plugin,
+gplugin_python3_plugin_set_load_func(GPluginPython3Plugin *plugin,
PyObject *func)
{
- g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin));
+ g_return_if_fail(GPLUGIN_PYTHON3_IS_PLUGIN(plugin));
g_return_if_fail(func != NULL);
Py_XINCREF(func);
@@ -109,17 +109,17 @@
}
static gpointer
-gplugin_python_plugin_get_unload_func(GPluginPythonPlugin *plugin) {
- g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL);
+gplugin_python3_plugin_get_unload_func(GPluginPython3Plugin *plugin) {
+ g_return_val_if_fail(GPLUGIN_PYTHON3_IS_PLUGIN(plugin), NULL);
return plugin->unload;
}
static void
-gplugin_python_plugin_set_unload_func(GPluginPythonPlugin *plugin,
- PyObject *func)
+gplugin_python3_plugin_set_unload_func(GPluginPython3Plugin *plugin,
+ PyObject *func)
{
- g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin));
+ g_return_if_fail(GPLUGIN_PYTHON3_IS_PLUGIN(plugin));
g_return_if_fail(func != NULL);
Py_XINCREF(func);
@@ -128,13 +128,13 @@
}
/******************************************************************************
- * Object Stuff
+ * GObject Implementation
*****************************************************************************/
static void
-gplugin_python_plugin_get_property(GObject *obj, guint param_id, GValue *value,
- GParamSpec *pspec)
+gplugin_python3_plugin_get_property(GObject *obj, guint param_id, GValue *value,
+ GParamSpec *pspec)
{
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
+ GPluginPython3Plugin *plugin = GPLUGIN_PYTHON3_PLUGIN(obj);
switch(param_id) {
case PROP_MODULE:
@@ -142,11 +142,11 @@
break;
case PROP_LOAD_FUNC:
g_value_set_pointer(value,
- gplugin_python_plugin_get_load_func(plugin));
+ gplugin_python3_plugin_get_load_func(plugin));
break;
case PROP_UNLOAD_FUNC:
g_value_set_pointer(value,
- gplugin_python_plugin_get_unload_func(plugin));
+ gplugin_python3_plugin_get_unload_func(plugin));
break;
/* overrides */
@@ -170,23 +170,23 @@
}
static void
-gplugin_python_plugin_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
+gplugin_python3_plugin_set_property(GObject *obj, guint param_id,
+ const GValue *value, GParamSpec *pspec)
{
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
+ GPluginPython3Plugin *plugin = GPLUGIN_PYTHON3_PLUGIN(obj);
switch(param_id) {
case PROP_MODULE:
- gplugin_python_plugin_set_module(plugin,
- g_value_get_pointer(value));
+ gplugin_python3_plugin_set_module(plugin,
+ g_value_get_pointer(value));
break;
case PROP_LOAD_FUNC:
- gplugin_python_plugin_set_load_func(plugin,
- g_value_get_pointer(value));
+ gplugin_python3_plugin_set_load_func(plugin,
+ g_value_get_pointer(value));
break;
case PROP_UNLOAD_FUNC:
- gplugin_python_plugin_set_unload_func(plugin,
- g_value_get_pointer(value));
+ gplugin_python3_plugin_set_unload_func(plugin,
+ g_value_get_pointer(value));
break;
/* overrides */
@@ -210,8 +210,8 @@
}
static void
-gplugin_python_plugin_finalize(GObject *obj) {
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
+gplugin_python3_plugin_finalize(GObject *obj) {
+ GPluginPython3Plugin *plugin = GPLUGIN_PYTHON3_PLUGIN(obj);
Py_CLEAR(plugin->module);
Py_CLEAR(plugin->load);
@@ -221,25 +221,25 @@
g_clear_object(&plugin->loader);
g_clear_object(&plugin->info);
- G_OBJECT_CLASS(gplugin_python_plugin_parent_class)->finalize(obj);
+ G_OBJECT_CLASS(gplugin_python3_plugin_parent_class)->finalize(obj);
}
static void
-gplugin_python_plugin_init(G_GNUC_UNUSED GPluginPythonPlugin *plugin) {
+gplugin_python3_plugin_init(G_GNUC_UNUSED GPluginPython3Plugin *plugin) {
}
static void
-gplugin_python_plugin_class_finalize(G_GNUC_UNUSED GPluginPythonPluginClass *klass)
+gplugin_python3_plugin_class_finalize(G_GNUC_UNUSED GPluginPython3PluginClass *klass)
{
}
static void
-gplugin_python_plugin_class_init(GPluginPythonPluginClass *klass) {
+gplugin_python3_plugin_class_init(GPluginPython3PluginClass *klass) {
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->get_property = gplugin_python_plugin_get_property;
- obj_class->set_property = gplugin_python_plugin_set_property;
- obj_class->finalize = gplugin_python_plugin_finalize;
+ obj_class->get_property = gplugin_python3_plugin_get_property;
+ obj_class->set_property = gplugin_python3_plugin_set_property;
+ obj_class->finalize = gplugin_python3_plugin_finalize;
properties[PROP_MODULE] = g_param_spec_pointer(
"module", "module",
@@ -272,6 +272,7 @@
* API
*****************************************************************************/
void
-gplugin_python_plugin_register(GPluginNativePlugin *native) {
- gplugin_python_plugin_register_type(G_TYPE_MODULE(native));
+gplugin_python3_plugin_register(GPluginNativePlugin *native) {
+ gplugin_python3_plugin_register_type(G_TYPE_MODULE(native));
}
+
--- a/python/gplugin-python3-plugin.h Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-plugin.h Sat Feb 22 04:00:07 2020 -0600
@@ -15,19 +15,19 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GPLUGIN_PYTHON_PLUGIN_H
-#define GPLUGIN_PYTHON_PLUGIN_H
+#ifndef GPLUGIN_PYTHON3_PLUGIN_H
+#define GPLUGIN_PYTHON3_PLUGIN_H
#include <gplugin.h>
#include <gplugin-native.h>
G_BEGIN_DECLS
-#define GPLUGIN_PYTHON_TYPE_PLUGIN (gplugin_python_plugin_get_type())
-G_DECLARE_FINAL_TYPE(GPluginPythonPlugin, gplugin_python_plugin, GPLUGIN_PYTHON, PLUGIN, GObject)
+#define GPLUGIN_PYTHON3_TYPE_PLUGIN (gplugin_python3_plugin_get_type())
+G_DECLARE_FINAL_TYPE(GPluginPython3Plugin, gplugin_python3_plugin, GPLUGIN_PYTHON3, PLUGIN, GObject)
-void gplugin_python_plugin_register(GPluginNativePlugin *native);
+void gplugin_python3_plugin_register(GPluginNativePlugin *native);
G_END_DECLS
-#endif /* GPLUGIN_PYTHON_PLUGIN_H */
+#endif /* GPLUGIN_PYTHON3_PLUGIN_H */
--- a/python/gplugin-python3-utils.c Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-utils.c Sat Feb 22 04:00:07 2020 -0600
@@ -24,7 +24,7 @@
#include <string.h>
gchar *
-gplugin_python_filename_to_module(const gchar *filename) {
+gplugin_python3_filename_to_module(const gchar *filename) {
gchar *base = NULL;
gchar *e = NULL, *r = NULL;
@@ -51,7 +51,7 @@
}
gboolean
-gplugin_python_add_module_path(const gchar *module_path) {
+gplugin_python3_add_module_path(const gchar *module_path) {
PyObject *sys_path = NULL, *path = NULL;
gboolean ret = FALSE;
@@ -70,7 +70,7 @@
}
GError *
-gplugin_python_exception_to_gerror(void) {
+gplugin_python3_exception_to_gerror(void) {
GError *error = NULL;
PyObject *type = NULL, *value = NULL, *trace = NULL;
PyObject *type_name = NULL, *value_str = NULL, *obj = NULL;
--- a/python/gplugin-python3-utils.h Sat Feb 22 03:41:23 2020 -0600
+++ b/python/gplugin-python3-utils.h Sat Feb 22 04:00:07 2020 -0600
@@ -15,21 +15,21 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GPLUGIN_PYTHON_UTILS_H
-#define GPLUGIN_PYTHON_UTILS_H
+#ifndef GPLUGIN_PYTHON3_UTILS_H
+#define GPLUGIN_PYTHON3_UTILS_H
#include <glib.h>
-#define GPLUGIN_PYTHON_DOMAIN (g_quark_from_static_string("gplugin-python"))
+#define GPLUGIN_PYTHON3_DOMAIN (g_quark_from_static_string("gplugin-python"))
G_BEGIN_DECLS
-gchar *gplugin_python_filename_to_module(const gchar *filename);
+gchar *gplugin_python3_filename_to_module(const gchar *filename);
-gboolean gplugin_python_add_module_path(const gchar *module_path);
+gboolean gplugin_python3_add_module_path(const gchar *module_path);
-GError *gplugin_python_exception_to_gerror(void);
+GError *gplugin_python3_exception_to_gerror(void);
G_END_DECLS
-#endif /* GPLUGIN_PYTHON_UTILS_H */
+#endif /* GPLUGIN_PYTHON3_UTILS_H */
--- a/python/tests/test-python3-utils.c Sat Feb 22 03:41:23 2020 -0600
+++ b/python/tests/test-python3-utils.c Sat Feb 22 04:00:07 2020 -0600
@@ -26,7 +26,7 @@
*****************************************************************************/
static void
test_filename_to_module_NULL_subprocess(void) {
- gplugin_python_filename_to_module(NULL);
+ gplugin_python3_filename_to_module(NULL);
}
static void
@@ -38,7 +38,7 @@
static void
test_filename_to_module_empty(void) {
- gchar *module = gplugin_python_filename_to_module("");
+ gchar *module = gplugin_python3_filename_to_module("");
g_assert_cmpstr(module, ==, "");
@@ -47,7 +47,7 @@
static void
test_filename_to_module_no_extension(void) {
- gchar *module = gplugin_python_filename_to_module("foo");
+ gchar *module = gplugin_python3_filename_to_module("foo");
g_assert_cmpstr(module, ==, "foo");