[pygobject] PEP8: run via --fix from craigds fork
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] PEP8: run via --fix from craigds fork
- Date: Thu, 22 Mar 2012 14:33:08 +0000 (UTC)
commit 725483a5dc36739dc7836716b5d6d48091564bf8
Author: Johan Dahlin <johan gnome org>
Date: Thu Mar 22 10:38:59 2012 -0300
PEP8: run via --fix from craigds fork
https://bugzilla.gnome.org/show_bug.cgi?id=672627
demos/gtk-demo/demos/Entry/entry_buffer.py | 1 +
demos/gtk-demo/demos/Entry/entry_completion.py | 1 +
demos/gtk-demo/demos/Entry/search_entry.py | 3 +-
demos/gtk-demo/demos/Icon View/iconviewbasics.py | 1 +
demos/gtk-demo/demos/Icon View/iconviewedit.py | 2 +
demos/gtk-demo/demos/Tree View/liststore.py | 3 +
demos/gtk-demo/demos/appwindow.py | 13 ++++-
demos/gtk-demo/demos/assistant.py | 1 +
demos/gtk-demo/demos/builder.py | 1 +
demos/gtk-demo/demos/button_box.py | 1 +
demos/gtk-demo/demos/clipboard.py | 2 +-
demos/gtk-demo/demos/colorselector.py | 1 +
demos/gtk-demo/demos/combobox.py | 4 +-
demos/gtk-demo/demos/dialogs.py | 2 +
demos/gtk-demo/demos/drawingarea.py | 1 +
demos/gtk-demo/demos/expander.py | 4 +-
demos/gtk-demo/demos/images.py | 10 ++--
demos/gtk-demo/demos/infobars.py | 2 +
demos/gtk-demo/demos/links.py | 2 +
demos/gtk-demo/demos/menus.py | 2 +
demos/gtk-demo/demos/pickers.py | 2 +
demos/gtk-demo/demos/pixbuf.py | 2 +
demos/gtk-demo/demos/printing.py | 5 +-
demos/gtk-demo/demos/rotatedtext.py | 4 +-
demos/gtk-demo/demos/test.py | 1 +
demos/gtk-demo/gtk-demo.py | 9 ++--
examples/cairo-demo.py | 57 +++++++++++++---------
examples/option.py | 1 -
examples/properties.py | 1 +
examples/signal.py | 4 ++
gi/__init__.py | 2 +
gi/_glib/option.py | 4 +-
gi/_gobject/__init__.py | 1 +
gi/_gobject/propertyhelper.py | 5 +-
gi/module.py | 3 +
gi/overrides/GIMarshallingTests.py | 2 +
gi/overrides/GLib.py | 12 ++++-
gi/overrides/Gdk.py | 9 ++++
gi/overrides/Gio.py | 4 ++
gi/overrides/Gtk.py | 56 +++++++++++++++++++--
gi/overrides/Pango.py | 2 +
gi/overrides/__init__.py | 5 ++-
gi/pygtkcompat.py | 16 +++++-
gi/types.py | 4 ++
tests/test_everything.py | 30 ++++++++----
tests/test_gdbus.py | 1 +
tests/test_gi.py | 30 ++++++-----
tests/test_gobject.py | 3 +-
tests/test_mainloop.py | 1 +
tests/test_option.py | 1 +
tests/test_overrides.py | 55 +++++++++++----------
tests/test_properties.py | 11 ++++-
tests/test_signal.py | 32 +++++++++++-
tests/test_source.py | 1 +
tests/test_subprocess.py | 1 +
tests/test_thread.py | 1 +
tests/test_uris.py | 1 +
tests/testmodule.py | 1 +
58 files changed, 326 insertions(+), 111 deletions(-)
---
diff --git a/demos/gtk-demo/demos/Entry/entry_buffer.py b/demos/gtk-demo/demos/Entry/entry_buffer.py
index 39d4f8b..00b6602 100644
--- a/demos/gtk-demo/demos/Entry/entry_buffer.py
+++ b/demos/gtk-demo/demos/Entry/entry_buffer.py
@@ -64,6 +64,7 @@ class EntryBufferApp:
self.window.destroy()
Gtk.main_quit()
+
def main(demoapp=None):
EntryBufferApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/Entry/entry_completion.py b/demos/gtk-demo/demos/Entry/entry_completion.py
index a5387ac..6229a12 100644
--- a/demos/gtk-demo/demos/Entry/entry_completion.py
+++ b/demos/gtk-demo/demos/Entry/entry_completion.py
@@ -78,6 +78,7 @@ class EntryBufferApp:
self.window.destroy()
Gtk.main_quit()
+
def main(demoapp=None):
EntryBufferApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/Entry/search_entry.py b/demos/gtk-demo/demos/Entry/search_entry.py
index 7307fc7..8d8165f 100644
--- a/demos/gtk-demo/demos/Entry/search_entry.py
+++ b/demos/gtk-demo/demos/Entry/search_entry.py
@@ -29,6 +29,7 @@ from gi.repository import Gtk, GObject
(PIXBUF_COL,
TEXT_COL) = range(2)
+
class SearchboxApp:
def __init__(self, demoapp):
self.demoapp = demoapp
@@ -199,7 +200,6 @@ class SearchboxApp:
return menu
-
def icon_press_cb(self, entry, position, event, menu):
if position == Gtk.EntryIconPosition.PRIMARY:
menu.popup(None, None, None, None,
@@ -244,6 +244,7 @@ class SearchboxApp:
item.set_submenu(search_menu)
menu.append (item)
+
def main(demoapp=None):
SearchboxApp(demoapp)
Gtk.main()
diff --git a/demos/gtk-demo/demos/Icon View/iconviewbasics.py b/demos/gtk-demo/demos/Icon View/iconviewbasics.py
index fbf1eb3..b214a6f 100644
--- a/demos/gtk-demo/demos/Icon View/iconviewbasics.py
+++ b/demos/gtk-demo/demos/Icon View/iconviewbasics.py
@@ -212,6 +212,7 @@ class IconViewApp:
pixbuf = self.file_to_icon_pixbuf(path)
store.append((path, name, pixbuf, is_dir))
+
def main(demoapp=None):
IconViewApp(demoapp)
Gtk.main()
diff --git a/demos/gtk-demo/demos/Icon View/iconviewedit.py b/demos/gtk-demo/demos/Icon View/iconviewedit.py
index fe5e8e9..73884c1 100644
--- a/demos/gtk-demo/demos/Icon View/iconviewedit.py
+++ b/demos/gtk-demo/demos/Icon View/iconviewedit.py
@@ -26,6 +26,7 @@ The GtkIconView widget supports Editing and Drag-and-Drop. This example also dem
from gi.repository import Gtk, Gdk, GdkPixbuf
+
class IconviewEditApp:
COL_TEXT = 0
NUM_COLS = 1
@@ -88,6 +89,7 @@ class IconviewEditApp:
iter_ = model.get_iter(path)
model.set_row(iter_, [text])
+
def main(demoapp=None):
IconviewEditApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/Tree View/liststore.py b/demos/gtk-demo/demos/Tree View/liststore.py
index d0d72e7..d8f5d95 100644
--- a/demos/gtk-demo/demos/Tree View/liststore.py
+++ b/demos/gtk-demo/demos/Tree View/liststore.py
@@ -26,6 +26,7 @@ The GtkListStore is used to store data in list form, to be used later on by a Gt
from gi.repository import Gtk, GObject
+
class Bug:
def __init__(self, is_fixed, number, severity, description):
self.is_fixed = is_fixed
@@ -49,6 +50,7 @@ data = [Bug(False, 60482, "Normal", "scrollable notebooks and hidden tabs"),
Bug(False, 6112, "Enhancement","netscape-like collapsable toolbars"),
Bug(False, 1, "Normal", "First bug :=)")]
+
class ListStoreApp:
(COLUMN_FIXED,
COLUMN_NUMBER,
@@ -196,6 +198,7 @@ class ListStoreApp:
model.set_value(iter_, self.COLUMN_FIXED, is_fixed)
+
def main(demoapp=None):
ListStoreApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py
index 4695b45..5a01d32 100644
--- a/demos/gtk-demo/demos/appwindow.py
+++ b/demos/gtk-demo/demos/appwindow.py
@@ -34,9 +34,11 @@ window = None
messagelabel = None
_demoapp = None
+
def widget_destroy(widget, button):
widget.destroy()
+
def activate_action(action, user_data=None):
global window
@@ -48,7 +50,6 @@ def activate_action(action, user_data=None):
settings.set_property('gtk-application-prefer-dark-theme', value)
return
-
dialog = Gtk.MessageDialog(message_type=Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.CLOSE,
text='You activated action: "%s" of type %s' % (name, _type))
@@ -58,6 +59,7 @@ def activate_action(action, user_data=None):
dialog.connect('response', widget_destroy)
dialog.show()
+
def activate_radio_action(action, current, user_data=None):
global infobar
global messagelabel
@@ -72,6 +74,7 @@ def activate_radio_action(action, current, user_data=None):
infobar.set_message_type(Gtk.MessageType(value))
infobar.show()
+
def update_statusbar(buffer, statusbar):
statusbar.pop(0)
count = buffer.get_char_count()
@@ -83,9 +86,11 @@ def update_statusbar(buffer, statusbar):
statusbar.push(0, msg)
+
def mark_set_callback(buffer, new_location, mark, data):
update_statusbar(buffer, data)
+
def about_cb(widget, user_data=None):
global window
@@ -258,9 +263,11 @@ ui_info = """
</ui>
"""
+
def _quit(*args):
Gtk.main_quit()
+
def register_stock_icons():
"""
This function registers our custom toolbar icons, so they can be themed.
@@ -294,11 +301,14 @@ def register_stock_icons():
factory.add('demo-gtk-logo', icon_set)
+
class ToolMenuAction(Gtk.Action):
__gtype_name__ = "GtkToolMenuAction"
+
def do_create_tool_item(self):
return Gtk.MenuToolButton()
+
def main(demoapp=None):
global infobar
global window
@@ -352,7 +362,6 @@ def main(demoapp=None):
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
0, 0, 0)
-
infobar = Gtk.InfoBar()
infobar.set_no_show_all(True)
messagelabel = Gtk.Label()
diff --git a/demos/gtk-demo/demos/assistant.py b/demos/gtk-demo/demos/assistant.py
index de42394..b1d8720 100644
--- a/demos/gtk-demo/demos/assistant.py
+++ b/demos/gtk-demo/demos/assistant.py
@@ -125,6 +125,7 @@ class AssistantApp:
None)
self.assistant.set_page_header_image(label, pixbuf)
+
def main(demoapp=None):
AssistantApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/builder.py b/demos/gtk-demo/demos/builder.py
index 196cc9d..c557d06 100644
--- a/demos/gtk-demo/demos/builder.py
+++ b/demos/gtk-demo/demos/builder.py
@@ -55,6 +55,7 @@ class BuilderApp:
def quit_activate(self, action):
Gtk.main_quit()
+
def main(demoapp=None):
BuilderApp(demoapp)
Gtk.main()
diff --git a/demos/gtk-demo/demos/button_box.py b/demos/gtk-demo/demos/button_box.py
index 8695dc2..8c9a0bf 100644
--- a/demos/gtk-demo/demos/button_box.py
+++ b/demos/gtk-demo/demos/button_box.py
@@ -112,6 +112,7 @@ class ButtonBoxApp:
return frame
+
def main(demoapp=None):
ButtonBoxApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/clipboard.py b/demos/gtk-demo/demos/clipboard.py
index 4622690..4fb7b2e 100644
--- a/demos/gtk-demo/demos/clipboard.py
+++ b/demos/gtk-demo/demos/clipboard.py
@@ -64,7 +64,6 @@ class ClipboardApp:
label = Gtk.Label(label='"Paste" will paste the text from the clipboard to the entry')
vbox.pack_start(label, False, False, 0)
-
hbox = Gtk.HBox(homogeneous=False, spacing=4)
hbox.set_border_width(8)
vbox.pack_start(hbox, False, False, 0)
@@ -223,6 +222,7 @@ class ClipboardApp:
self.menu.popup(None, None, None, None, event.button, event.time)
+
def main(demoapp=None):
ClipboardApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/colorselector.py b/demos/gtk-demo/demos/colorselector.py
index 7dfb098..3dee3d1 100644
--- a/demos/gtk-demo/demos/colorselector.py
+++ b/demos/gtk-demo/demos/colorselector.py
@@ -102,6 +102,7 @@ class ColorSelectorApp:
dialog.destroy()
+
def main(demoapp=None):
ColorSelectorApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/combobox.py b/demos/gtk-demo/demos/combobox.py
index 8335b5e..1e4fa91 100644
--- a/demos/gtk-demo/demos/combobox.py
+++ b/demos/gtk-demo/demos/combobox.py
@@ -35,6 +35,7 @@ from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
(PIXBUF_COL,
TEXT_COL) = range(2)
+
class MaskEntry(Gtk.Entry):
__gtype_name__ = 'MaskEntry'
@@ -66,6 +67,7 @@ class MaskEntry(Gtk.Entry):
def changed_cb(self, entry):
self.set_background()
+
class ComboboxApp:
def __init__(self, demoapp):
self.demoapp = demoapp
@@ -323,13 +325,13 @@ class ComboboxApp:
sensitive = not tree_model.iter_has_child(treeiter)
cell.set_property('sensitive', sensitive)
-
def fill_combo_entry(self, entry):
entry.append_text('One')
entry.append_text('Two')
entry.append_text('2\302\275')
entry.append_text('Three')
+
def main(demoapp=None):
ComboboxApp(demoapp)
Gtk.main()
diff --git a/demos/gtk-demo/demos/dialogs.py b/demos/gtk-demo/demos/dialogs.py
index b90d62a..2b4f9fe 100644
--- a/demos/gtk-demo/demos/dialogs.py
+++ b/demos/gtk-demo/demos/dialogs.py
@@ -26,6 +26,7 @@ Dialog widgets are used to pop up a transient window for user feedback.
from gi.repository import Gtk
+
class DialogsApp:
def __init__(self):
self.dialog_counter = 1
@@ -145,6 +146,7 @@ class DialogsApp:
self.dialog_counter += 1
dialog.destroy()
+
def main(demoapp=None):
DialogsApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/drawingarea.py b/demos/gtk-demo/demos/drawingarea.py
index 5d65fc4..8bc5b7f 100644
--- a/demos/gtk-demo/demos/drawingarea.py
+++ b/demos/gtk-demo/demos/drawingarea.py
@@ -197,6 +197,7 @@ class DrawingAreaApp:
return True
+
def main(demoapp=None):
DrawingAreaApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/expander.py b/demos/gtk-demo/demos/expander.py
index 8ee9e2a..1e8326d 100644
--- a/demos/gtk-demo/demos/expander.py
+++ b/demos/gtk-demo/demos/expander.py
@@ -27,13 +27,14 @@ This is also known as "disclosure triangle".
from gi.repository import Gtk
+
class ExpanderApp:
def __init__(self):
self.window = Gtk.Dialog("GtkExpander",
None, 0,
(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE))
self.window.set_resizable(False)
- self.window.connect('response', lambda window, x:window.destroy())
+ self.window.connect('response', lambda window, x: window.destroy())
self.window.connect('destroy', Gtk.main_quit)
content_area = self.window.get_content_area()
@@ -52,6 +53,7 @@ class ExpanderApp:
self.window.show_all()
+
def main(demoapp=None):
ExpanderApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/images.py b/demos/gtk-demo/demos/images.py
index a81245a..488d075 100644
--- a/demos/gtk-demo/demos/images.py
+++ b/demos/gtk-demo/demos/images.py
@@ -29,6 +29,7 @@ from os import path
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, Gio, GObject
+
class ImagesApp:
def __init__(self):
self.pixbuf_loader = None
@@ -168,7 +169,7 @@ class ImagesApp:
self.load_timeout = 0
dialog.show()
- dialog.connect('response', lambda x,y: dialog.destroy())
+ dialog.connect('response', lambda x, y: dialog.destroy())
return False # uninstall the timeout
@@ -187,7 +188,7 @@ class ImagesApp:
self.load_timeout = 0
dialog.show()
- dialog.connect('response', lambda x,y: dialog.destroy())
+ dialog.connect('response', lambda x, y: dialog.destroy())
return False # uninstall the timeout
@@ -210,7 +211,7 @@ class ImagesApp:
self.load_timeout = 0
dialog.show()
- dialog.connect('response', lambda x,y: dialog.destroy())
+ dialog.connect('response', lambda x, y: dialog.destroy())
return False # uninstall the timeout
else:
@@ -225,7 +226,7 @@ class ImagesApp:
str(e))
self.load_timeout = 0
dialog.show()
- dialog.connect('response', lambda x,y: dialog.destroy())
+ dialog.connect('response', lambda x, y: dialog.destroy())
return False # uninstall the timeout
@@ -292,6 +293,7 @@ class ImagesApp:
Gtk.main_quit()
+
def main(demoapp=None):
ImagesApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/infobars.py b/demos/gtk-demo/demos/infobars.py
index fbbdc1d..047df51 100644
--- a/demos/gtk-demo/demos/infobars.py
+++ b/demos/gtk-demo/demos/infobars.py
@@ -26,6 +26,7 @@ Info bar widgets are used to report important messages to the user.
from gi.repository import Gtk
+
class InfobarApp:
def __init__(self):
self.window = Gtk.Window()
@@ -91,6 +92,7 @@ class InfobarApp:
dialog.run()
dialog.destroy()
+
def main(demoapp=None):
InfobarApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/links.py b/demos/gtk-demo/demos/links.py
index d812efe..e6ca731 100644
--- a/demos/gtk-demo/demos/links.py
+++ b/demos/gtk-demo/demos/links.py
@@ -27,6 +27,7 @@ their URI, but it is possible to override this with a custom handler.
from gi.repository import Gtk
+
class LinksApp:
def __init__(self):
self.window = Gtk.Window()
@@ -66,6 +67,7 @@ a program (exclusively) via keyboard input."""
def response_cb(self, dialog, response_id):
dialog.destroy()
+
def main(demoapp=None):
LinksApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/menus.py b/demos/gtk-demo/demos/menus.py
index 6b70361..754875a 100644
--- a/demos/gtk-demo/demos/menus.py
+++ b/demos/gtk-demo/demos/menus.py
@@ -28,6 +28,7 @@ GtkUIManager provides a higher-level interface for creating menu bars and menus;
from gi.repository import Gtk
+
class MenusApp:
def __init__(self):
self.window = Gtk.Window()
@@ -111,6 +112,7 @@ class MenusApp:
else:
menubar.props.pack_direction = Gtk.PackDirection.LTR
+
def main(demoapp=None):
MenusApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/pickers.py b/demos/gtk-demo/demos/pickers.py
index 8d0046a..1abd626 100644
--- a/demos/gtk-demo/demos/pickers.py
+++ b/demos/gtk-demo/demos/pickers.py
@@ -26,6 +26,7 @@ These widgets are mainly intended for use in preference dialogs. They allow to s
from gi.repository import Gtk
+
class PickersApp:
def __init__(self):
self.window = Gtk.Window(title='Pickers')
@@ -66,6 +67,7 @@ class PickersApp:
self.window.show_all()
+
def main(demoapp=None):
PickersApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/pixbuf.py b/demos/gtk-demo/demos/pixbuf.py
index 3f5fbc5..30a8094 100644
--- a/demos/gtk-demo/demos/pixbuf.py
+++ b/demos/gtk-demo/demos/pixbuf.py
@@ -29,6 +29,7 @@ from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject
import os
import math
+
class PixbufApp:
FRAME_DELAY = 50
BACKGROUND_NAME = "background.jpg"
@@ -172,6 +173,7 @@ class PixbufApp:
GObject.source_remove(self.timeout_id)
Gtk.main_quit()
+
def main(demoapp=None):
PixbufApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/printing.py b/demos/gtk-demo/demos/printing.py
index 923fbba..1702a95 100644
--- a/demos/gtk-demo/demos/printing.py
+++ b/demos/gtk-demo/demos/printing.py
@@ -30,8 +30,8 @@ import os
class PrintingApp:
- HEADER_HEIGHT = 10*72/25.4
- HEADER_GAP = 3*72/25.4
+ HEADER_HEIGHT = 10 * 72 / 25.4
+ HEADER_GAP = 3 * 72 / 25.4
def __init__(self):
self.operation = Gtk.PrintOperation()
@@ -169,6 +169,7 @@ class PrintingApp:
def end_print(self, operation, print_ctx, print_data):
pass
+
def main(demoapp=None):
app = PrintingApp()
GLib.idle_add(app.run, demoapp)
diff --git a/demos/gtk-demo/demos/rotatedtext.py b/demos/gtk-demo/demos/rotatedtext.py
index 2a1b332..e2a406d 100644
--- a/demos/gtk-demo/demos/rotatedtext.py
+++ b/demos/gtk-demo/demos/rotatedtext.py
@@ -42,6 +42,7 @@ else:
HEART = "â"
BYTES_HEART = bytes(HEART, 'utf-8')
+
class RotatedTextApp:
RADIUS = 150
N_WORDS = 5
@@ -184,10 +185,11 @@ class RotatedTextApp:
PangoCairo.show_layout(cairo_ctx, layout)
# Rotate for the next turn
- cairo_ctx.rotate(math.pi*2 / self.N_WORDS)
+ cairo_ctx.rotate(math.pi * 2 / self.N_WORDS)
return False
+
def main(demoapp=None):
RotatedTextApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/test.py b/demos/gtk-demo/demos/test.py
index 202546a..4bd7684 100644
--- a/demos/gtk-demo/demos/test.py
+++ b/demos/gtk-demo/demos/test.py
@@ -8,6 +8,7 @@ from gi.repository import Gtk
def _quit(*args):
Gtk.main_quit()
+
def main(demoapp=None):
window = Gtk.Window()
window.connect_after('destroy', _quit)
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index bb36093..bd0e44a 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -29,7 +29,6 @@ import sys
from gi.repository import GLib, GObject, Pango, GdkPixbuf, Gtk
-
DEMOROOTDIR = os.path.abspath(os.path.dirname(__file__))
DEMOCODEDIR = os.path.join(DEMOROOTDIR, 'demos')
sys.path.insert(0, DEMOROOTDIR)
@@ -43,7 +42,7 @@ class InputStream(object):
function isn't used in such a context. (see <python-lib>/tokenize.py)
"""
def __init__(self, data):
- self.__data = [ '%s\n' % x for x in data.splitlines() ]
+ self.__data = ['%s\n' % x for x in data.splitlines()]
self.__lcount = 0
def readline(self):
@@ -340,9 +339,9 @@ class GtkDemoWindow(Gtk.Window):
is_func = False
def prepare_iters():
- start_iter.set_line(srow-1)
+ start_iter.set_line(srow - 1)
start_iter.set_line_offset(scol)
- end_iter.set_line(erow-1)
+ end_iter.set_line(erow - 1)
end_iter.set_line_offset(ecol)
for x in tokenize.generate_tokens(InputStream(data).readline):
@@ -394,6 +393,7 @@ class GtkDemoWindow(Gtk.Window):
if is_decorator is True:
is_decorator = False
+
def main():
mainloop = GLib.MainLoop()
@@ -403,6 +403,7 @@ def main():
mainloop.run()
+
def quit(widget, event, mainloop):
mainloop.quit()
diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py
index 1cc69bf..5f5bf6b 100755
--- a/examples/cairo-demo.py
+++ b/examples/cairo-demo.py
@@ -8,39 +8,44 @@ from gi.repository import Gtk
SIZE = 30
+
def triangle(ctx):
ctx.move_to(SIZE, 0)
- ctx.rel_line_to(SIZE, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
+ ctx.rel_line_to(SIZE, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
ctx.close_path()
+
def square(ctx):
ctx.move_to(0, 0)
- ctx.rel_line_to(2*SIZE, 0)
- ctx.rel_line_to(0, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
+ ctx.rel_line_to(2 * SIZE, 0)
+ ctx.rel_line_to(0, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
ctx.close_path()
+
def bowtie(ctx):
ctx.move_to(0, 0)
- ctx.rel_line_to(2*SIZE, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
- ctx.rel_line_to(2*SIZE, -2*SIZE)
+ ctx.rel_line_to(2 * SIZE, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
+ ctx.rel_line_to(2 * SIZE, -2 * SIZE)
ctx.close_path()
+
def inf(ctx):
ctx.move_to(0, SIZE)
- ctx.rel_curve_to(0,SIZE, SIZE,SIZE, 2*SIZE,0)
- ctx.rel_curve_to(SIZE,-SIZE, 2*SIZE,-SIZE, 2*SIZE,0)
- ctx.rel_curve_to(0,SIZE, -SIZE,SIZE, -2*SIZE,0)
- ctx.rel_curve_to(-SIZE,-SIZE, -2*SIZE,-SIZE, -2*SIZE,0)
+ ctx.rel_curve_to(0, SIZE, SIZE, SIZE, 2*SIZE, 0)
+ ctx.rel_curve_to(SIZE, -SIZE, 2 *SIZE, -SIZE, 2*SIZE, 0)
+ ctx.rel_curve_to(0, SIZE, -SIZE, SIZE, - 2*SIZE, 0)
+ ctx.rel_curve_to(-SIZE, -SIZE, - 2 *SIZE, -SIZE, - 2*SIZE, 0)
ctx.close_path()
+
def draw_shapes(ctx, x, y, fill):
ctx.save()
ctx.new_path()
- ctx.translate(x+SIZE, y+SIZE)
+ ctx.translate(x + SIZE, y + SIZE)
bowtie(ctx)
if fill:
ctx.fill()
@@ -48,7 +53,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
square(ctx)
if fill:
ctx.fill()
@@ -56,7 +61,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
triangle(ctx)
if fill:
ctx.fill()
@@ -64,7 +69,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
inf(ctx)
if fill:
ctx.fill()
@@ -73,12 +78,15 @@ def draw_shapes(ctx, x, y, fill):
ctx.restore()
+
def fill_shapes(ctx, x, y):
draw_shapes(ctx, x, y, True)
+
def stroke_shapes(ctx, x, y):
draw_shapes(ctx, x, y, False)
+
def draw(da, ctx):
ctx.set_source_rgb(0, 0, 0)
@@ -86,24 +94,25 @@ def draw(da, ctx):
ctx.set_tolerance(0.1)
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
- ctx.set_dash([SIZE/4.0, SIZE/4.0], 0)
+ ctx.set_dash([SIZE / 4.0, SIZE / 4.0], 0)
stroke_shapes(ctx, 0, 0)
ctx.set_dash([], 0)
- stroke_shapes(ctx, 0, 3*SIZE)
+ stroke_shapes(ctx, 0, 3 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
- stroke_shapes(ctx, 0, 6*SIZE)
+ stroke_shapes(ctx, 0, 6 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_MITER)
- stroke_shapes(ctx, 0, 9*SIZE)
+ stroke_shapes(ctx, 0, 9 * SIZE)
- fill_shapes(ctx, 0, 12*SIZE)
+ fill_shapes(ctx, 0, 12 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
- fill_shapes(ctx, 0, 15*SIZE)
- ctx.set_source_rgb(1,0,0)
- stroke_shapes(ctx, 0, 15*SIZE)
+ fill_shapes(ctx, 0, 15 * SIZE)
+ ctx.set_source_rgb(1, 0, 0)
+ stroke_shapes(ctx, 0, 15 * SIZE)
+
def main():
win = Gtk.Window()
diff --git a/examples/option.py b/examples/option.py
index c05d0a8..4c61602 100644
--- a/examples/option.py
+++ b/examples/option.py
@@ -10,7 +10,6 @@ group = OptionGroup("example", "OptionGroup Example", "Shows all example options
dest="example",
help="An example option."),
])
-
parser = OptionParser("NAMES ...",
description="A simple gobject.option example.",
option_list=[
diff --git a/examples/properties.py b/examples/properties.py
index eebfb16..465b3c3 100644
--- a/examples/properties.py
+++ b/examples/properties.py
@@ -1,5 +1,6 @@
from gi.repository import GObject
+
class MyObject(GObject.GObject):
foo = GObject.Property(type=str, default='bar')
diff --git a/examples/signal.py b/examples/signal.py
index d1b7357..057adda 100644
--- a/examples/signal.py
+++ b/examples/signal.py
@@ -1,18 +1,22 @@
from gi.repository import GObject
+
class C(GObject.GObject):
__gsignals__ = {
'my_signal': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
(GObject.TYPE_INT,))
}
+
def do_my_signal(self, arg):
print "C: class closure for `my_signal' called with argument", arg
+
class D(C):
def do_my_signal(self, arg):
print "D: class closure for `my_signal' called. Chaining up to C"
C.do_my_signal(self, arg)
+
def my_signal_handler(object, arg, *extra):
print "handler for `my_signal' called with argument", arg, \
"and extra args", extra
diff --git a/gi/__init__.py b/gi/__init__.py
index d72351b..0ebac0b 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -34,6 +34,7 @@ import os
_versions = {}
_overridesdir = os.path.join(os.path.dirname(__file__), 'overrides')
+
def require_version(namespace, version):
repository = Repository.get_default()
@@ -57,5 +58,6 @@ def require_version(namespace, version):
_versions[namespace] = version
+
def get_required_version(namespace):
return _versions.get(namespace, None)
diff --git a/gi/_glib/option.py b/gi/_glib/option.py
index 3219047..b5b03cb 100644
--- a/gi/_glib/option.py
+++ b/gi/_glib/option.py
@@ -57,6 +57,7 @@ __all__ = [
"make_option",
]
+
class Option(optparse.Option):
"""Represents a command line option
@@ -105,7 +106,6 @@ class Option(optparse.Option):
if not self.help:
raise ValueError("%s needs a help message.", self._long_opts[0])
-
def _set_opt_string(self, opts):
if self.REMAINING in opts:
self._long_opts.append(self.REMAINING)
@@ -138,6 +138,7 @@ class Option(optparse.Option):
for long_name in self._long_opts[len(self._short_opts):]:
yield (long_name[2:], _bytes('\0'), flags, self.help, self.metavar)
+
class OptionGroup(optparse.OptionGroup):
"""A group of command line options.
@@ -229,6 +230,7 @@ class OptionGroup(optparse.OptionGroup):
opt_str, default)
self.values = optparse.Values(self.defaults)
+
class OptionParser(optparse.OptionParser):
"""Command line parser with GOption support.
diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py
index 8fadfea..affd3df 100644
--- a/gi/_gobject/__init__.py
+++ b/gi/_gobject/__init__.py
@@ -210,6 +210,7 @@ G_MAXOFFSET = constants.G_MAXOFFSET
from .._glib import option
sys.modules['gi._gobject.option'] = option
+
class GObjectMeta(type):
"Metaclass for automatically registering GObject classes"
def __init__(cls, name, bases, dict_):
diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py
index 80fe46b..da748b8 100644
--- a/gi/_gobject/propertyhelper.py
+++ b/gi/_gobject/propertyhelper.py
@@ -42,6 +42,7 @@ else:
_basestring = basestring
_long = long
+
class Property(object):
"""
Creates a new property which in conjunction with GObject subclass will
@@ -304,10 +305,10 @@ class Property(object):
#
def _default_setter(self, instance, value):
- setattr(instance, '_property_helper_'+self.name, value)
+ setattr(instance, '_property_helper_' + self.name, value)
def _default_getter(self, instance):
- return getattr(instance, '_property_helper_'+self.name, self.default)
+ return getattr(instance, '_property_helper_' + self.name, self.default)
def _readonly_setter(self, instance, value):
self._exc = TypeError("%s property of %s is read-only" % (
diff --git a/gi/module.py b/gi/module.py
index 29b9002..da84cda 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -55,6 +55,7 @@ from .types import \
repository = Repository.get_default()
+
def get_parent_for_object(object_info):
parent_object_info = object_info.get_parent()
@@ -208,6 +209,7 @@ class IntrospectionModule(object):
return list(result)
+
class DynamicModule(object):
def __init__(self, namespace):
self._namespace = namespace
@@ -258,6 +260,7 @@ class DynamicModule(object):
self._namespace,
path)
+
class DynamicGObjectModule(DynamicModule):
"""Wrapper for the internal GObject module
diff --git a/gi/overrides/GIMarshallingTests.py b/gi/overrides/GIMarshallingTests.py
index aac8883..a25eda7 100644
--- a/gi/overrides/GIMarshallingTests.py
+++ b/gi/overrides/GIMarshallingTests.py
@@ -28,6 +28,7 @@ __all__ = []
OVERRIDES_CONSTANT = 7
__all__.append('OVERRIDES_CONSTANT')
+
class OverridesStruct(GIMarshallingTests.OverridesStruct):
def __new__(cls, long_):
@@ -43,6 +44,7 @@ class OverridesStruct(GIMarshallingTests.OverridesStruct):
OverridesStruct = override(OverridesStruct)
__all__.append('OverridesStruct')
+
class OverridesObject(GIMarshallingTests.OverridesObject):
def __new__(cls, long_):
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index b6e0b09..04f7c2e 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -25,6 +25,7 @@ GLib = modules['GLib']._introspection_module
__all__ = []
+
class _VariantCreator(object):
_LEAF_CONSTRUCTORS = {
@@ -109,7 +110,7 @@ class _VariantCreator(object):
rest_format = self._create(rest_format, None)[1]
if not rest_format.startswith('}'):
raise ValueError('dictionary type string not closed with }')
- rest_format = rest_format[1:] # eat the }
+ rest_format = rest_format[1:] # eat the}
element_type = format[:len(format) - len(rest_format)]
builder = GLib.VariantBuilder.new(variant_type_from_string(element_type))
else:
@@ -120,7 +121,7 @@ class _VariantCreator(object):
if not rest_format.startswith('}'):
raise ValueError('dictionary type string not closed with }')
- rest_format = rest_format[1:] # eat the }
+ rest_format = rest_format[1:] # eat the}
entry = GLib.VariantBuilder.new(variant_type_from_string('{?*}'))
entry.add_value(key_v)
@@ -150,6 +151,7 @@ class _VariantCreator(object):
args = args[1:]
return (builder.end(), rest_format, args)
+
class Variant(GLib.Variant):
def __new__(cls, format_string, value):
'''Create a GVariant from a native Python object.
@@ -257,7 +259,7 @@ class Variant(GLib.Variant):
result = []
head = ''
- tail = signature[1:-1] # eat the surrounding ( )
+ tail = signature[1:-1] # eat the surrounding ()
while tail:
c = tail[0]
head += c
@@ -292,6 +294,7 @@ class Variant(GLib.Variant):
#
# Pythonic iterators
#
+
def __len__(self):
if self.get_type_string() in ['s', 'o', 'g']:
return len(self.get_string())
@@ -336,6 +339,7 @@ class Variant(GLib.Variant):
#
# Pythonic bool operations
#
+
def __nonzero__(self):
return self.__bool__()
@@ -365,10 +369,12 @@ class Variant(GLib.Variant):
res.append(v.get_child_value(0).unpack())
return res
+
@classmethod
def new_tuple(cls, *elements):
return variant_new_tuple(elements)
+
def get_string(self):
value, length = GLib.Variant.get_string(self)
return value
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 8761ae8..604ac37 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -28,6 +28,7 @@ Gdk = modules['Gdk']._introspection_module
__all__ = []
+
class Color(Gdk.Color):
def __init__(self, red, green, blue):
@@ -106,8 +107,10 @@ else:
# Gdk.Window had to be made abstract,
# this override allows using the standard constructor
return Gdk.Window.new(parent, attributes, attributes_mask)
+
def __init__(self, parent, attributes, attributes_mask):
pass
+
def cairo_create(self):
return Gdk.cairo_create(self)
@@ -117,6 +120,7 @@ else:
Gdk.EventType._2BUTTON_PRESS = getattr(Gdk.EventType, "2BUTTON_PRESS")
Gdk.EventType._3BUTTON_PRESS = getattr(Gdk.EventType, "3BUTTON_PRESS")
+
class Event(Gdk.Event):
_UNION_MEMBERS = {
Gdk.EventType.DELETE: 'any',
@@ -202,6 +206,7 @@ gsuccess_mask_funcs = ['get_state',
'get_coords',
'get_root_coords']
+
def _gsuccess_mask(func):
def cull_success(*args):
result = func(*args)
@@ -235,6 +240,7 @@ for event_class in event_member_classes:
# end GdkEvent overrides
+
class DragContext(Gdk.DragContext):
def finish(self, success, del_, time):
Gtk = modules['Gtk']._introspection_module
@@ -243,6 +249,7 @@ class DragContext(Gdk.DragContext):
DragContext = override(DragContext)
__all__.append('DragContext')
+
class Cursor(Gdk.Cursor):
def __new__(cls, *args, **kwds):
arg_len = len(args)
@@ -285,6 +292,8 @@ Cursor = override(Cursor)
__all__.append('Cursor')
_Gdk_color_parse = Gdk.color_parse
+
+
@override(Gdk.color_parse)
def color_parse(color):
success, color = _Gdk_color_parse(color)
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py
index 3b556da..3e12cc7 100644
--- a/gi/overrides/Gio.py
+++ b/gi/overrides/Gio.py
@@ -29,6 +29,7 @@ Gio = modules['Gio']._introspection_module
__all__ = []
+
class FileEnumerator(Gio.FileEnumerator):
def __iter__(self):
return self
@@ -48,6 +49,7 @@ class FileEnumerator(Gio.FileEnumerator):
FileEnumerator = override(FileEnumerator)
__all__.append('FileEnumerator')
+
class Settings(Gio.Settings):
'''Provide dictionary-like access to GLib.Settings.'''
@@ -100,6 +102,7 @@ class Settings(Gio.Settings):
Settings = override(Settings)
__all__.append('Settings')
+
class _DBusProxyMethodCall:
'''Helper class to implement DBusProxy method calls.'''
@@ -163,6 +166,7 @@ class _DBusProxyMethodCall:
return result
+
class DBusProxy(Gio.DBusProxy):
'''Provide comfortable and pythonic method calls.
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index b21567d..1323e4d 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -60,6 +60,7 @@ class Widget(Gtk.Widget):
Widget = override(Widget)
__all__.append('Widget')
+
class Container(Gtk.Container, Widget):
def __len__(self):
@@ -85,6 +86,7 @@ class Container(Gtk.Container, Widget):
Container = override(Container)
__all__.append('Container')
+
class Editable(Gtk.Editable):
def insert_text(self, text, position):
@@ -102,6 +104,7 @@ class Editable(Gtk.Editable):
Editable = override(Editable)
__all__.append("Editable")
+
class Action(Gtk.Action):
def __init__(self, name, label, tooltip, stock_id, **kwds):
Gtk.Action.__init__(self, name=name, label=label, tooltip=tooltip, stock_id=stock_id, **kwds)
@@ -109,6 +112,7 @@ class Action(Gtk.Action):
Action = override(Action)
__all__.append("Action")
+
class RadioAction(Gtk.RadioAction):
def __init__(self, name, label, tooltip, stock_id, value, **kwds):
Gtk.RadioAction.__init__(self, name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=value, **kwds)
@@ -116,6 +120,7 @@ class RadioAction(Gtk.RadioAction):
RadioAction = override(RadioAction)
__all__.append("RadioAction")
+
class ActionGroup(Gtk.ActionGroup):
def __init__(self, name, **kwds):
super(ActionGroup, self).__init__(name=name, **kwds)
@@ -214,7 +219,6 @@ class ActionGroup(Gtk.ActionGroup):
# using inner function above since entries can leave out optional arguments
_process_action(*e)
-
def add_radio_actions(self, entries, value=None, on_change=None, user_data=None):
"""
The add_radio_actions() method is a convenience method that creates a
@@ -282,6 +286,7 @@ class ActionGroup(Gtk.ActionGroup):
ActionGroup = override(ActionGroup)
__all__.append('ActionGroup')
+
class UIManager(Gtk.UIManager):
def add_ui_from_string(self, buffer):
if not isinstance(buffer, _basestring):
@@ -297,6 +302,7 @@ class UIManager(Gtk.UIManager):
UIManager = override(UIManager)
__all__.append('UIManager')
+
class ComboBox(Gtk.ComboBox, Container):
def get_active_iter(self):
@@ -317,6 +323,7 @@ class Box(Gtk.Box):
Box = override(Box)
__all__.append('Box')
+
class SizeGroup(Gtk.SizeGroup):
def __init__(self, mode=Gtk.SizeGroupMode.VERTICAL):
super(SizeGroup, self).__init__(mode=mode)
@@ -385,6 +392,8 @@ __all__.append('Builder')
# NOTE: This must come before any other Window/Dialog subclassing, to ensure
# that we have a correct inheritance hierarchy.
+
+
class Window(Gtk.Window):
def __init__(self, type=Gtk.WindowType.TOPLEVEL, **kwargs):
Gtk.Window.__init__(self, type=type, **kwargs)
@@ -458,6 +467,7 @@ class Dialog(Gtk.Dialog, Container):
Dialog = override(Dialog)
__all__.append('Dialog')
+
class MessageDialog(Gtk.MessageDialog, Dialog):
def __init__(self,
parent=None,
@@ -494,6 +504,7 @@ class MessageDialog(Gtk.MessageDialog, Dialog):
MessageDialog = override(MessageDialog)
__all__.append('MessageDialog')
+
class AboutDialog(Gtk.AboutDialog):
def __init__(self, **kwds):
Gtk.AboutDialog.__init__(self, **kwds)
@@ -501,6 +512,7 @@ class AboutDialog(Gtk.AboutDialog):
AboutDialog = override(AboutDialog)
__all__.append('AboutDialog')
+
class ColorSelectionDialog(Gtk.ColorSelectionDialog):
def __init__(self, title=None, **kwds):
Gtk.ColorSelectionDialog.__init__(self, title=title, **kwds)
@@ -508,6 +520,7 @@ class ColorSelectionDialog(Gtk.ColorSelectionDialog):
ColorSelectionDialog = override(ColorSelectionDialog)
__all__.append('ColorSelectionDialog')
+
class FileChooserDialog(Gtk.FileChooserDialog):
def __init__(self,
title=None,
@@ -524,6 +537,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
FileChooserDialog = override(FileChooserDialog)
__all__.append('FileChooserDialog')
+
class FontSelectionDialog(Gtk.FontSelectionDialog):
def __init__(self, title=None, **kwds):
Gtk.FontSelectionDialog.__init__(self, title=title, **kwds)
@@ -531,6 +545,7 @@ class FontSelectionDialog(Gtk.FontSelectionDialog):
FontSelectionDialog = override(FontSelectionDialog)
__all__.append('FontSelectionDialog')
+
class RecentChooserDialog(Gtk.RecentChooserDialog):
def __init__(self,
title=None,
@@ -549,6 +564,7 @@ class RecentChooserDialog(Gtk.RecentChooserDialog):
RecentChooserDialog = override(RecentChooserDialog)
__all__.append('RecentChooserDialog')
+
class IconView(Gtk.IconView):
def __init__(self, model=None):
@@ -592,6 +608,7 @@ class IMContext(Gtk.IMContext):
IMContext = override(IMContext)
__all__.append('IMContext')
+
class RecentInfo(Gtk.RecentInfo):
def get_application_info(self, app_name):
@@ -602,6 +619,7 @@ class RecentInfo(Gtk.RecentInfo):
RecentInfo = override(RecentInfo)
__all__.append('RecentInfo')
+
class TextBuffer(Gtk.TextBuffer):
def _get_or_create_tag_table(self):
table = self.get_tag_table()
@@ -643,7 +661,7 @@ class TextBuffer(Gtk.TextBuffer):
Gtk.TextBuffer.set_text(self, text, length)
def insert(self, iter, text, length=-1):
- if not isinstance(text , _basestring):
+ if not isinstance(text, _basestring):
raise TypeError('text must be a string, not %s' % type(text))
Gtk.TextBuffer.insert(self, iter, text, length)
@@ -675,7 +693,7 @@ class TextBuffer(Gtk.TextBuffer):
self.insert_with_tags(iter, text, *tag_objs)
def insert_at_cursor(self, text, length=-1):
- if not isinstance(text , _basestring):
+ if not isinstance(text, _basestring):
raise TypeError('text must be a string, not %s' % type(text))
Gtk.TextBuffer.insert_at_cursor(self, text, length)
@@ -690,6 +708,7 @@ class TextBuffer(Gtk.TextBuffer):
TextBuffer = override(TextBuffer)
__all__.append('TextBuffer')
+
class TextIter(Gtk.TextIter):
def forward_search(self, string, flags, limit):
@@ -720,6 +739,7 @@ class TextIter(Gtk.TextIter):
TextIter = override(TextIter)
__all__.append('TextIter')
+
class TreeModel(Gtk.TreeModel):
def __len__(self):
return self.iter_n_children(None)
@@ -927,6 +947,7 @@ class TreeModel(Gtk.TreeModel):
TreeModel = override(TreeModel)
__all__.append('TreeModel')
+
class TreeSortable(Gtk.TreeSortable, ):
def get_sort_column_id(self):
@@ -945,6 +966,7 @@ class TreeSortable(Gtk.TreeSortable, ):
TreeSortable = override(TreeSortable)
__all__.append('TreeSortable')
+
class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
def __init__(self, *column_types):
Gtk.ListStore.__init__(self)
@@ -975,6 +997,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
# FIXME: sends two signals; check if this can use an atomic
# insert_with_valuesv()
+
def insert_before(self, sibling, row=None):
treeiter = Gtk.ListStore.insert_before(self, sibling)
@@ -985,6 +1008,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
# FIXME: sends two signals; check if this can use an atomic
# insert_with_valuesv()
+
def insert_after(self, sibling, row=None):
treeiter = Gtk.ListStore.insert_after(self, sibling)
@@ -1026,6 +1050,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
ListStore = override(ListStore)
__all__.append('ListStore')
+
class TreeModelRow(object):
def __init__(self, model, iter_or_path):
@@ -1093,7 +1118,7 @@ class TreeModelRow(object):
"attempt to assign sequence of size %d to slice of size %d"
% (len(value), len(indexList)))
- for i,v in enumerate(indexList):
+ for i, v in enumerate(indexList):
self.model.set_value(self.iter, v, value[i])
else:
raise TypeError("index must be an integer or slice, not %s" % type(key).__name__)
@@ -1110,6 +1135,7 @@ class TreeModelRow(object):
__all__.append('TreeModelRow')
+
class TreeModelRowIter(object):
def __init__(self, model, aiter):
@@ -1131,6 +1157,7 @@ class TreeModelRowIter(object):
__all__.append('TreeModelRowIter')
+
class TreePath(Gtk.TreePath):
def __new__(cls, path=0):
@@ -1173,6 +1200,7 @@ class TreePath(Gtk.TreePath):
TreePath = override(TreePath)
__all__.append('TreePath')
+
class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
def __init__(self, *column_types):
@@ -1199,6 +1227,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
# FIXME: sends two signals; check if this can use an atomic
# insert_with_valuesv()
+
def insert_before(self, parent, sibling, row=None):
treeiter = Gtk.TreeStore.insert_before(self, parent, sibling)
@@ -1209,6 +1238,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
# FIXME: sends two signals; check if this can use an atomic
# insert_with_valuesv()
+
def insert_after(self, parent, sibling, row=None):
treeiter = Gtk.TreeStore.insert_after(self, parent, sibling)
@@ -1250,6 +1280,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
TreeStore = override(TreeStore)
__all__.append('TreeStore')
+
class TreeView(Gtk.TreeView, Container):
def __init__(self, model=None):
@@ -1310,6 +1341,7 @@ class TreeView(Gtk.TreeView, Container):
TreeView = override(TreeView)
__all__.append('TreeView')
+
class TreeViewColumn(Gtk.TreeViewColumn):
def __init__(self, title='',
cell_renderer=None,
@@ -1332,6 +1364,7 @@ class TreeViewColumn(Gtk.TreeViewColumn):
TreeViewColumn = override(TreeViewColumn)
__all__.append('TreeViewColumn')
+
class TreeSelection(Gtk.TreeSelection):
def select_path(self, path):
@@ -1347,6 +1380,7 @@ class TreeSelection(Gtk.TreeSelection):
return (model, None)
# for compatibility with PyGtk
+
def get_selected_rows(self):
rows, model = super(TreeSelection, self).get_selected_rows()
return (model, rows)
@@ -1355,6 +1389,7 @@ class TreeSelection(Gtk.TreeSelection):
TreeSelection = override(TreeSelection)
__all__.append('TreeSelection')
+
class Button(Gtk.Button, Container):
def __init__(self, label=None, stock=None, use_stock=False, use_underline=False, **kwds):
if stock:
@@ -1366,6 +1401,7 @@ class Button(Gtk.Button, Container):
Button = override(Button)
__all__.append('Button')
+
class LinkButton(Gtk.LinkButton):
def __init__(self, uri, label=None, **kwds):
Gtk.LinkButton.__init__(self, uri=uri, label=label, **kwds)
@@ -1373,6 +1409,7 @@ class LinkButton(Gtk.LinkButton):
LinkButton = override(LinkButton)
__all__.append('LinkButton')
+
class Label(Gtk.Label):
def __init__(self, label=None, **kwds):
Gtk.Label.__init__(self, label=label, **kwds)
@@ -1380,6 +1417,7 @@ class Label(Gtk.Label):
Label = override(Label)
__all__.append('Label')
+
class Adjustment(Gtk.Adjustment):
def __init__(self, *args, **kwds):
arg_names = ('value', 'lower', 'upper',
@@ -1403,6 +1441,7 @@ class Adjustment(Gtk.Adjustment):
Adjustment = override(Adjustment)
__all__.append('Adjustment')
+
class Table(Gtk.Table, Container):
def __init__(self, rows=1, columns=1, homogeneous=False, **kwds):
if 'n_rows' in kwds:
@@ -1413,12 +1452,13 @@ class Table(Gtk.Table, Container):
Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous, **kwds)
- def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
+ def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
Gtk.Table.attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
Table = override(Table)
__all__.append('Table')
+
class ScrolledWindow(Gtk.ScrolledWindow):
def __init__(self, hadjustment=None, vadjustment=None, **kwds):
Gtk.ScrolledWindow.__init__(self, hadjustment=hadjustment, vadjustment=vadjustment, **kwds)
@@ -1434,6 +1474,7 @@ class HScrollbar(Gtk.HScrollbar):
HScrollbar = override(HScrollbar)
__all__.append('HScrollbar')
+
class VScrollbar(Gtk.VScrollbar):
def __init__(self, adjustment=None):
Gtk.VScrollbar.__init__(self, adjustment=adjustment)
@@ -1441,6 +1482,7 @@ class VScrollbar(Gtk.VScrollbar):
VScrollbar = override(VScrollbar)
__all__.append('VScrollbar')
+
class Paned(Gtk.Paned):
def pack1(self, child, resize=False, shrink=True):
super(Paned, self).pack1(child, resize, shrink)
@@ -1497,11 +1539,15 @@ if Gtk._version != '2.0':
__all__.append('Menu')
_Gtk_main_quit = Gtk.main_quit
+
+
@override(Gtk.main_quit)
def main_quit(*args):
_Gtk_main_quit()
_Gtk_stock_lookup = Gtk.stock_lookup
+
+
@override(Gtk.stock_lookup)
def stock_lookup(*args):
success, item = _Gtk_stock_lookup(*args)
diff --git a/gi/overrides/Pango.py b/gi/overrides/Pango.py
index 7030a76..bbaa734 100644
--- a/gi/overrides/Pango.py
+++ b/gi/overrides/Pango.py
@@ -25,6 +25,7 @@ Pango = modules['Pango']._introspection_module
__all__ = []
+
class Context(Pango.Context):
def get_metrics(self, desc, language=None):
@@ -45,6 +46,7 @@ class FontDescription(Pango.FontDescription):
FontDescription = override(FontDescription)
__all__.append('FontDescription')
+
class Layout(Pango.Layout):
def __new__(cls, context):
diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py
index def9d04..8ca0cb2 100644
--- a/gi/overrides/__init__.py
+++ b/gi/overrides/__init__.py
@@ -3,6 +3,8 @@ import types
from gi import _gobject
registry = None
+
+
class _Registry(dict):
def __setitem__(self, key, value):
'''We do checks here to make sure only submodules of the override
@@ -29,7 +31,7 @@ class _Registry(dict):
g_type.pytype = value
# strip gi.overrides from module name
- module = value.__module__[13:]
+ module = value.__module__[13:]
key = "%s.%s" % (module, value.__name__)
super(_Registry, self).__setitem__(key, value)
@@ -54,6 +56,7 @@ class overridefunc(object):
registry = _Registry()
+
def override(type_):
'''Decorator for registering an override'''
if type(type_) == types.FunctionType:
diff --git a/gi/pygtkcompat.py b/gi/pygtkcompat.py
index eca493c..f6338e4 100644
--- a/gi/pygtkcompat.py
+++ b/gi/pygtkcompat.py
@@ -99,7 +99,7 @@ _unset = object()
def enable_gtk(version='2.0'):
# set the default encoding like PyGTK
reload(sys)
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
sys.setdefaultencoding('utf-8')
# atk
@@ -150,6 +150,7 @@ def enable_gtk(version='2.0'):
Gdk.Window.get_frame_extents = get_frame_extents
orig_get_origin = Gdk.Window.get_origin
+
def get_origin(self):
return orig_get_origin(self)[1:]
Gdk.Window.get_origin = get_origin
@@ -205,11 +206,13 @@ def enable_gtk(version='2.0'):
# TreeViewColumn
orig_tree_view_column_pack_end = Gtk.TreeViewColumn.pack_end
+
def tree_view_column_pack_end(self, cell, expand=True):
orig_tree_view_column_pack_end(self, cell, expand)
Gtk.TreeViewColumn.pack_end = tree_view_column_pack_end
orig_tree_view_column_pack_start = Gtk.TreeViewColumn.pack_start
+
def tree_view_column_pack_start(self, cell, expand=True):
orig_tree_view_column_pack_start(self, cell, expand)
Gtk.TreeViewColumn.pack_start = tree_view_column_pack_start
@@ -267,8 +270,10 @@ def enable_gtk(version='2.0'):
class ComboBoxEntry(Gtk.ComboBox):
def __init__(self, **kwds):
Gtk.ComboBox.__init__(self, has_entry=True, **kwds)
+
def set_text_column (self, text_column):
self.set_entry_text_column(text_column)
+
def get_text_column (self):
return self.get_entry_text_column()
Gtk.ComboBoxEntry = ComboBoxEntry
@@ -295,6 +300,7 @@ def enable_gtk(version='2.0'):
combo.set_entry_text_column(0)
return combo
Gtk.combo_box_new_text = new_text
+
def append_text(self, text):
model = self.get_model()
model.append([text])
@@ -327,6 +333,7 @@ def enable_gtk(version='2.0'):
Gtk.widget_get_default_direction = Gtk.Widget.get_default_direction
orig_size_request = Gtk.Widget.size_request
+
def size_request(widget):
class SizeRequest(UserList):
def __init__(self, req):
@@ -360,12 +367,14 @@ def enable_gtk(version='2.0'):
Gtk.Widget.style = StyleDescriptor()
# gtk.unixprint
+
class UnixPrint(object):
pass
unixprint = UnixPrint()
sys.modules['gtkunixprint'] = unixprint
# gtk.keysyms
+
class Keysyms(object):
pass
keysyms = Keysyms()
@@ -405,6 +414,7 @@ def enable_gudev():
from gi.repository import GUdev
sys.modules['gudev'] = GUdev
+
def enable_gst():
gi.require_version('Gst', '0.10')
from gi.repository import Gst
@@ -414,8 +424,8 @@ def enable_gst():
Gst.element_register = Gst.Element.register
Gst.element_factory_make = Gst.ElementFactory.make
Gst.caps_new_any = Gst.Caps.new_any
- Gst.get_pygst_version = lambda : (0, 10, 19)
- Gst.get_gst_version = lambda : (0, 10, 40)
+ Gst.get_pygst_version = lambda: (0, 10, 19)
+ Gst.get_gst_version = lambda: (0, 10, 40)
from gi.repository import GstInterfaces
sys.modules['gst.interfaces'] = GstInterfaces
diff --git a/gi/types.py b/gi/types.py
index 2cd5ab4..c60b2b2 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -40,6 +40,7 @@ if sys.version_info > (3, 0):
def callable(obj):
return hasattr(obj, '__call__')
+
def Function(info):
def function(*args, **kwargs):
@@ -172,6 +173,7 @@ class MetaClassHelper(object):
value = NativeVFunc(vfunc_info)
setattr(cls, name, value)
+
def find_vfunc_info_in_interface(bases, vfunc_name):
for base in bases:
# All wrapped interfaces inherit from GInterface.
@@ -193,6 +195,7 @@ def find_vfunc_info_in_interface(bases, vfunc_name):
return None
+
def find_vfunc_conflict_in_bases(vfunc, bases):
for klass in bases:
if not hasattr(klass, '__info__') or \
@@ -209,6 +212,7 @@ def find_vfunc_conflict_in_bases(vfunc, bases):
return aklass
return None
+
class GObjectMeta(_gobject.GObjectMeta, MetaClassHelper):
def __init__(cls, name, bases, dict_):
diff --git a/tests/test_everything.py b/tests/test_everything.py
index d788a27..33227a9 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -67,7 +67,6 @@ class TestEverything(unittest.TestCase):
self.assertRaises(TypeError, Everything.test_unichar, "")
self.assertRaises(TypeError, Everything.test_unichar, "morethanonechar")
-
def test_floating(self):
e = Everything.TestFloating()
self.assertEquals(e.__grefcount__, 1)
@@ -180,16 +179,17 @@ class TestEverything(unittest.TestCase):
l2 = l1
self.assertEqual(l1.data, l2.data)
- self.assertEquals(getrefcount(l1), init_refcount+1)
+ self.assertEquals(getrefcount(l1), init_refcount + 1)
l3 = copy.copy(l1)
l3.data = 'bar'
self.assertEqual(l1.data, 'foo')
self.assertEqual(l2.data, 'foo')
self.assertEqual(l3.data, 'bar')
- self.assertEquals(getrefcount(l1), init_refcount+1)
+ self.assertEquals(getrefcount(l1), init_refcount + 1)
self.assertEquals(getrefcount(l3), init_refcount)
+
class TestNullableArgs(unittest.TestCase):
def test_in_nullable_hash(self):
Everything.test_ghash_null_in(None)
@@ -233,6 +233,7 @@ class TestCallbacks(unittest.TestCase):
def test_callback(self):
TestCallbacks.called = False
+
def callback():
TestCallbacks.called = True
@@ -274,6 +275,7 @@ class TestCallbacks(unittest.TestCase):
def test_return_value_callback(self):
TestCallbacks.called = False
+
def callback():
TestCallbacks.called = True
return 44
@@ -283,6 +285,7 @@ class TestCallbacks(unittest.TestCase):
def test_callback_async(self):
TestCallbacks.called = False
+
def callback(foo):
TestCallbacks.called = True
return foo
@@ -294,6 +297,7 @@ class TestCallbacks(unittest.TestCase):
def test_callback_scope_call(self):
TestCallbacks.called = 0
+
def callback():
TestCallbacks.called += 1
return 0
@@ -303,6 +307,7 @@ class TestCallbacks(unittest.TestCase):
def test_callback_userdata(self):
TestCallbacks.called = 0
+
def callback(userdata):
self.assertEquals(userdata, "Test%d" % TestCallbacks.called)
TestCallbacks.called += 1
@@ -310,12 +315,13 @@ class TestCallbacks(unittest.TestCase):
for i in range(100):
val = Everything.test_callback_user_data(callback, "Test%d" % i)
- self.assertEquals(val, i+1)
+ self.assertEquals(val, i + 1)
self.assertEquals(TestCallbacks.called, 100)
def test_callback_userdata_refcount(self):
TestCallbacks.called = False
+
def callback(userdata):
TestCallbacks.called = True
return 1
@@ -419,17 +425,18 @@ class TestCallbacks(unittest.TestCase):
mydict['new'] = 42
TestCallbacks.called = True
- mydict = { 'foo': 1, 'bar': 2 }
+ mydict = {'foo': 1, 'bar': 2}
TestCallbacks.called = False
Everything.test_hash_table_callback(mydict, callback)
self.assertTrue(TestCallbacks.called)
- self.assertEqual(mydict, { 'foo': 1, 'bar': 2, 'new': 42 })
+ self.assertEqual(mydict, {'foo': 1, 'bar': 2, 'new': 42})
+
class TestClosures(unittest.TestCase):
def test_int_arg(self):
def callback(num):
self.called = True
- return num+1
+ return num + 1
self.called = False
result = Everything.test_closure_one_arg(callback, 42)
@@ -437,6 +444,7 @@ class TestClosures(unittest.TestCase):
self.assertEqual(result, 43)
# https://bugzilla.gnome.org/show_bug.cgi?id=656554
+
@unittest.expectedFailure
def test_variant(self):
def callback(variant):
@@ -450,6 +458,7 @@ class TestClosures(unittest.TestCase):
self.assertEqual(result.get_type_string(), 'i')
self.assertEqual(result.get_int32(), 43)
+
class TestProperties(unittest.TestCase):
def test_basic(self):
@@ -502,6 +511,7 @@ class TestProperties(unittest.TestCase):
self.assertTrue(isinstance(object_.props.boxed, Everything.TestBoxed))
self.assertEquals(object_.props.boxed.some_int8, 42)
+
class TestTortureProfile(unittest.TestCase):
def test_torture_profile(self):
import time
@@ -534,7 +544,6 @@ class TestTortureProfile(unittest.TestCase):
total_time += delta_time
print("%f secs" % delta_time)
-
sys.stdout.write("\ttorture test 3 (10000 iterations): ")
start_time = time.clock()
for i in range(10000):
@@ -550,10 +559,11 @@ class TestTortureProfile(unittest.TestCase):
print("%f secs" % delta_time)
sys.stdout.write("\ttorture test 4 (10000 iterations): ")
+
def callback(userdata):
pass
- userdata = [1,2,3,4]
+ userdata = [1, 2, 3, 4]
start_time = time.clock()
for i in range(10000):
(y,z,q) = Everything.test_torture_signature_2(5000,
@@ -568,6 +578,7 @@ class TestTortureProfile(unittest.TestCase):
print("\t====")
print("\tTotal: %f sec" % total_time)
+
class TestAdvancedInterfaces(unittest.TestCase):
def test_array_objs(self):
obj1, obj2 = Everything.test_array_fixed_out_objects()
@@ -591,6 +602,7 @@ class TestAdvancedInterfaces(unittest.TestCase):
ret = obj.skip_return_val_no_out(1)
self.assertEquals(ret, None)
+
class TestSignals(unittest.TestCase):
def test_object_param_signal(self):
obj = Everything.TestObj()
diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py
index af7d399..edc42a4 100644
--- a/tests/test_gdbus.py
+++ b/tests/test_gdbus.py
@@ -10,6 +10,7 @@ from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
+
class TestGDBusClient(unittest.TestCase):
def setUp(self):
self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
diff --git a/tests/test_gi.py b/tests/test_gi.py
index eb498ff..1a96ce3 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -19,10 +19,10 @@ from compathelper import _bytes
if sys.version_info < (3, 0):
CONSTANT_UTF8 = "const \xe2\x99\xa5 utf8"
PY2_UNICODE_UTF8 = unicode(CONSTANT_UTF8, 'UTF-8')
- CHAR_255='\xff'
+ CHAR_255 = '\xff'
else:
CONSTANT_UTF8 = "const â utf8"
- CHAR_255=bytes([255])
+ CHAR_255 = bytes([255])
CONSTANT_NUMBER = 42
@@ -843,10 +843,10 @@ class TestGArray(unittest.TestCase):
self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.garray_utf8_none_inout(Sequence(('0', '1', '2'))))
def test_garray_utf8_container_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.garray_utf8_container_inout(['0', '1', '2']))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.garray_utf8_container_inout(['0', '1', '2']))
def test_garray_utf8_full_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.garray_utf8_full_inout(['0', '1', '2']))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.garray_utf8_full_inout(['0', '1', '2']))
class TestGPtrArray(unittest.TestCase):
@@ -876,10 +876,10 @@ class TestGPtrArray(unittest.TestCase):
self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gptrarray_utf8_none_inout(Sequence(('0', '1', '2'))))
def test_gptrarray_utf8_container_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.gptrarray_utf8_container_inout(['0', '1', '2']))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gptrarray_utf8_container_inout(['0', '1', '2']))
def test_gptrarray_utf8_full_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.gptrarray_utf8_full_inout(['0', '1', '2']))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gptrarray_utf8_full_inout(['0', '1', '2']))
class TestGList(unittest.TestCase):
@@ -920,10 +920,10 @@ class TestGList(unittest.TestCase):
self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.glist_utf8_none_inout(Sequence(('0', '1', '2'))))
def test_glist_utf8_container_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.glist_utf8_container_inout(('0', '1', '2')))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.glist_utf8_container_inout(('0', '1', '2')))
def test_glist_utf8_full_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.glist_utf8_full_inout(('0', '1', '2')))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.glist_utf8_full_inout(('0', '1', '2')))
class TestGSList(unittest.TestCase):
@@ -964,10 +964,10 @@ class TestGSList(unittest.TestCase):
self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gslist_utf8_none_inout(Sequence(('0', '1', '2'))))
def test_gslist_utf8_container_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.gslist_utf8_container_inout(('0', '1', '2')))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gslist_utf8_container_inout(('0', '1', '2')))
def test_gslist_utf8_full_inout(self):
- self.assertEquals(['-2', '-1','0', '1'], GIMarshallingTests.gslist_utf8_full_inout(('0', '1', '2')))
+ self.assertEquals(['-2', '-1', '0', '1'], GIMarshallingTests.gslist_utf8_full_inout(('0', '1', '2')))
class TestGHashTable(unittest.TestCase):
@@ -1699,6 +1699,7 @@ class TestMultiOutputArgs(unittest.TestCase):
def test_int_return_out(self):
self.assertEquals((6, 7), GIMarshallingTests.int_return_out())
+
class TestGErrorException(unittest.TestCase):
def test_gerror_exception(self):
self.assertRaises(GObject.GError, GIMarshallingTests.gerror)
@@ -1713,6 +1714,7 @@ class TestGErrorException(unittest.TestCase):
# Interface
+
class TestInterfaces(unittest.TestCase):
class TestInterfaceImpl(GObject.GObject, GIMarshallingTests.Interface):
@@ -1902,10 +1904,10 @@ class TestKeywordArgs(unittest.TestCase):
kw_func = GIMarshallingTests.int_three_in_three_out
self.assertEquals(kw_func(1, 2, 3), (1, 2, 3))
- self.assertEquals(kw_func(**{'a':4, 'b':5, 'c':6}), (4, 5, 6))
- self.assertEquals(kw_func(1, **{'b':7, 'c':8}), (1, 7, 8))
- self.assertEquals(kw_func(1, 7, **{'c':8}), (1, 7, 8))
- self.assertEquals(kw_func(1, c=8, **{'b':7}), (1, 7, 8))
+ self.assertEquals(kw_func(**{'a': 4, 'b': 5, 'c': 6}), (4, 5, 6))
+ self.assertEquals(kw_func(1, **{'b': 7, 'c': 8}), (1, 7, 8))
+ self.assertEquals(kw_func(1, 7, **{'c': 8}), (1, 7, 8))
+ self.assertEquals(kw_func(1, c=8, **{'b': 7}), (1, 7, 8))
self.assertEquals(kw_func(2, c=4, b=3), (2, 3, 4))
self.assertEquals(kw_func(a=2, c=4, b=3), (2, 3, 4))
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index 4bb7c53..95227bb 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -123,7 +123,6 @@ class TestReferenceCounting(unittest.TestCase):
obj.release()
self.assertEquals(obj.__grefcount__, 1)
-
def testFloatingAndSunkUsingGObjectNew(self):
# Upon creation, the refcount of the object should be 2:
# - someone already has a reference on the new object.
@@ -155,10 +154,12 @@ class TestReferenceCounting(unittest.TestCase):
obj.release()
self.assertEquals(obj.__grefcount__, 1)
+
class A(GObject.GObject):
def __init__(self):
super(A, self).__init__()
+
class TestPythonReferenceCounting(unittest.TestCase):
# Newly created instances should alwayshave two references: one for
# the GC, and one for the bound variable in the local scope.
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py
index 937ecaf..fa6192e 100644
--- a/tests/test_mainloop.py
+++ b/tests/test_mainloop.py
@@ -9,6 +9,7 @@ from gi.repository import GLib
from compathelper import _bytes
+
class TestMainLoop(unittest.TestCase):
def testExceptionHandling(self):
pipe_r, pipe_w = os.pipe()
diff --git a/tests/test_option.py b/tests/test_option.py
index 07d2e78..862d4ed 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -14,6 +14,7 @@ except ImportError:
from gi._glib.option import OptionParser, OptionGroup, OptionValueError, \
make_option, BadOptionError
+
class TestOption(unittest.TestCase):
EXCEPTION_MESSAGE = "This callback fails"
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 0446a2c..08c275a 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -18,6 +18,7 @@ from gi.repository import GdkPixbuf
import gi.overrides as overrides
import gi.types
+
class TestGLib(unittest.TestCase):
def test_gvariant_create(self):
@@ -353,7 +354,7 @@ class TestGLib(unittest.TestCase):
self.assertTrue(v2 in set([v1, v3]))
self.assertTrue(v2 in frozenset([v1, v3]))
- self.assertTrue(v2 in {v1: '1', v3:'2' })
+ self.assertTrue(v2 in {v1: '1', v3: '2' })
def test_variant_compare(self):
# Check if identical GVariant are equal
@@ -416,8 +417,8 @@ class TestGLib(unittest.TestCase):
assert_equals_bool('ab', [True])
assert_equals_bool('ab', [False])
for number in numbers:
- assert_equals_bool('a'+number, [])
- assert_equals_bool('a'+number, [0])
+ assert_equals_bool('a' + number, [])
+ assert_equals_bool('a' + number, [0])
assert_equals_bool('as', [])
assert_equals_bool('as', [''])
assert_equals_bool('ao', [])
@@ -429,7 +430,7 @@ class TestGLib(unittest.TestCase):
# tuples
assert_equals_bool('()', ())
for number in numbers:
- assert_equals_bool('('+number+')', (0,))
+ assert_equals_bool('(' + number + ')', (0,))
assert_equals_bool('(s)', ('',))
assert_equals_bool('(o)', ('/',))
assert_equals_bool('(g)', ('',))
@@ -447,6 +448,7 @@ class TestGLib(unittest.TestCase):
assert_equals_bool('v', GLib.Variant('i', 0))
assert_equals_bool('v', GLib.Variant('i', 1))
+
class TestPango(unittest.TestCase):
def test_default_font_description(self):
@@ -557,6 +559,7 @@ class TestGdk(unittest.TestCase):
self.assertNotEqual(c, None)
self.assertRaises(ValueError, Gdk.Cursor, 1, 2, 3)
+
class TestGtk(unittest.TestCase):
def test_container(self):
@@ -668,7 +671,6 @@ class TestGtk(unittest.TestCase):
[]),
}
-
class SignalCheck:
def __init__(self):
self.sentinel = 0
@@ -853,8 +855,8 @@ class TestGtk(unittest.TestCase):
pass
test_pyobj = TestPyObject()
- test_pydict = {1:1, "2":2, "3":"3"}
- test_pylist = [1,"2", "3"]
+ test_pydict = {1: 1, "2": 2, "3": "3"}
+ test_pylist = [1, "2", "3"]
tree_store = Gtk.TreeStore(int,
'gchararray',
TestGtk.TestClass,
@@ -1044,8 +1046,8 @@ class TestGtk(unittest.TestCase):
pass
test_pyobj = TestPyObject()
- test_pydict = {1:1, "2":2, "3":"3"}
- test_pylist = [1,"2", "3"]
+ test_pydict = {1: 1, "2": 2, "3": "3"}
+ test_pylist = [1, "2", "3"]
list_store = Gtk.ListStore(int, str, 'GIOverrideTreeAPITest', object, object, object, bool, bool)
for i in range(1, 93):
@@ -1148,7 +1150,6 @@ class TestGtk(unittest.TestCase):
0,
False))
-
i = 95
label = 'this is row #95'
list_store.insert(95, (i,
@@ -1278,7 +1279,7 @@ class TestGtk(unittest.TestCase):
p2 = Gtk.TreePath.new_from_string('1:2:3')
self.assertEqual(p1, p2)
self.assertEqual(str(p1), '1:2:3')
- p1 = Gtk.TreePath((1,2,3))
+ p1 = Gtk.TreePath((1, 2, 3))
p2 = Gtk.TreePath.new_from_string('1:2:3')
self.assertEqual(p1, p2)
self.assertEqual(str(p1), '1:2:3')
@@ -1339,7 +1340,7 @@ class TestGtk(unittest.TestCase):
self.assertTrue(tree_store)
self.assertEqual(len(tree_store), 100)
- for i,row in enumerate(tree_store):
+ for i, row in enumerate(tree_store):
self.assertEqual(row.model, tree_store)
self.assertEqual(row.parent, None)
@@ -1370,7 +1371,7 @@ class TestGtk(unittest.TestCase):
self.assertEqual(tree_store.iter_n_children(row.iter), 20)
child = tree_store.iter_children(row.iter)
- for j,childrow in enumerate(row.iterchildren()):
+ for j, childrow in enumerate(row.iterchildren()):
child_path = tree_store.get_path(child)
self.assertEqual(childrow.path, child_path)
self.assertEqual(childrow.parent.path, row.path)
@@ -1408,7 +1409,7 @@ class TestGtk(unittest.TestCase):
self.assertEqual(i, 99)
# negative indices
- for i in range(-1,-100,-1):
+ for i in range(-1, -100, -1):
i_real = i + 100
self.assertEqual(tree_store[i][0], i_real)
@@ -1433,7 +1434,7 @@ class TestGtk(unittest.TestCase):
last_row = tree_store[99]
self.assertNotEqual(last_row, None)
- for i,childrow in enumerate(last_row.iterchildren()):
+ for i, childrow in enumerate(last_row.iterchildren()):
if i < 19:
self.assertTrue(tree_store.remove(childrow.iter))
else:
@@ -1557,7 +1558,7 @@ class TestGtk(unittest.TestCase):
self.assertEqual(m, store)
self.assertEqual(store.get_path(s), firstpath)
- sel.select_path((0,0))
+ sel.select_path((0, 0))
(m, s) = sel.get_selected()
self.assertEqual(m, store)
self.assertEqual(store.get_path(s), firstpath)
@@ -1694,7 +1695,7 @@ class TestGtk(unittest.TestCase):
self.assertEquals(Gtk.Editable, overrides.Gtk.Editable)
# need to use Gtk.Entry because Editable is an interface
- entry=Gtk.Entry()
+ entry = Gtk.Entry()
pos = entry.insert_text('HeWorld', 0)
self.assertEquals(pos, 7)
pos = entry.insert_text('llo ', 2)
@@ -1717,16 +1718,16 @@ class TestGtk(unittest.TestCase):
self.assertEquals(adjustment.get_page_size(), page_size)
def test_adjustment(self):
- adjustment = Gtk.Adjustment(1, 0, 6, 4, 5, 3)
+ adjustment = Gtk.Adjustment(1, 0, 6, 4, 5, 3)
self.adjustment_check(adjustment, 1, 0, 6, 4, 5, 3)
- adjustment = Gtk.Adjustment(1, 0, 6, 4, 5)
+ adjustment = Gtk.Adjustment(1, 0, 6, 4, 5)
self.adjustment_check(adjustment, 1, 0, 6, 4, 5)
- adjustment = Gtk.Adjustment(1, 0, 6, 4)
+ adjustment = Gtk.Adjustment(1, 0, 6, 4)
self.adjustment_check(adjustment, 1, 0, 6, 4)
- adjustment = Gtk.Adjustment(1, 0, 6)
+ adjustment = Gtk.Adjustment(1, 0, 6)
self.adjustment_check(adjustment, 1, 0, 6)
adjustment = Gtk.Adjustment()
@@ -1741,21 +1742,21 @@ class TestGtk(unittest.TestCase):
self.assertTrue(isinstance(table, Gtk.Table))
self.assertTrue(isinstance(table, Gtk.Container))
self.assertTrue(isinstance(table, Gtk.Widget))
- self.assertEquals(table.get_size(), (1,1))
+ self.assertEquals(table.get_size(), (1, 1))
self.assertEquals(table.get_homogeneous(), False)
table = Gtk.Table(2, 3)
- self.assertEquals(table.get_size(), (2,3))
+ self.assertEquals(table.get_size(), (2, 3))
self.assertEquals(table.get_homogeneous(), False)
table = Gtk.Table(2, 3, True)
- self.assertEquals(table.get_size(), (2,3))
+ self.assertEquals(table.get_size(), (2, 3))
self.assertEquals(table.get_homogeneous(), True)
# Test PyGTK interface
table = Gtk.Table(rows=3, columns=2)
- self.assertEquals(table.get_size(), (3,2))
+ self.assertEquals(table.get_size(), (3, 2))
# Test using the actual property names
table = Gtk.Table(n_rows=2, n_columns=3, homogeneous=True)
- self.assertEquals(table.get_size(), (2,3))
+ self.assertEquals(table.get_size(), (2, 3))
self.assertEquals(table.get_homogeneous(), True)
label = Gtk.Label(label='Hello')
@@ -1789,7 +1790,7 @@ class TestGtk(unittest.TestCase):
widget.drag_dest_get_track_motion()
widget.drag_dest_set_track_motion(True)
widget.drag_dest_get_target_list()
- widget.drag_dest_set_target_list(Gtk.TargetList.new([Gtk.TargetEntry.new('test',0, 0)]))
+ widget.drag_dest_set_target_list(Gtk.TargetList.new([Gtk.TargetEntry.new('test', 0, 0)]))
widget.drag_dest_unset()
widget.drag_highlight()
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 8a73ab8..5f0bed6 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -26,6 +26,7 @@ else:
from compathelper import _long
+
class PropertyObject(GObject.GObject):
normal = GObject.Property(type=str)
construct = GObject.Property(
@@ -43,6 +44,7 @@ class PropertyObject(GObject.GObject):
boxed = GObject.Property(
type=GLib.Regex, flags=PARAM_READWRITE|PARAM_CONSTRUCT)
+
class TestProperties(unittest.TestCase):
def testGetSet(self):
obj = PropertyObject()
@@ -181,6 +183,7 @@ class TestProperties(unittest.TestCase):
# kiwi code
def max(c):
return 2 ** ((8 * struct.calcsize(c)) - 1) - 1
+
def umax(c):
return 2 ** (8 * struct.calcsize(c)) - 1
@@ -245,7 +248,6 @@ class TestProperties(unittest.TestCase):
obj.set_property(key, max)
self.assertEqual(obj.get_property(key), max)
-
def testMulti(self):
obj = PropertyObject()
obj.set_properties(normal="foo",
@@ -254,6 +256,7 @@ class TestProperties(unittest.TestCase):
self.assertEqual(normal, "foo")
self.assertEqual(uint64, 7)
+
class TestProperty(unittest.TestCase):
def testSimple(self):
class C(GObject.GObject):
@@ -313,9 +316,11 @@ class TestProperty(unittest.TestCase):
def testDecoratorDefault(self):
class C(GObject.GObject):
_value = 'value'
+
@GObject.Property
def value(self):
return self._value
+
@value.setter
def value_setter(self, value):
self._value = value
@@ -329,9 +334,11 @@ class TestProperty(unittest.TestCase):
def testDecoratorWithCall(self):
class C(GObject.GObject):
_value = 1
+
@GObject.Property(type=int, default=1, minimum=1, maximum=10)
def typedValue(self):
return self._value
+
@typedValue.setter
def typedValue_setter(self, value):
self._value = value
@@ -521,12 +528,14 @@ class TestProperty(unittest.TestCase):
raise AssertionError
# Bug 587637.
+
def test_float_min(self):
GObject.Property(type=float, minimum=-1)
GObject.Property(type=GObject.TYPE_FLOAT, minimum=-1)
GObject.Property(type=GObject.TYPE_DOUBLE, minimum=-1)
# Bug 644039
+
def testReferenceCount(self):
# We can check directly if an object gets finalized, so we will
# observe it indirectly through the refcount of a member object.
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 46be7fc..54e9f04 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -8,17 +8,21 @@ from gi.repository import GObject
import testhelper
from compathelper import _long
+
class C(GObject.GObject):
__gsignals__ = { 'my_signal': (GObject.SignalFlags.RUN_FIRST, None,
(GObject.TYPE_INT,)) }
+
def do_my_signal(self, arg):
self.arg = arg
+
class D(C):
def do_my_signal(self, arg2):
self.arg2 = arg2
C.do_my_signal(self, arg2)
+
class TestSignalCreation(unittest.TestCase):
# Bug 540376.
def test_illegals(self):
@@ -55,6 +59,8 @@ class TestChaining(unittest.TestCase):
assert inst2.arg2 == 44
# This is for bug 153718
+
+
class TestGSignalsError(unittest.TestCase):
def testInvalidType(self, *args):
def foo():
@@ -66,10 +72,11 @@ class TestGSignalsError(unittest.TestCase):
def testInvalidName(self, *args):
def foo():
class Foo(GObject.GObject):
- __gsignals__ = {'not-exists' : 'override'}
+ __gsignals__ = {'not-exists': 'override'}
self.assertRaises(TypeError, foo)
gc.collect()
+
class TestGPropertyError(unittest.TestCase):
def testInvalidType(self, *args):
def foo():
@@ -81,11 +88,12 @@ class TestGPropertyError(unittest.TestCase):
def testInvalidName(self, *args):
def foo():
class Foo(GObject.GObject):
- __gproperties__ = { None: None }
+ __gproperties__ = {None: None}
self.assertRaises(TypeError, foo)
gc.collect()
+
class TestList(unittest.TestCase):
def testListObject(self):
self.assertEqual(GObject.signal_list_names(C), ('my-signal',))
@@ -99,6 +107,7 @@ def my_accumulator(ihint, return_accu, handler_return, user_data):
return False, return_accu
return True, return_accu + handler_return
+
class Foo(GObject.GObject):
__gsignals__ = {
'my-acc-signal': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_INT,
@@ -107,6 +116,7 @@ class Foo(GObject.GObject):
(), GObject.signal_accumulator_true_handled)
}
+
class TestAccumulator(unittest.TestCase):
def testAccumulator(self):
@@ -134,16 +144,20 @@ class TestAccumulator(unittest.TestCase):
def _true_handler1(self, obj):
self.__true_val = 1
return False
+
def _true_handler2(self, obj):
self.__true_val = 2
return True
+
def _true_handler3(self, obj):
self.__true_val = 3
return False
+
class E(GObject.GObject):
__gsignals__ = { 'signal': (GObject.SignalFlags.RUN_FIRST, None,
()) }
+
def __init__(self):
GObject.GObject.__init__(self)
self.status = 0
@@ -152,9 +166,11 @@ class E(GObject.GObject):
assert self.status == 0
self.status = 1
+
class F(GObject.GObject):
__gsignals__ = { 'signal': (GObject.SignalFlags.RUN_FIRST, None,
()) }
+
def __init__(self):
GObject.GObject.__init__(self)
self.status = 0
@@ -162,6 +178,7 @@ class F(GObject.GObject):
def do_signal(self):
self.status += 1
+
class TestEmissionHook(unittest.TestCase):
def testAdd(self):
self.hook = True
@@ -194,6 +211,7 @@ class TestEmissionHook(unittest.TestCase):
def testCallbackReturnFalse(self):
self.hook = False
obj = F()
+
def _emission_hook(obj):
obj.status += 1
return False
@@ -205,6 +223,7 @@ class TestEmissionHook(unittest.TestCase):
def testCallbackReturnTrue(self):
self.hook = False
obj = F()
+
def _emission_hook(obj):
obj.status += 1
return True
@@ -217,6 +236,7 @@ class TestEmissionHook(unittest.TestCase):
def testCallbackReturnTrueButRemove(self):
self.hook = False
obj = F()
+
def _emission_hook(obj):
obj.status += 1
return True
@@ -226,6 +246,7 @@ class TestEmissionHook(unittest.TestCase):
obj.emit('signal')
self.assertEqual(obj.status, 3)
+
class TestClosures(unittest.TestCase):
def setUp(self):
self.count = 0
@@ -276,9 +297,11 @@ class TestClosures(unittest.TestCase):
class C(GObject.GObject):
__gsignals__ = { 'my_signal': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_GSTRING,
(GObject.TYPE_GSTRING,)) }
+
def __init__(self, test):
GObject.GObject.__init__(self)
self.test = test
+
def do_my_signal(self, data):
self.data = data
self.test.assertEqual(len(data), 3)
@@ -287,6 +310,7 @@ class TestClosures(unittest.TestCase):
data = c.emit("my_signal", "\01\00\02")
self.assertEqual(data, "\02\00\01")
+
class SigPropClass(GObject.GObject):
__gsignals__ = { 'my_signal': (GObject.SignalFlags.RUN_FIRST, None,
(GObject.TYPE_INT,)) }
@@ -323,6 +347,7 @@ double = GObject.TYPE_DOUBLE
uint = GObject.TYPE_UINT
ulong = GObject.TYPE_ULONG
+
class CM(GObject.GObject):
__gsignals__ = dict(
test1=(f, None, ()),
@@ -335,6 +360,7 @@ class CM(GObject.GObject):
test_object=(l, object, (object, )),
)
+
class _TestCMarshaller:
def setUp(self):
self.obj = CM()
@@ -378,6 +404,8 @@ else:
print()
# Test for 374653
+
+
class TestPyGValue(unittest.TestCase):
def testNoneNULLBoxedConversion(self):
class C(GObject.GObject):
diff --git a/tests/test_source.py b/tests/test_source.py
index 3dc9c5f..85362ad 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -4,6 +4,7 @@ import unittest
from gi.repository import GLib
+
class Idle(GLib.Idle):
def __init__(self, loop):
GLib.Idle.__init__(self)
diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py
index 14c6283..69f5f4c 100644
--- a/tests/test_subprocess.py
+++ b/tests/test_subprocess.py
@@ -5,6 +5,7 @@ import unittest
from gi.repository import GLib
+
class TestProcess(unittest.TestCase):
def _child_watch_cb(self, pid, condition, data):
diff --git a/tests/test_thread.py b/tests/test_thread.py
index fa52dfa..b707bc4 100644
--- a/tests/test_thread.py
+++ b/tests/test_thread.py
@@ -5,6 +5,7 @@ import testhelper
from gi.repository import GLib
+
class TestThread(unittest.TestCase):
def setUp(self):
self.main = GLib.MainLoop()
diff --git a/tests/test_uris.py b/tests/test_uris.py
index c223d3e..095a9dd 100644
--- a/tests/test_uris.py
+++ b/tests/test_uris.py
@@ -2,6 +2,7 @@ import unittest
from gi.repository import GLib
+
class TestUris(unittest.TestCase):
def testExtractUris(self):
uri_list_text = "# urn:isbn:0-201-08372-8\n" + \
diff --git a/tests/testmodule.py b/tests/testmodule.py
index c4132c5..3da8ed5 100644
--- a/tests/testmodule.py
+++ b/tests/testmodule.py
@@ -1,5 +1,6 @@
from gi.repository import GObject
+
class PyGObject(GObject.GObject):
__gtype_name__ = 'PyGObject'
__gproperties__ = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]