From b4fcee3de22092d206747ba03275833917e9bbdb Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Mon, 16 Feb 2015 20:38:25 +0100 Subject: [PATCH] Use consistent indentation style with the rest of the code --- CODING | 14 ++++++++++++++ efl/elementary/image.pyx | 25 ++++++++++++------------- examples/elementary/test_image.py | 23 +++++++++-------------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/CODING b/CODING index a5c4600..1e4f965 100644 --- a/CODING +++ b/CODING @@ -8,6 +8,20 @@ Style * When comparing C pointers with NULL, use == and != instead of the python operator "is". This makes a visual distinction between python and C code. +* For long lines that do not fit in the 80 cols please use only the first + raccomandation from PEP-8 (Aligned with opening delimiter). Example: + Yes: + foo = long_function_name(var_one, var_two, + var_three, var_four) + No: + foo = long_function_name( + var_one, var_two, + var_three, var_four) + + This to keep new code consistent with the rest of the bindings and to + try to match the style of the C efl code style as much as possible. + ...also because I found it more readable and I like it more :P -davemds- + Design patterns =============== diff --git a/efl/elementary/image.pyx b/efl/elementary/image.pyx index 79cb7e3..e39ea59 100644 --- a/efl/elementary/image.pyx +++ b/efl/elementary/image.pyx @@ -195,19 +195,18 @@ cdef class Image(Object): self._set_properties_from_keyword_args(kwargs) def memfile_set(self, img, size, format=None, key=None): - """ - Set a location in memory to be used as an image object's source + """Set a location in memory to be used as an image object's source bitmap. This function is handy when the contents of an image file are mapped in memory, for example. The ``format`` string should be something like ``"png"``, ``"jpg"``, - ``"tga"``, ``"tiff"``, ``"bmp"`` etc, when provided. This improves the loader performance as it tries the - "correct" loader first, before trying a range of other possible - loaders until one succeeds. + ``"tga"``, ``"tiff"``, ``"bmp"`` etc, when provided. This improves + the loader performance as it tries the "correct" loader first, + before trying a range of other possible loaders until one succeeds. - :return: (``True`` = success, ``False`` = error) + :return: ``True`` = success, ``False`` = error .. versionadded:: 1.14 @@ -216,6 +215,7 @@ cdef class Image(Object): :param format: (Optional) expected format of ``img`` bytes :param key: Optional indexing key of ``img`` to be passed to the image loader (eg. if ``img`` is a memory-mapped EET file) + """ cdef Py_buffer view @@ -227,13 +227,12 @@ cdef class Image(Object): PyObject_GetBuffer(img, &view, PyBUF_SIMPLE) - ret = bool(elm_image_memfile_set( - self.obj, - view.buf, - size, - format if format else NULL, - key if key else NULL - )) + ret = bool(elm_image_memfile_set(self.obj, + view.buf, + size, + format if format else NULL, + key if key else NULL + )) PyBuffer_Release(&view) diff --git a/examples/elementary/test_image.py b/examples/elementary/test_image.py index e095cf2..4203c40 100644 --- a/examples/elementary/test_image.py +++ b/examples/elementary/test_image.py @@ -61,9 +61,8 @@ def image_clicked(obj, it=None): win.resize_object_add(vbox) vbox.show() - im = Image( - win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, - file=os.path.join(img_path, "logo.png")) + im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, + file=os.path.join(img_path, "logo.png")) vbox.pack_end(im) im.show() @@ -71,9 +70,8 @@ def image_clicked(obj, it=None): vbox.pack_end(sep) sep.show() - hbox = Box( - win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL, - size_hint_align=FILL_BOTH) + hbox = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL, + size_hint_align=FILL_BOTH) vbox.pack_end(hbox) hbox.show() @@ -96,9 +94,8 @@ def image_clicked(obj, it=None): b.callback_clicked_add(lambda b: im.file_set(remote_url)) b.show() - pb = Progressbar( - win, size_hint_weight=EXPAND_BOTH, - size_hint_align=FILL_BOTH) + pb = Progressbar(win, size_hint_weight=EXPAND_BOTH, + size_hint_align=FILL_BOTH) hbox.pack_end(pb) pb.show() @@ -118,8 +115,7 @@ def image2_clicked(obj, it=None): vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) - im = Image( - win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) + im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) with open(os.path.join(img_path, "logo.png"), "rb") as fp: image_data = fp.read() @@ -133,9 +129,8 @@ def image2_clicked(obj, it=None): if __name__ == "__main__": elementary.init() - win = StandardWindow( - "test", "python-elementary test application", - size=(320, 520)) + win = StandardWindow("test", "python-elementary test application", + size=(320, 520)) win.callback_delete_request_add(lambda o: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH)