[pygobject] Remove static get_current_time() binding
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Remove static get_current_time() binding
- Date: Sun, 28 Oct 2012 21:39:06 +0000 (UTC)
commit 7b12803bce3418bb487127f497f022c973f35888
Author: Martin Pitt <martinpitt gnome org>
Date: Sun Oct 28 17:37:29 2012 +0100
Remove static get_current_time() binding
Use GLib.get_real_time() through GI instead. Deprecate the function, as
GLib.get_real_time() should be called directly.
docs/reference/pyglib-functions.xml | 26 --------------------------
gi/_glib/__init__.py | 1 -
gi/_glib/glibmodule.c | 11 -----------
gi/_glib/pyglib.c | 16 ----------------
gi/_glib/pyglib.h | 1 -
gi/_gobject/__init__.py | 1 -
gi/overrides/GLib.py | 8 ++++++++
gi/overrides/GObject.py | 2 +-
tests/test_glib.py | 6 +++++-
9 files changed, 14 insertions(+), 58 deletions(-)
---
diff --git a/docs/reference/pyglib-functions.xml b/docs/reference/pyglib-functions.xml
index fa1c210..fcde435 100644
--- a/docs/reference/pyglib-functions.xml
+++ b/docs/reference/pyglib-functions.xml
@@ -26,9 +26,6 @@ linkend="function-glib--spawn-async">glib.spawn_async</link></methodname>
<methodparam><parameter role="keyword">standard_error</parameter><initializer>None</initializer></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link
-linkend="function-glib--get-current-time">glib.get_current_time</link></methodname>
- </methodsynopsis><methodsynopsis language="python">
- <methodname><link
linkend="function-glib--threads-init">glib.threads_init</link></methodname>
</methodsynopsis><methodsynopsis language="python">
<methodname><link
@@ -289,29 +286,6 @@ raised.</para>
</refsect2>
- <refsect2 id="function-glib--get-current-time">
- <title>glib.get_current_time</title>
-
- <programlisting><methodsynopsis language="python">
- <methodname>glib.get_current_time</methodname>
- </methodsynopsis></programlisting>
- <variablelist role="params">
- <varlistentry>
- <term><emphasis>Returns</emphasis> :</term>
- <listitem><simpara>the current time as the number of seconds and
-microseconds from the epoch.</simpara></listitem>
- </varlistentry>
- </variablelist>
- <note>
- <para>This function is available in PyGTK 2.8 and above.</para>
- </note>
-
- <para>The <function>glib.get_current_time</function>() function
-reurns the current time of day as the number of seconds and microseconds
-from the epoch.</para>
-
- </refsect2>
-
<refsect2 id="function-glib--threads-init">
<title>glib.threads_init</title>
diff --git a/gi/_glib/__init__.py b/gi/_glib/__init__.py
index a9fee83..236aaaf 100644
--- a/gi/_glib/__init__.py
+++ b/gi/_glib/__init__.py
@@ -46,7 +46,6 @@ OPTION_REMAINING = _glib.OPTION_REMAINING
# Functions
filename_from_utf8 = _glib.filename_from_utf8
-get_current_time = _glib.get_current_time
glib_version = _glib.glib_version
pyglib_version = _glib.pyglib_version
spawn_async = _glib.spawn_async
diff --git a/gi/_glib/glibmodule.c b/gi/_glib/glibmodule.c
index 21cd52c..68abc78 100644
--- a/gi/_glib/glibmodule.c
+++ b/gi/_glib/glibmodule.c
@@ -97,15 +97,6 @@ pyglib_threads_init(PyObject *unused, PyObject *args, PyObject *kwargs)
}
static PyObject *
-pyglib_get_current_time(PyObject *unused)
-{
- GTimeVal timeval;
-
- g_get_current_time(&timeval);
- return pyglib_float_from_timeval(timeval);
-}
-
-static PyObject *
pyglib_filename_from_utf8(PyObject *self, PyObject *args)
{
char *filename, *utf8string;
@@ -146,8 +137,6 @@ static PyMethodDef _glib_functions[] = {
"See the reference manual for a complete reference." },
{ "filename_from_utf8",
(PyCFunction)pyglib_filename_from_utf8, METH_VARARGS },
- { "get_current_time",
- (PyCFunction)pyglib_get_current_time, METH_NOARGS },
{ NULL, NULL, 0 }
};
diff --git a/gi/_glib/pyglib.c b/gi/_glib/pyglib.c
index 2e5a0ef..ef8a02e 100644
--- a/gi/_glib/pyglib.c
+++ b/gi/_glib/pyglib.c
@@ -471,22 +471,6 @@ pyglib_option_context_new (GOptionContext *context)
return _PyGLib_API->option_context_new(context);
}
-/**
- * pyglib_option_context_new:
- * @context: a GTimeVal struct
- *
- * Converts a GTimeVal struct to a python float
- *
- * Returns: a float representing the timeval
- */
-PyObject *
-pyglib_float_from_timeval(GTimeVal timeval)
-{
- double ret;
- ret = (double)timeval.tv_sec + (double)timeval.tv_usec * 0.000001;
- return PyFloat_FromDouble(ret);
-}
-
/****** Private *****/
diff --git a/gi/_glib/pyglib.h b/gi/_glib/pyglib.h
index 35e40c4..bc80d6d 100644
--- a/gi/_glib/pyglib.h
+++ b/gi/_glib/pyglib.h
@@ -49,7 +49,6 @@ void pyglib_unblock_threads(void);
PyObject * pyglib_option_context_new(GOptionContext *context);
PyObject * pyglib_option_group_new(GOptionGroup *group);
GOptionGroup * pyglib_option_group_transfer_group(PyObject *self);
-PyObject * pyglib_float_from_timeval(GTimeVal timeval);
/* Private: for gobject <-> glib interaction only. */
void _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback);
diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py
index b0da863..d6dff72 100644
--- a/gi/_gobject/__init__.py
+++ b/gi/_gobject/__init__.py
@@ -82,7 +82,6 @@ type_parent = _gobject.type_parent
type_register = _gobject.type_register
spawn_async = _glib.spawn_async
-get_current_time = _glib.get_current_time
filename_from_utf8 = _glib.filename_from_utf8
Pid = _glib.Pid
GError = _glib.GError
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index a03ed2a..c785b9e 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -761,6 +761,14 @@ def child_watch_add(priority_or_pid, pid_or_callback, *args, **kwargs):
__all__.append('child_watch_add')
+def get_current_time():
+ return GLib.get_real_time() * 0.000001
+
+get_current_time = deprecated(get_current_time, 'GLib.get_real_time()')
+
+__all__.append('get_current_time')
+
+
# work around wrong constants in GLib GIR, see
# https://bugzilla.gnome.org/show_bug.cgi?id=685022
MININT64 = -9223372036854775808
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index d7d8ade..6c36ff9 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -32,7 +32,7 @@ for name in ['markup_escape_text', 'get_application_name',
'MainLoop', 'MainContext', 'main_context_default',
'source_remove', 'Source', 'Idle', 'Timeout', 'PollFD',
'idle_add', 'timeout_add', 'timeout_add_seconds',
- 'io_add_watch', 'child_watch_add']:
+ 'io_add_watch', 'child_watch_add', 'get_current_time']:
globals()[name] = gi.overrides.deprecated(getattr(GLib, name), 'GLib.' + name)
__all__.append(name)
diff --git a/tests/test_glib.py b/tests/test_glib.py
index b1e3fc4..3753ea6 100644
--- a/tests/test_glib.py
+++ b/tests/test_glib.py
@@ -63,7 +63,11 @@ https://my.org/q?x=1&y=2
'http://gnome.org/new'])
def test_current_time(self):
- tm = GLib.get_current_time()
+ with warnings.catch_warnings(record=True) as warn:
+ warnings.simplefilter('always')
+ tm = GLib.get_current_time()
+ self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
+
self.assertTrue(isinstance(tm, float))
self.assertGreater(tm, 1350000000.0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]