kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=dc4752c6821ba581c3974926f8cb4240b079a523

commit dc4752c6821ba581c3974926f8cb4240b079a523
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Fri Dec 6 14:04:34 2013 +0200

    Elementary: Document handling of failure return values, add missing ones.
---
 efl/elementary/calendar_elm.pyx  | 21 ++++++++------
 efl/elementary/datetime_elm.pyx  | 36 +++++++++++++++++++----
 efl/elementary/entry.pyx         | 13 +++++++--
 efl/elementary/gesture_layer.pyx |  8 +++---
 efl/elementary/icon.pyx          |  4 +++
 efl/elementary/image.pyx         |  4 +++
 efl/elementary/layout_class.pyx  | 62 ++++++++++++++++++++++++++++++++++------
 efl/elementary/photo.pyx         |  3 ++
 efl/elementary/plug.pyx          | 12 +++++---
 efl/elementary/thumb.pyx         |  8 +++++-
 efl/elementary/video.pyx         |  3 ++
 efl/elementary/web.pyx           |  6 ++++
 efl/elementary/window.pyx        |  4 +++
 13 files changed, 149 insertions(+), 35 deletions(-)

diff --git a/efl/elementary/calendar_elm.pyx b/efl/elementary/calendar_elm.pyx
index e848fe8..666197e 100644
--- a/efl/elementary/calendar_elm.pyx
+++ b/efl/elementary/calendar_elm.pyx
@@ -364,21 +364,20 @@ cdef class Calendar(LayoutClass):
         Selected date changes when the user goes to next/previous month or
         select a day pressing over it on calendar.
 
+        :type: datetime.date
+
         .. versionchanged:: 1.8
             Returns None when the selected date cannot be fetched.
 
-        :type: datetime.date
-
         """
         def __get__(self):
             cdef tm time
-            if elm_calendar_selected_time_get(self.obj, &time):
-                ret = date( time.tm_year + 1900,
-                            time.tm_mon + 1,
-                            time.tm_mday)
-                return ret
-            else:
+            if not elm_calendar_selected_time_get(self.obj, &time):
                 return None
+            ret = date( time.tm_year + 1900,
+                        time.tm_mon + 1,
+                        time.tm_mday)
+            return ret
 
         def __set__(self, selected_time):
             cdef tm time
@@ -541,10 +540,14 @@ cdef class Calendar(LayoutClass):
 
         :type: datetime.date
 
+        .. versionchanged:: 1.8
+            Returns None when the displayed date cannot be fetched.
+
         """
         def __get__(self):
             cdef tm time
-            elm_calendar_displayed_time_get(self.obj, &time)
+            if not elm_calendar_displayed_time_get(self.obj, &time):
+                return None
             ret = date( time.tm_year + 1900,
                         time.tm_mon + 1,
                         time.tm_mday)
diff --git a/efl/elementary/datetime_elm.pyx b/efl/elementary/datetime_elm.pyx
index 90724d2..9d06cce 100644
--- a/efl/elementary/datetime_elm.pyx
+++ b/efl/elementary/datetime_elm.pyx
@@ -393,12 +393,19 @@ cdef class Datetime(Object):
 
         Minute: default value range is from 0 to 59.
 
+        :raise RuntimeError: when the max value could not be set.
+
         :type: datetime.datetime
 
+        .. versionchanged:: 1.8
+            Returns None when the max value cannot be fetched, raise
+            RuntimeError when setting the max value failed.
+
         """
         def __get__(self):
             cdef tm time
-            elm_datetime_value_max_get(self.obj, &time)
+            if not elm_datetime_value_max_get(self.obj, &time):
+                return None
             ret = datetime( time.tm_year + 1900,
                             time.tm_mon + 1,
                             time.tm_mday,
@@ -419,7 +426,8 @@ cdef class Datetime(Object):
             time.tm_wday = tmtup.tm_wday
             time.tm_yday = tmtup.tm_yday
             time.tm_isdst = tmtup.tm_isdst
-            elm_datetime_value_max_set(self.obj, &time)
+            if not elm_datetime_value_max_set(self.obj, &time):
+                raise RuntimeError
 
     property value_min:
         """The lower boundary of a field.
@@ -435,12 +443,19 @@ cdef class Datetime(Object):
 
         Minute: default value range is from 0 to 59.
 
+        :raise RuntimeError: when the min value could not be set.
+
         :type: datetime.datetime
 
+        .. versionchanged:: 1.8
+            Returns None when the min value cannot be fetched, raise
+            RuntimeError when setting the min value failed.
+
         """
         def __get__(self):
             cdef tm time
-            elm_datetime_value_min_get(self.obj, &time)
+            if not elm_datetime_value_min_get(self.obj, &time):
+                return None
             ret = datetime( time.tm_year + 1900,
                             time.tm_mon + 1,
                             time.tm_mday,
@@ -461,7 +476,8 @@ cdef class Datetime(Object):
             time.tm_wday = tmtup.tm_wday
             time.tm_yday = tmtup.tm_yday
             time.tm_isdst = tmtup.tm_isdst
-            elm_datetime_value_min_set(self.obj, &time)
+            if not elm_datetime_value_min_set(self.obj, &time):
+                raise RuntimeError
 
     def field_limit_get(self, Elm_Datetime_Field_Type fieldtype):
         """Get the field limits of a field.
@@ -511,12 +527,19 @@ cdef class Datetime(Object):
 
         Minute: default value range is from 0 to 59.
 
+        :raise RuntimeError: when the value could not be set.
+
         :type: datetime.datetime
 
+        .. versionchanged:: 1.8
+            Returns None when the value cannot be fetched, raise RuntimeError
+            when setting the value failed.
+
         """
         def __get__(self):
             cdef tm time
-            elm_datetime_value_get(self.obj, &time)
+            if not elm_datetime_value_get(self.obj, &time):
+                return None
             ret = datetime( time.tm_year + 1900,
                             time.tm_mon + 1,
                             time.tm_mday,
@@ -537,7 +560,8 @@ cdef class Datetime(Object):
             time.tm_wday = tmtup.tm_wday
             time.tm_yday = tmtup.tm_yday
             time.tm_isdst = tmtup.tm_isdst
-            elm_datetime_value_set(self.obj, &time)
+            if not elm_datetime_value_set(self.obj, &time):
+                raise RuntimeError
 
     def field_visible_get(self, fieldtype):
         """field_visible_get(int fieldtype) -> bool
diff --git a/efl/elementary/entry.pyx b/efl/elementary/entry.pyx
index 6d9045e..e684600 100644
--- a/efl/elementary/entry.pyx
+++ b/efl/elementary/entry.pyx
@@ -1227,14 +1227,17 @@ cdef class Entry(Object):
         cursor.
 
         :return: Geometry (x, y, w, h)
-        :rtype: tuple of Evas_Coords (int)
+        :rtype: tuple of Evas_Coords (int) or None
+
+        .. versionchanged:: 1.8
+            Returns None when the cursor geometry cannot be fetched.
 
         """
         cdef Evas_Coord x, y, w, h
-        if bool(elm_entry_cursor_geometry_get(self.obj, &x, &y, &w, &h)):
+        if elm_entry_cursor_geometry_get(self.obj, &x, &y, &w, &h):
             return (x, y, w, h)
         else:
-            raise RuntimeError("Fetching cursor geometry failed")
+            return None
 
     property cursor_pos:
         """The cursor position in the entry
@@ -1462,6 +1465,10 @@ cdef class Entry(Object):
         :type: (unicode **file_name**, :ref:`Elm_Entry_Text_Format` 
**file_format**)
         :raise RuntimeError: when setting the file fails
 
+        .. versionchanged:: 1.8
+            Raise RuntimeError when setting the file fails, instead of
+            returning a bool.
+
         """
         def __get__(self):
             cdef const_char *file
diff --git a/efl/elementary/gesture_layer.pyx b/efl/elementary/gesture_layer.pyx
index 2362cd9..1b27c60 100644
--- a/efl/elementary/gesture_layer.pyx
+++ b/efl/elementary/gesture_layer.pyx
@@ -647,12 +647,12 @@ cdef class GestureLayer(Object):
         :param target: The target object to attach to this object.
         :type target: :py:class:`~efl.evas.Object`
 
-        :return: ``True``, on success, ``False`` otherwise.
-        :rtype: bool
+        .. versionchanged:: 1.8
+            Raise RuntimeError on failure, instead of returning a bool
 
         """
-        return bool(elm_gesture_layer_attach(self.obj, target.obj))
-
+        if not elm_gesture_layer_attach(self.obj, target.obj):
+            raise RuntimeError
 
     property line_min_length:
         """Gesture layer line min length of an object
diff --git a/efl/elementary/icon.pyx b/efl/elementary/icon.pyx
index 3b5616d..fa03442 100644
--- a/efl/elementary/icon.pyx
+++ b/efl/elementary/icon.pyx
@@ -223,6 +223,10 @@ cdef class Icon(Image):
         :return bool: For 1.7 compatibility standard_set() returns a bool value
             that tells whether setting the standard name was succesful or not.
 
+        .. versionchanged:: 1.8
+            Raises RuntimeWarning when setting the standard name fails,
+            instead of returning a bool.
+
         """
         def __get__(self):
             return _ctouni(elm_icon_standard_get(self.obj))
diff --git a/efl/elementary/image.pyx b/efl/elementary/image.pyx
index bd64dc2..cd16f8a 100644
--- a/efl/elementary/image.pyx
+++ b/efl/elementary/image.pyx
@@ -182,6 +182,10 @@ cdef class Image(Object):
         :type: unicode **file** or (unicode **file**, unicode **group**)
         :raise RuntimeError: when setting the file fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError when setting the file fails, instead of
+            returning a bool.
+
         """
         def __set__(self, value):
             if isinstance(value, tuple):
diff --git a/efl/elementary/layout_class.pyx b/efl/elementary/layout_class.pyx
index 940f37d..798a7b3 100644
--- a/efl/elementary/layout_class.pyx
+++ b/efl/elementary/layout_class.pyx
@@ -84,17 +84,18 @@ cdef class LayoutClass(Object):
         :param content: The child that will be added in this layout object
         :type content: :py:class:`~efl.evas.Object`
 
-        :return: ``True`` on success, ``False`` otherwise
-        :rtype: bool
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the content fails.
 
         """
         if content is None:
             content = swallow
             swallow = None
         if isinstance(swallow, unicode): swallow = 
PyUnicode_AsUTF8String(swallow)
-        elm_layout_content_set(self.obj,
+        if not elm_layout_content_set(self.obj,
             <const_char *>swallow if swallow is not None else NULL,
-            content.obj if content is not None else NULL)
+            content.obj if content is not None else NULL):
+            raise RuntimeError
 
     def content_get(self, swallow=None):
         """content_get(unicode swallow) -> Object
@@ -137,7 +138,9 @@ cdef class LayoutClass(Object):
         :type part: string
         :param text: The text to set
         :type text: string
-        :return: ``True`` on success, ``False`` otherwise
+
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the text fails
 
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
@@ -147,9 +150,10 @@ cdef class LayoutClass(Object):
             # as text
             text = part
             part = None
-        elm_layout_text_set(self.obj,
+        if not elm_layout_text_set(self.obj,
             <const_char *>part if part is not None else NULL,
-            <const_char *>text if text is not None else NULL)
+            <const_char *>text if text is not None else NULL):
+            raise RuntimeError
 
     def text_get(self, part=None):
         """text_get(unicode part) -> unicode
@@ -175,6 +179,9 @@ cdef class LayoutClass(Object):
         :type: tuple of string
         :raise RuntimeError: when setting the file fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the file fails
+
         """
         def __set__(self, value):
             filename, group = value
@@ -232,6 +239,9 @@ cdef class LayoutClass(Object):
         :type: tuple of strings
         :raise RuntimeError: when setting the theme fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the theme fails
+
         """
         def __set__(self, theme):
             clas, group, style = theme
@@ -377,7 +387,10 @@ cdef class LayoutClass(Object):
         :param child: the child object to append to box.
         :type child: :py:class:`~efl.evas.Object`
 
