diff options
author | Johan Dahlin <johan@src.gnome.org> | 2006-04-11 14:11:09 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2006-04-11 14:11:09 +0000 |
commit | d775961664e4755481ef01c192ea8b8d27cf7567 (patch) | |
tree | 60beef30983edffbc29f74db19ef6163ee743f33 | |
parent | be8d076bbafd3bb5f26fa8716ff6e898b76b1d1a (diff) | |
download | pygobject-d775961664e4755481ef01c192ea8b8d27cf7567.tar.gz pygobject-d775961664e4755481ef01c192ea8b8d27cf7567.tar.xz pygobject-d775961664e4755481ef01c192ea8b8d27cf7567.zip |
reindent
-rw-r--r-- | dsextras.py | 73 | ||||
-rw-r--r-- | examples/signal.py | 8 | ||||
-rw-r--r-- | ltihooks.py | 48 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | tests/common.py | 17 | ||||
-rw-r--r-- | tests/runtests.py | 4 | ||||
-rw-r--r-- | tests/test_conversion.py | 14 | ||||
-rw-r--r-- | tests/test_enum.py | 10 | ||||
-rw-r--r-- | tests/test_gtype.py | 12 | ||||
-rw-r--r-- | tests/test_mainloop.py | 4 | ||||
-rw-r--r-- | tests/test_properties.py | 12 | ||||
-rw-r--r-- | tests/test_signal.py | 2 | ||||
-rw-r--r-- | tests/test_subtype.py | 4 | ||||
-rw-r--r-- | tests/test_thread.py | 2 | ||||
-rw-r--r-- | tests/test_unknown.py | 2 | ||||
-rw-r--r-- | tests/testmodule.py | 4 |
16 files changed, 107 insertions, 111 deletions
diff --git a/dsextras.py b/dsextras.py index 4ba908c..9caac13 100644 --- a/dsextras.py +++ b/dsextras.py @@ -27,7 +27,7 @@ def get_m4_define(varname): fname = 'configure.in' else: raise SystemExit('could not find configure file') - + for line in open(fname).readlines(): match_obj = pattern.match(line) if match_obj: @@ -85,11 +85,11 @@ def pkgc_version_check(name, longname, req_version): if not is_installed: print "Could not find %s" % longname return 0 - + orig_version = getoutput('pkg-config --modversion %s' % name) version = map(int, orig_version.split('.')) pkc_version = map(int, req_version.split('.')) - + if version >= pkc_version: return 1 else: @@ -105,7 +105,7 @@ class BuildExt(build_ext): if sys.platform == 'win32' and \ self.compiler.compiler_type == 'mingw32': # MSVC compatible struct packing is required. - # Note gcc2 uses -fnative-struct while gcc3 + # Note gcc2 uses -fnative-struct while gcc3 # uses -mms-bitfields. Based on the version # the proper flag is used below. msnative_struct = { '2' : '-fnative-struct', @@ -114,7 +114,7 @@ class BuildExt(build_ext): print 'using MinGW GCC version %s with %s option' % \ (gcc_version, msnative_struct[gcc_version[0]]) self.extra_compile_args.append(msnative_struct[gcc_version[0]]) - + def modify_compiler(self): if sys.platform == 'win32' and \ self.compiler.compiler_type == 'mingw32': @@ -122,7 +122,7 @@ class BuildExt(build_ext): # from trying to link with MSVC import libraries. if self.compiler.linker_so.count('-static'): self.compiler.linker_so.remove('-static') - + def build_extensions(self): # Init self.extra_compile_args self.init_extra_compile_args() @@ -130,7 +130,7 @@ class BuildExt(build_ext): self.modify_compiler() # Invoke base build_extensions() build_ext.build_extensions(self) - + def build_extension(self, ext): # Add self.extra_compile_args to ext.extra_compile_args ext.extra_compile_args += self.extra_compile_args @@ -144,10 +144,10 @@ class InstallLib(install_lib): local_outputs = [] local_inputs = [] - + def set_install_dir(self, install_dir): self.install_dir = install_dir - + def get_outputs(self): return install_lib.get_outputs(self) + self.local_outputs @@ -155,7 +155,7 @@ class InstallLib(install_lib): return install_lib.get_inputs(self) + self.local_inputs class InstallData(install_data): - + local_outputs = [] local_inputs = [] template_options = {} @@ -171,18 +171,18 @@ class InstallData(install_data): self.includedir = '${prefix}/include' self.libdir = '${prefix}/lib' self.datadir = '${prefix}/share' - - self.add_template_option('prefix', self.prefix) - self.add_template_option('exec_prefix', self.exec_prefix) + + self.add_template_option('prefix', self.prefix) + self.add_template_option('exec_prefix', self.exec_prefix) self.add_template_option('includedir', self.includedir) self.add_template_option('libdir', self.libdir) self.add_template_option('datadir', self.datadir) self.add_template_option('PYTHON', sys.executable) self.add_template_option('THREADING_CFLAGS', '') - + def set_install_dir(self, install_dir): self.install_dir = install_dir - + def add_template_option(self, name, value): self.template_options['@%s@' % name] = value @@ -193,20 +193,20 @@ class InstallData(install_data): template = open(filename).read() for key, value in self.template_options.items(): template = template.replace(key, value) - + output = os.path.join(install_dir, output_file) self.mkpath(install_dir) open(output, 'w').write(template) self.local_inputs.append(filename) self.local_outputs.append(output) return output - + def get_outputs(self): return install_lib.get_outputs(self) + self.local_outputs def get_inputs(self): return install_lib.get_inputs(self) + self.local_inputs - + class PkgConfigExtension(Extension): can_build_ok = None def __init__(self, **kwargs): @@ -238,7 +238,7 @@ class PkgConfigExtension(Extension): output = getoutput('pkg-config --libs-only-l %s' % name) retval.extend(output.replace('-l', '').split()) return retval - + def get_library_dirs(self, names): if type(names) != tuple: names = (names,) @@ -250,7 +250,7 @@ class PkgConfigExtension(Extension): def can_build(self): """If the pkg-config version found is good enough""" - if self.can_build_ok != None: + if self.can_build_ok != None: return self.can_build_ok if type(self.pkc_name) != tuple: @@ -278,10 +278,10 @@ class PkgConfigExtension(Extension): (package, orig_version) self.can_build_ok = 0 return 0 - + def generate(self): pass - + class Template: def __init__(self, override, output, defs, prefix, register=[], load_types=None): @@ -291,7 +291,7 @@ class Template: self.output = output self.prefix = prefix self.load_types = load_types - + def check_dates(self): if not os.path.exists(self.output): return 0 @@ -300,17 +300,17 @@ class Template: files.append(self.override) # files.append('setup.py') files.append(self.defs) - + newest = 0 for file in files: test = os.stat(file)[8] if test > newest: newest = test - + if newest < os.stat(self.output)[8]: return 1 return 0 - + def generate(self): # We must insert it first, otherwise python will try '.' first, # in which it exist a "bogus" codegen (the third import line @@ -319,7 +319,7 @@ class Template: from override import Overrides from defsparser import DefsParser from codegen import register_types, write_source, FileOutput - + if self.check_dates(): return @@ -331,18 +331,18 @@ class Template: if self.load_types: globals = {} execfile(self.load_types, globals) - + dp = DefsParser(self.defs,dict(GLOBAL_MACROS)) dp.startParsing() register_types(dp) - + fd = open(self.output, 'w') write_source(dp, Overrides(self.override), self.prefix, FileOutput(fd, self.output)) fd.close() - + class TemplateExtension(PkgConfigExtension): def __init__(self, **kwargs): name = kwargs['name'] @@ -353,19 +353,16 @@ class TemplateExtension(PkgConfigExtension): self.templates = [] self.templates.append(Template(override, output, defs, 'py' + name, kwargs['register'], load_types)) - + del kwargs['register'], kwargs['override'], kwargs['defs'] if load_types: - del kwargs['load_types'] - + del kwargs['load_types'] + if kwargs.has_key('output'): kwargs['name'] = kwargs['output'] del kwargs['output'] - + PkgConfigExtension.__init__(self, **kwargs) - + def generate(self): map(lambda x: x.generate(), self.templates) - - - diff --git a/examples/signal.py b/examples/signal.py index 3ac4235..26ddae9 100644 --- a/examples/signal.py +++ b/examples/signal.py @@ -9,16 +9,16 @@ class C(gobject.GObject): def __init__(self): self.__gobject_init__() # default constructor using our new GType def do_my_signal(self, arg): - print "C: class closure for `my_signal' called with argument", 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) + 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 + "and extra args", extra inst = C() inst2 = D() diff --git a/ltihooks.py b/ltihooks.py index 7086365..ae1d604 100644 --- a/ltihooks.py +++ b/ltihooks.py @@ -21,33 +21,33 @@ import os, ihooks class LibtoolHooks(ihooks.Hooks): def get_suffixes(self): """Like normal get_suffixes, but adds .la suffixes to list""" - ret = ihooks.Hooks.get_suffixes(self) - ret.insert(0, ('module.la', 'rb', 3)) - ret.insert(0, ('.la', 'rb', 3)) - return ret + ret = ihooks.Hooks.get_suffixes(self) + ret.insert(0, ('module.la', 'rb', 3)) + ret.insert(0, ('.la', 'rb', 3)) + return ret def load_dynamic(self, name, filename, file=None): """Like normal load_dynamic, but treat .la files specially""" - if len(filename) > 3 and filename[-3:] == '.la': - fp = open(filename, 'r') - dlname = '' - installed = 1 - line = fp.readline() - while line: - if len(line) > 7 and line[:7] == 'dlname=': - dlname = line[8:-2] - elif len(line) > 10 and line[:10] == 'installed=': - installed = line[10:-1] == 'yes' - line = fp.readline() - fp.close() - if dlname: - if installed: - filename = os.path.join(os.path.dirname(filename), - dlname) - else: - filename = os.path.join(os.path.dirname(filename), - '.libs', dlname) - return ihooks.Hooks.load_dynamic(self, name, filename, file) + if len(filename) > 3 and filename[-3:] == '.la': + fp = open(filename, 'r') + dlname = '' + installed = 1 + line = fp.readline() + while line: + if len(line) > 7 and line[:7] == 'dlname=': + dlname = line[8:-2] + elif len(line) > 10 and line[:10] == 'installed=': + installed = line[10:-1] == 'yes' + line = fp.readline() + fp.close() + if dlname: + if installed: + filename = os.path.join(os.path.dirname(filename), + dlname) + else: + filename = os.path.join(os.path.dirname(filename), + '.libs', dlname) + return ihooks.Hooks.load_dynamic(self, name, filename, file) importer = ihooks.ModuleImporter() importer.set_hooks(LibtoolHooks()) @@ -21,7 +21,7 @@ else: print "It's mainly included to be able to easily build win32 installers" print "You may continue, but only if you agree to not ask any questions" print "To build PyGObject in a supported way, read the INSTALL file" - print + print print "Build fixes are of course welcome and should be filed in bugzilla" print '*'*70 input = raw_input('Not supported, ok [y/N]? ') diff --git a/tests/common.py b/tests/common.py index 627e281..3cd6386 100644 --- a/tests/common.py +++ b/tests/common.py @@ -4,7 +4,7 @@ import sys def importModules(buildDir, srcDir): # Be very careful when you change this code, it's # fragile and the order is really significant - + # ltihooks sys.path.insert(0, srcDir) import ltihooks @@ -15,15 +15,15 @@ def importModules(buildDir, srcDir): # testhelper sys.path.insert(0, os.path.join(buildDir, 'tests')) sys.argv.append('--g-fatal-warnings') - + gobject = importModule('gobject', buildDir, 'gobject/gobject.la') testhelper = importModule('testhelper', '.') - + ltihooks.uninstall() del ltihooks - + globals().update(locals()) - + os.environ['PYGTK_USE_GIL_STATE_API'] = '' gobject.threads_init() @@ -44,8 +44,8 @@ def importModule(module, directory, name=None): except ImportError, e: print 'WARNING: %s could not be imported' % origName print e - return - + return + if hasattr(obj, '__file__'): location = obj.__file__ else: @@ -57,7 +57,6 @@ def importModule(module, directory, name=None): current = os.path.abspath(location) if current != expected: raise AssertionError('module %s imported from wrong location. Expected %s, got %s' % ( - module, expected, current)) + module, expected, current)) return obj - diff --git a/tests/runtests.py b/tests/runtests.py index da866d4..fc0558d 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -38,8 +38,8 @@ loader = unittest.TestLoader() for name in gettestnames(): if program and program not in name: - continue + continue suite.addTest(loader.loadTestsFromName(name)) - + testRunner = unittest.TextTestRunner() testRunner.run(suite) diff --git a/tests/test_conversion.py b/tests/test_conversion.py index 373ab9d..d3aee72 100644 --- a/tests/test_conversion.py +++ b/tests/test_conversion.py @@ -7,10 +7,10 @@ import unittest from common import gtk, gobject class Tests(unittest.TestCase): - + def testUnicharArg(self): """ Test unichar values when used as arguments. """ - + entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_invisible_char(valid_value) @@ -27,11 +27,11 @@ class Tests(unittest.TestCase): raise AssertionError( 'exception not raised on invalid value w/ ' 'set_invisible_char: %s' % invalid_value) - + def testUnicharProperty(self): """ Test unichar values when used as properties. """ - + entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) @@ -53,7 +53,7 @@ class Tests(unittest.TestCase): entry = gobject.new(gtk.Entry, invisible_char=valid_value) self.assertEqual(entry.get_property('invisible_char'), valid_value, valid_value) - + def testColorCreation(self): """ Test GdkColor creation """ @@ -76,10 +76,10 @@ class Tests(unittest.TestCase): table = gtk.Table(2, 2, False) table.attach(child, 1, 2, 0, 1, ypadding=2) self.assertEqual(table.child_get_property(child, 'y-padding'), 2) - + child = gtk.DrawingArea() table.attach(child, 1, 2, 0, 1, ypadding=2L) self.assertEqual(table.child_get_property(child, 'y-padding'), 2) - + if __name__ == '__main__': unittest.main() diff --git a/tests/test_enum.py b/tests/test_enum.py index 508ad16..88d8287 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -123,7 +123,7 @@ class FlagsTest(unittest.TestCase): else: raise AssertionError warnings.resetwarnings() - + def testFlagOperations(self): a = gdk.BUTTON_PRESS_MASK self.failUnless(isinstance(a, GFlags)) @@ -164,7 +164,7 @@ class FlagsTest(unittest.TestCase): self.assertEquals(int(c), (int(gdk.BUTTON_PRESS_MASK) | int(gdk.BUTTON_RELEASE_MASK) | int(gdk.ENTER_NOTIFY_MASK))) - + def testUnsupportedOpertionWarning(self): warnings.filterwarnings("error", "", Warning, "", 0) try: @@ -180,13 +180,13 @@ class FlagsTest(unittest.TestCase): gtk.container_class_list_child_properties(gtk.Table)) self.failUnless(len(props) >= 2) pspec = props[0] - klass = pspec.flags_class + klass = pspec.flags_class self.assertEquals(klass, gtk.AttachOptions) self.failUnless(hasattr(klass, '__flags_values__')) self.failUnless(isinstance(klass.__flags_values__, dict)) self.failUnless(len(klass.__flags_values__) >= 3) self.failUnless(isinstance(pspec.default_value, gtk.AttachOptions)) - + def testEnumComparision(self): enum = gtk.TREE_VIEW_DROP_BEFORE self.assertEquals(enum, 0) @@ -201,7 +201,7 @@ class FlagsTest(unittest.TestCase): self.failUnless(not enum >= 10) self.failUnless(enum <= 0) self.failUnless(enum <= 10) - + def testFlagComparision(self): flag = gdk.EXPOSURE_MASK self.assertEquals(flag, 2) diff --git a/tests/test_gtype.py b/tests/test_gtype.py index b8177fd..52efda4 100644 --- a/tests/test_gtype.py +++ b/tests/test_gtype.py @@ -8,16 +8,16 @@ class GTypeTest(unittest.TestCase): # First, double check so we get back what we sent str = GType(expected).name # pyg_type_from_object val = GType.from_name(str) # pyg_type_wrapper_new - self.assertEqual(val, expected, + self.assertEqual(val, expected, 'got %r while %r was expected' % (val, expected)) # Then test the objects for object in objects: val = GType.from_name(GType(expected).name) - self.assertEqual(val, expected, + self.assertEqual(val, expected, 'got %r while %r was expected' % (val, expected)) - + def testBool(self): self.checkType(gobject.TYPE_BOOLEAN, 'gboolean', bool) @@ -26,7 +26,7 @@ class GTypeTest(unittest.TestCase): # model = gtk.ListStore(str, int) # iter = model.append() # model.set(iter, 1, 100000000) - + def testInt64(self): self.checkType(gobject.TYPE_INT64, 'gint64') @@ -50,7 +50,7 @@ class GTypeTest(unittest.TestCase): def testPyObject(self): self.checkType(gobject.TYPE_PYOBJECT, 'GObject', object) - + def testObject(self): self.checkType(gobject.TYPE_OBJECT, 'PyObject') @@ -62,6 +62,6 @@ class MyObject(gobject.GObject): class TypeNameTest(unittest.TestCase): def testTypeName(self): self.assertEqual(GType(MyObject).name, 'MyObject') - + if __name__ == '__main__': unittest.main() diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py index 44d6937..8294642 100644 --- a/tests/test_mainloop.py +++ b/tests/test_mainloop.py @@ -22,7 +22,7 @@ class TestMainLoop(unittest.TestCase): def child_died(pid, status, loop): loop.quit() raise Exception("deadbabe") - + loop = gobject.MainLoop() gobject.child_watch_add(pid, child_died, loop) @@ -40,7 +40,7 @@ class TestMainLoop(unittest.TestCase): loop.run() except: got_exception = True - + # # The exception should be handled (by printing it) # immediately on return from child_died() rather diff --git a/tests/test_properties.py b/tests/test_properties.py index c73e6a9..d75a810 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -16,14 +16,14 @@ class PropertyObject(GObject): 'uint64': (TYPE_UINT64, 'blurb', 'description', 0, 10, 0, PARAM_READWRITE), } - + def __init__(self): GObject.__init__(self) self._value = 'default' self._construct_only = None self._construct = None self._uint64 = 0L - + def do_get_property(self, pspec): if pspec.name == 'normal': return self._value @@ -47,7 +47,7 @@ class PropertyObject(GObject): self._uint64 = value else: raise AssertionError - + class TestProperties(unittest.TestCase): def testGetSet(self): obj = PropertyObject() @@ -64,7 +64,7 @@ class TestProperties(unittest.TestCase): def testSetNoInstance(self): def set(obj): obj.props.normal = "foobar" - + self.assertRaises(TypeError, set, PropertyObject) def testIterator(self): @@ -85,7 +85,7 @@ class TestProperties(unittest.TestCase): self.assertEqual(obj.props.normal, "456") obj.props.normal = '789' self.assertEqual(obj.props.normal, "789") - + def testConstruct(self): obj = new(PropertyObject, construct="123") self.assertEqual(obj.props.construct, "123") @@ -93,7 +93,7 @@ class TestProperties(unittest.TestCase): self.assertEqual(obj.props.construct, "456") obj.props.construct = '789' self.assertEqual(obj.props.construct, "789") - + def testConstructOnly(self): obj = new(PropertyObject, construct_only="123") self.assertEqual(obj.props.construct_only, "123") diff --git a/tests/test_signal.py b/tests/test_signal.py index b0c023e..f006fae 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -14,7 +14,7 @@ class C(gobject.GObject): class D(C): def do_my_signal(self, arg2): self.arg2 = arg2 - C.do_my_signal(self, arg2) + C.do_my_signal(self, arg2) class TestChaining(unittest.TestCase): def setUp(self): diff --git a/tests/test_subtype.py b/tests/test_subtype.py index 99fbb3b..178c2f0 100644 --- a/tests/test_subtype.py +++ b/tests/test_subtype.py @@ -9,7 +9,7 @@ class TestSubType(unittest.TestCase): t = type('testtype', (GObject, GInterface), {}) self.failUnless(issubclass(t, GObject)) self.failUnless(issubclass(t, GInterface)) - + def testGObject(self): label = gobject.GObject() self.assertEqual(label.__grefcount__, 1) @@ -29,7 +29,7 @@ class TestSubType(unittest.TestCase): self.assertEqual(obj.__grefcount__, 1) refcount = testhelper.test_g_object_new() self.assertEqual(refcount, 2) - + def testRegisterArgNotType(self): self.assertRaises(TypeError, gobject.type_register, 1) diff --git a/tests/test_thread.py b/tests/test_thread.py index 231930f..f1ec01a 100644 --- a/tests/test_thread.py +++ b/tests/test_thread.py @@ -9,7 +9,7 @@ class TestThread(unittest.TestCase): assert test == self.obj assert int(enum) == 0 assert type(enum) != int - + def idle_cb(self): self.obj = testhelper.get_test_thread() self.obj.connect('from-thread', self.from_thread_cb) diff --git a/tests/test_unknown.py b/tests/test_unknown.py index 49e8c40..d2ce6de 100644 --- a/tests/test_unknown.py +++ b/tests/test_unknown.py @@ -5,7 +5,7 @@ from gobject import GType, new from common import gobject, testhelper TestInterface = GType.from_name('TestInterface') - + class TestUnknown(unittest.TestCase): def testFoo(self): obj = testhelper.get_unknown() diff --git a/tests/testmodule.py b/tests/testmodule.py index 2fda01f..5fc29b3 100644 --- a/tests/testmodule.py +++ b/tests/testmodule.py @@ -8,7 +8,7 @@ class PyGObject(gobject.GObject): 'the label of the object', 'default', gobject.PARAM_READWRITE), } - + def __init__(self): self._props = {} gobject.GObject.__init__(self) @@ -16,6 +16,6 @@ class PyGObject(gobject.GObject): def do_set_property(self, name, value): self._props[name] = value - + def do_get_property(self, name): return self._props[name] |