-        :raise RuntimeError: when adding the box fails
+        :raise RuntimeError: when adding the child fails
+
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
 
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
@@ -409,6 +422,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when adding to box fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_box_prepend(self.obj,
@@ -441,6 +457,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when inserting to box fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_box_insert_before(self.obj,
@@ -473,6 +492,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when inserting to box fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_box_insert_at(self.obj,
@@ -529,6 +551,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when removing all items fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if removing the children fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_box_remove_all(self.obj,
@@ -569,6 +594,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when packing an item fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_table_pack(self.obj,
@@ -625,6 +653,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when clearing the table fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if clearing the table fails
+
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if not elm_layout_table_clear(self.obj,
@@ -730,6 +761,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when setting the parts cursor fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the cursor fails
+
         """
         if isinstance(part_name, unicode): part_name = 
PyUnicode_AsUTF8String(part_name)
         if isinstance(cursor, unicode): cursor = PyUnicode_AsUTF8String(cursor)
@@ -764,6 +798,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when unsetting the part cursor fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if unsetting the cursor fails
+
         """
         if isinstance(part_name, unicode): part_name = 
PyUnicode_AsUTF8String(part_name)
         if not elm_layout_part_cursor_unset(self.obj,
@@ -782,6 +819,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: when setting the part cursor style fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the cursor style fails
+
         """
         if isinstance(part_name, unicode): part_name = 
PyUnicode_AsUTF8String(part_name)
         if isinstance(style, unicode): style = PyUnicode_AsUTF8String(style)
@@ -830,6 +870,9 @@ cdef class LayoutClass(Object):
         :raise RuntimeError: when setting the engine_only setting fails,
             when part does not exist or has no cursor set.
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the value fails
+
         """
         if isinstance(part_name, unicode): part_name = 
PyUnicode_AsUTF8String(part_name)
         if not elm_layout_part_cursor_engine_only_set(self.obj,
@@ -861,6 +904,9 @@ cdef class LayoutClass(Object):
 
         :raise RuntimeError: if accessibility cannot be set.
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting accessibility fails
+
         """
         def __set__(self, can_access):
             if not elm_layout_edje_object_can_access_set(self.obj, can_access):
diff --git a/efl/elementary/photo.pyx b/efl/elementary/photo.pyx
index 96306c9..b11c6fb 100644
--- a/efl/elementary/photo.pyx
+++ b/efl/elementary/photo.pyx
@@ -62,6 +62,9 @@ cdef class Photo(Object):
         :type: string
         :raise RuntimeError: when setting the file fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the file fails
+
         """
         def __set__(self, filename):
             if isinstance(filename, unicode): filename = 
PyUnicode_AsUTF8String(filename)
diff --git a/efl/elementary/plug.pyx b/efl/elementary/plug.pyx
index a9aab48..0e50abd 100644
--- a/efl/elementary/plug.pyx
+++ b/efl/elementary/plug.pyx
@@ -74,13 +74,17 @@ cdef class Plug(Object):
             (set up by socket).
         :type svcsys: bool
 
-        :return: (``True`` = success, ``False`` = error)
-        :rtype: bool
+        :raise RuntimeError: on failure
+
+        .. versionchanged:: 1.8
+            Raises RuntimeError if adding the child fails
 
         """
         if isinstance(svcname, unicode): svcname = 
PyUnicode_AsUTF8String(svcname)
-        return bool(elm_plug_connect(self.obj,
-            <const_char *>svcname if svcname is not None else NULL, svcnum, 
svcsys))
+        if not elm_plug_connect(self.obj,
+            <const_char *>svcname if svcname is not None else NULL,
+            svcnum, svcsys):
+            raise RuntimeError
 
     property image_object:
         """Get the basic Image object from this object (widget).
diff --git a/efl/elementary/thumb.pyx b/efl/elementary/thumb.pyx
index bc8ddfd..cedf172 100644
--- a/efl/elementary/thumb.pyx
+++ b/efl/elementary/thumb.pyx
@@ -475,9 +475,15 @@ cdef class Thumb(Object):
 
         :type: bool
 
+        :raise RuntimeError: when cannot be set as editable
+
+        .. versionchanged:: 1.8
+            Raises RuntimeError if cannot be set as editable
+
         """
         def __set__(self, edit):
-            elm_thumb_editable_set(self.obj, edit)
+            if not elm_thumb_editable_set(self.obj, edit):
+                raise RuntimeError
         def __get__(self):
             return bool(elm_thumb_editable_get(self.obj))
 
diff --git a/efl/elementary/video.pyx b/efl/elementary/video.pyx
index f7f84ae..25c1e38 100644
--- a/efl/elementary/video.pyx
+++ b/efl/elementary/video.pyx
@@ -64,6 +64,9 @@ cdef class Video(LayoutClass):
         :type: string
         :raise RuntimeError: when setting the file/uri fails
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if setting the file/uri fails
+
         """
         def __set__(self, filename):
             if isinstance(filename, unicode): filename = 
PyUnicode_AsUTF8String(filename)
diff --git a/efl/elementary/web.pyx b/efl/elementary/web.pyx
index 99e9b6c..7309d87 100644
--- a/efl/elementary/web.pyx
+++ b/efl/elementary/web.pyx
@@ -512,6 +512,12 @@ cdef class Web(Object):
         return _ctouni(elm_web_url_get(self.obj))
 
     property uri:
+        """
+
+        .. deprecated:: 1.8
+            Use property "url" instead.
+
+        """
         def __get__(self):
             return self.uri_get()
 
diff --git a/efl/elementary/window.pyx b/efl/elementary/window.pyx
index f5c42e9..447caea 100644
--- a/efl/elementary/window.pyx
+++ b/efl/elementary/window.pyx
@@ -1529,8 +1529,12 @@ cdef class Window(Object):
             system-wide service all users can connect to, otherwise the
             service is private to the user id that created the service.
         :type svcsys: bool
+
         :raise RuntimeError: if the socket could not be created.
 
+        .. versionchanged:: 1.8
+            Raises RuntimeError if creating a socket fails
+
         """
         if isinstance(svcname, unicode): svcname = 
PyUnicode_AsUTF8String(svcname)
         if not elm_win_socket_listen(self.obj, <const_char *>svcname, svcnum, 
svcsys):

-- 


Reply via email to