From: <win...@us...> - 2008-04-30 14:25:14
|
Revision: 7288 http://translate.svn.sourceforge.net/translate/?rev=7288&view=rev Author: winterstream Date: 2008-04-30 07:24:52 -0700 (Wed, 30 Apr 2008) Log Message: ----------- Various cosmetic changes. Some of the changes were recommended by pylint. Modified Paths: -------------- src/trunk/virtaal/setup.py src/trunk/virtaal/virtaal/main_window.py src/trunk/virtaal/virtaal/support/partial.py src/trunk/virtaal/virtaal/support/simplegeneric.py src/trunk/virtaal/virtaal/support/sorted_set.py src/trunk/virtaal/virtaal/unit_editor.py src/trunk/virtaal/virtaal/unit_grid.py src/trunk/virtaal/virtaal/widgets/label_expander.py Property Changed: ---------------- src/trunk/virtaal/ Property changes on: src/trunk/virtaal ___________________________________________________________________ Name: bzr:revision-id:v3-single1-c3JjL3RydW5rL3ZpcnRhYWw. - 14 wyn...@gm...-20080411084527-h6d8h012w3xilzep 15 wyn...@gm...-20080411094646-gl1gcj595xsffki9 16 wyn...@gm...-20080411095625-5hj0uiweezj6qi3h 17 wyn...@gm...-20080411140509-8m8p5oe5lmov595m 18 wyn...@gm...-20080411144419-hiuig40y7x9at37f 25 wyn...@gm...-20080414100315-m89mcnd0bm3ibyq9 27 wyn...@gm...-20080414101932-ghgs3fd04ppzohpc 41 wyn...@gm...-20080414143220-l6hfwwpejre3kp0o 42 wyn...@gm...-20080414144759-rmutnowkh26vbvw0 43 wyn...@gm...-20080415075927-0cwg3ev3c2o8cjuv 44 wyn...@gm...-20080415090132-5t781mlsxnvs8eyc 49 wyn...@gm...-20080415135432-qtudgtosr3retdzu 51 wyn...@gm...-20080416144113-a8rfaks4petzip1w 63 wyn...@gm...-20080417092936-mtqipjc3dvquzdl9 64 wyn...@gm...-20080417104615-agsr4h0d928a8vmp 65 wyn...@gm...-20080417104921-mc2jgy5vv05zj923 66 wyn...@gm...-20080417105238-29zhsqh9x3bn9pjk 73 wyn...@gm...-20080418092323-hb1gqlk5llzlusj3 74 wyn...@gm...-20080418111046-v6j0upr348wrq9g5 75 wyn...@gm...-20080418153615-zmvmm48i8yvb6jba 76 wyn...@gm...-20080418160129-3vzfgmqydrdz9e08 77 wyn...@gm...-20080421083631-uw57xplep9cmx0cm 78 wyn...@gm...-20080422075038-cwrroo10tg9cba4m 79 wyn...@gm...-20080422095355-3kf7g99224qhed3g 80 wyn...@gm...-20080422100150-6favh1ahs1y1m61b 81 wyn...@gm...-20080422121158-4eb5h53omm1l2pmz 82 wyn...@gm...-20080422160420-djkcinoxmnce1dq2 83 wyn...@gm...-20080422170306-o19767lezak8ysuc 84 wyn...@gm...-20080423075006-6i5ta2mc6k48ldj6 85 wyn...@gm...-20080423090557-i4tuiq5w3bwox766 86 wyn...@gm...-20080423092221-soz5n0egf1u5xyc4 112 wyn...@gm...-20080423141350-gfnesq9c5h5mwb1w 113 wyn...@gm...-20080423141814-sgx6ib9oobmdh5df 114 wyn...@gm...-20080423142518-ajvr7o079qbs1bzi 115 wyn...@gm...-20080423154733-4pegvc5vkfynrsmb 116 wyn...@gm...-20080424143020-us0u9r3cyii3hdk3 117 wyn...@gm...-20080424144407-c49c4v4tw2bt7pp7 118 wyn...@gm...-20080424145208-1xyl5lrw87vyi708 + 14 wyn...@gm...-20080411084527-h6d8h012w3xilzep 15 wyn...@gm...-20080411094646-gl1gcj595xsffki9 16 wyn...@gm...-20080411095625-5hj0uiweezj6qi3h 17 wyn...@gm...-20080411140509-8m8p5oe5lmov595m 18 wyn...@gm...-20080411144419-hiuig40y7x9at37f 25 wyn...@gm...-20080414100315-m89mcnd0bm3ibyq9 27 wyn...@gm...-20080414101932-ghgs3fd04ppzohpc 41 wyn...@gm...-20080414143220-l6hfwwpejre3kp0o 42 wyn...@gm...-20080414144759-rmutnowkh26vbvw0 43 wyn...@gm...-20080415075927-0cwg3ev3c2o8cjuv 44 wyn...@gm...-20080415090132-5t781mlsxnvs8eyc 49 wyn...@gm...-20080415135432-qtudgtosr3retdzu 51 wyn...@gm...-20080416144113-a8rfaks4petzip1w 63 wyn...@gm...-20080417092936-mtqipjc3dvquzdl9 64 wyn...@gm...-20080417104615-agsr4h0d928a8vmp 65 wyn...@gm...-20080417104921-mc2jgy5vv05zj923 66 wyn...@gm...-20080417105238-29zhsqh9x3bn9pjk 73 wyn...@gm...-20080418092323-hb1gqlk5llzlusj3 74 wyn...@gm...-20080418111046-v6j0upr348wrq9g5 75 wyn...@gm...-20080418153615-zmvmm48i8yvb6jba 76 wyn...@gm...-20080418160129-3vzfgmqydrdz9e08 77 wyn...@gm...-20080421083631-uw57xplep9cmx0cm 78 wyn...@gm...-20080422075038-cwrroo10tg9cba4m 79 wyn...@gm...-20080422095355-3kf7g99224qhed3g 80 wyn...@gm...-20080422100150-6favh1ahs1y1m61b 81 wyn...@gm...-20080422121158-4eb5h53omm1l2pmz 82 wyn...@gm...-20080422160420-djkcinoxmnce1dq2 83 wyn...@gm...-20080422170306-o19767lezak8ysuc 84 wyn...@gm...-20080423075006-6i5ta2mc6k48ldj6 85 wyn...@gm...-20080423090557-i4tuiq5w3bwox766 86 wyn...@gm...-20080423092221-soz5n0egf1u5xyc4 112 wyn...@gm...-20080423141350-gfnesq9c5h5mwb1w 113 wyn...@gm...-20080423141814-sgx6ib9oobmdh5df 114 wyn...@gm...-20080423142518-ajvr7o079qbs1bzi 115 wyn...@gm...-20080423154733-4pegvc5vkfynrsmb 116 wyn...@gm...-20080424143020-us0u9r3cyii3hdk3 117 wyn...@gm...-20080424144407-c49c4v4tw2bt7pp7 118 wyn...@gm...-20080424145208-1xyl5lrw87vyi708 119 wyn...@gm...-20080424151453-ptvn7v2724ttf7v9 Name: bzr:revision-info - timestamp: 2008-04-24 16:52:08.257999897 +0200 committer: Wynand Winterbach <wyn...@gm...> properties: branch-nick: VirtaalSVN rebase-of: wyn...@gm...-20080424145208-s2x2p0tan8mw7vz6 + timestamp: 2008-04-24 17:14:53.072000027 +0200 committer: Wynand Winterbach <wyn...@gm...> properties: branch-nick: VirtaalSVN rebase-of: wyn...@gm...-20080424151453-aj6i6q9c8wlk3f00 Name: bzr:file-ids - virtaal/globals.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2FGlobals.py virtaal/main_window.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2FMainWindow.py virtaal/profiler.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2FProfiler.py virtaal/unit_grid.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2Funitgrid.py virtaal/unit_renderer.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2Funitrenderer.py virtaal/widgets/entry_dialog.py 7126@54714841-351b-0410-a198-e36a94b762f5:src%2Ftrunk%2Fvirtaal:virtaal%2FEntryDialog.py + Modified: src/trunk/virtaal/setup.py =================================================================== --- src/trunk/virtaal/setup.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/setup.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -8,7 +8,7 @@ import py2exe build_exe = py2exe.build_exe.py2exe Distribution = py2exe.Distribution - + except ImportError: py2exe = None build_exe = Command @@ -16,18 +16,28 @@ from virtaal.__version__ import ver as virtaal_version from virtaal.formats import supported_types +def if_none(var, new_val): + if var == None: + return val + else: + return var + ############################################################################## # Windows building functions and classes class InnoScript: """class that builds an InnoSetup script""" - - def __init__(self, name, lib_dir, dist_dir, exe_files = [], other_files = [], install_scripts = [], version = "1.0"): + + def __init__(self, name, lib_dir, dist_dir, exe_files=None, other_files=None, install_scripts=None, version = "1.0"): + exe_files = if_none(exe_files, []) + other_files = if_none(other_files, []) + install_scripts = if_none(install_scripts, []) + self.lib_dir = lib_dir self.dist_dir = dist_dir if not self.dist_dir.endswith(os.sep): self.dist_dir += os.sep - + self.name = name self.version = version self.exe_files = [self.chop(p) for p in exe_files] @@ -41,7 +51,7 @@ compile_key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, "innosetupscriptfile\\shell\\compile\\command") compilecommand = _winreg.QueryValue(compile_key, "") compile_key.Close() - + except: compilecommand = "compil32.exe" return compilecommand @@ -57,10 +67,10 @@ """creates the InnoSetup script""" if pathname is None: self.pathname = path.join(self.dist_dir, self.name + os.extsep + "iss") - + else: self.pathname = pathname - + # See http://www.jrsoftware.org/isfaq.php for more InnoSetup config options. ofi = self.file = open(self.pathname, "w") print >> ofi, r'''; WARNING: This script has been created by py2exe. Changes to this script @@ -142,25 +152,25 @@ def map_data_file (data_file): """remaps a data_file (could be a directory) to a different location This version gets rid of Lib\\site-packages, etc""" - + data_parts = data_file.split(os.sep) - + if data_parts[:2] == ["Lib", "site-packages"]: data_parts = data_parts[2:] if data_parts: data_file = path.join(*data_parts) - + else: data_file = "" - + if data_parts[:1] == ["translate"]: data_parts = data_parts[1:] if data_parts: data_file = path.join(*data_parts) - + else: data_file = "" - + return data_file @@ -173,18 +183,18 @@ install_data = build_exe.reinitialize_command(self, command, reinit_subcommands) install_data.data_files = self.remap_data_files(install_data.data_files) return install_data - + return build_exe.reinitialize_command(self, command, reinit_subcommands) def remap_data_files(self, data_files): """maps the given data files to different locations using external map_data_file function""" new_data_files = [] - + for f in data_files: if type(f) in (str, unicode): f = map_data_file(f) - + else: datadir, files = f datadir = map_data_file(datadir) @@ -192,10 +202,10 @@ f = None else: f = datadir, files - + if f is not None: new_data_files.append(f) - + return new_data_files @@ -203,7 +213,7 @@ """distutils class that first builds the exe file(s), then creates a Windows installer using InnoSetup""" description = "create an executable installer for MS Windows using InnoSetup and py2exe" - + user_options = getattr(build_exe, 'user_options', []) + \ [('install-script=', None, "basename of installation script to be run after installation or before deinstallation")] @@ -259,7 +269,7 @@ files = [path.join(p, f) for f in os.listdir(p) if path.isfile(path.join(p, f)) and f.startswith(GTK_NAME)] if len(files) > 0: return p - + raise Exception("""Could not find the GTK runtime. Please place bin directory of your GTK installation in the program path.""") @@ -267,7 +277,7 @@ def findGTKFiles(): def parent(dir): return path.abspath(path.join(path.abspath(dir), '..')) - + def stripLeadingPath(leadingPath, p): return p[len(leadingPath) + 1:] @@ -280,8 +290,8 @@ dataFiles.append((stripLeadingPath(gtkPath, dirName), files)) return dataFiles - + class TranslateDistribution(Distribution): """a modified distribution class for translate""" def __init__(self, attrs): @@ -289,7 +299,7 @@ if py2exe: attrs.setdefault('data_files', []).extend(findGTKFiles()) - + baseattrs = { "options": { "py2exe": { @@ -308,11 +318,11 @@ 'icon_resources': [(1, "icons/virtaal.ico")], } ], - + 'zipfile': "virtaal.zip", 'cmdclass': {"py2exe": build_exe_map, "innosetup": build_installer} } - + baseattrs["options"]["innosetup"] = baseattrs["options"]["py2exe"].copy() baseattrs["options"]["innosetup"]["install_script"] = [] @@ -322,7 +332,7 @@ def dosetup(name, version, packages, **kwargs): long_description = __doc__ - #description = __doc__.split("\n", 1)[0] + #description = __doc__.split("\n", 1)[0] description = "A program to do translations." setup(name=name, version=version, @@ -340,7 +350,10 @@ **kwargs) -def standardsetup(name, version, custompackages=[], customdatafiles=[]): +def standardsetup(name, version, custompackages=None, customdatafiles=None): + custompackages = if_none(custompackages, []) + customdatafiles = if_none(customdatafiles, []) + dosetup(name, version, packages=['virtaal'], data_files=[('virtaal', ['virtaal/data/virtaal.glade']), @@ -349,6 +362,6 @@ ('icons', ['virtaal.png', 'virtaal.ico'])], scripts=['run_virtaal.py']) - + if __name__ == "__main__": standardsetup("VirTaal", virtaal_version) Modified: src/trunk/virtaal/virtaal/main_window.py =================================================================== --- src/trunk/virtaal/virtaal/main_window.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/main_window.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -82,6 +82,7 @@ self.translation_store = None self.unit_grid = None + self.document = None def _on_mainwindow_delete(self, _widget, _event): if self.modified: Modified: src/trunk/virtaal/virtaal/support/partial.py =================================================================== --- src/trunk/virtaal/virtaal/support/partial.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/support/partial.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -1,15 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# +# # Copyright 2008 Zuza Software Foundation -# +# # This file is part of virtaal. # # virtaal is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # translate is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -29,19 +29,19 @@ def partial(f, *args, **kwargs): """Given a function foo, return a new function bar with some parameters already specified. - + This can best be illustrated by an example: - + >>> def foo(a, b): ... return a - b - ... + ... ... bar = partial(foo, b=2) ... bar(1) -1 - - Partial application is more powerful than Python lambda functions, since the latter + + Partial application is more powerful than Python lambda functions, since the latter does not store a copy to its environment; thus if you reference a variable i in a - lambda and i changes, then the lambda will also see a changed copy. + lambda and i changes, then the lambda will also see a changed copy. """ def new_f(*new_args, **new_kwargs): all_args = args + new_args @@ -53,7 +53,7 @@ def compose(*funcs): """Compose two or more functions into a single function. - + This operates as mathematical composition. Thus, compose(a, b, c) is equivalent to a . b . c in mathematical notation. In Python, this can also be written as lambda *args: a(b(c(*args))). @@ -75,33 +75,33 @@ """Turn a normal Python function into a decorator which causes the code in the function to be executed after the code in the decorated function is executed. - + For example, suppose that you have a function foo. If you want the code in bar to be executed after the code in foo, you can decorate foo as follows: - + @post(bar) def foo(a, b, c, ...) - + The function bar needs to have a signature as follows: def bar(foo_return_value, a, b, c, ...) - + Thus, the first parameter of bar is the return value of foo and the rest of its parameters are identical to that of foo (this is so that bar has access to the parameters. - + As a concrete example, an implementation of bar might look something like: def bar(foo_return, a, *args): print 'The return value of the function that ran before me is %s' % repr(foo_return) print 'The first parameter is %s'% repr(a) - + return foo_return + 42 - + and the definition of foo something like: @post(bar) def foo(a, b, c): print 'I am foo' return 0 - + Thus >>> foo(1, 2, 3) ... I am foo @@ -112,12 +112,12 @@ def decorator(f): def new_f(*args, **kwargs): return post_f(f(*args, **kwargs), *args, **kwargs) - + copy_attrs(f, new_f) setattr(new_f, '__name__', f.__name__ + "+" + post_f.__name__) setattr(new_f, '__module__', f.__module__ + "+" + post_f.__module__) return new_f - + copy_attrs(post_f, decorator) return decorator @@ -125,8 +125,8 @@ # def decorator(f): # def new_f(*args, **kwargs): # return f(*pre_f(*args, **kwargs)) -# +# # return new_f - + # return decorator Modified: src/trunk/virtaal/virtaal/support/simplegeneric.py =================================================================== --- src/trunk/virtaal/virtaal/support/simplegeneric.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/support/simplegeneric.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -1,17 +1,17 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# +# # Copyright 2008 Zuza Software Foundation -# +# # This file is part of virtaal. # This file was originally part of the PEAK project: -# http://peak.telecommunity.com/DevCenter/FrontPage +# http://peak.telecommunity.com/DevCenter/FrontPage # # virtaal is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # translate is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -57,11 +57,6 @@ return f return decorate - - - - - _by_object = {} _gbo = _by_object.get @@ -75,7 +70,6 @@ return f return decorate - def dispatch(*args, **kw): f = _gbo(id(args[0]), _sentinel) if f is _sentinel: @@ -100,47 +94,9 @@ dispatch.has_type = lambda t: t in _by_type return dispatch - - - def test_suite(): import doctest return doctest.DocFileSuite( 'README.txt', optionflags=doctest.ELLIPSIS|doctest.REPORT_ONLY_FIRST_FAILURE, ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: src/trunk/virtaal/virtaal/support/sorted_set.py =================================================================== --- src/trunk/virtaal/virtaal/support/sorted_set.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/support/sorted_set.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -62,7 +62,7 @@ """ -from bisect import bisect_left, insort_left +from bisect import bisect_left import gobject Modified: src/trunk/virtaal/virtaal/unit_editor.py =================================================================== --- src/trunk/virtaal/virtaal/unit_editor.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/unit_editor.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -201,18 +201,18 @@ return widget, names def associate_layout_and_widget(widget_and_names, layout): - widget, names = widget_and_names + widget, _names = widget_and_names layout.__widget = widget widget.__layout = layout return widget_and_names def skip_enter_processing(widget_and_names, layout): - widget, names = widget_and_names + widget, _names = widget_and_names widget.connect('key-press-event', on_key_press_event) return widget_and_names -def specialize_make_widget(type): - return compose(make_widget.when_type(type), +def specialize_make_widget(type_desc): + return compose(make_widget.when_type(type_desc), post(associate_layout_and_widget), post(skip_enter_processing), post(set_size)) @@ -410,6 +410,8 @@ focus_text_view(self._widget_dict['source-0'].child) def _on_focus(self, widget, _direction): + # TODO: Check whether we do need to refocus the last edited text_view when + # our program gets focus after having lost it. self.recent_textview = widget return False @@ -442,9 +444,9 @@ else: return multistring(targets) - def _on_source_scroll(self, _textview, _step_size, _count, _extend_selection): - #XXX scroll the source??? - return True +# def _on_source_scroll(self, _textview, _step_size, _count, _extend_selection): +# #XXX scroll the source??? +# return True def _on_insert_at_cursor(self, _textview, _string): return True Modified: src/trunk/virtaal/virtaal/unit_grid.py =================================================================== --- src/trunk/virtaal/virtaal/unit_grid.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/unit_grid.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -151,9 +151,6 @@ return True def on_button_press(self, _widget, event): -# if self._modified_widget: -# self._modified_widget.stop_editing(canceled=False) - # XXX - emit modified answer = self.get_path_at_pos(int(event.x), int(event.y)) if answer is None: print "marakas! geen path gevind by (x,y) nie!" @@ -164,7 +161,6 @@ itr = self.get_model().get_iter(old_path) self.get_model().set(itr, COLUMN_EDITABLE, False) self._activate_editing_path(path) - #self.update_for_save(away=True) return True def _activate_editing_path(self, path): Modified: src/trunk/virtaal/virtaal/widgets/label_expander.py =================================================================== --- src/trunk/virtaal/virtaal/widgets/label_expander.py 2008-04-30 14:22:23 UTC (rev 7287) +++ src/trunk/virtaal/virtaal/widgets/label_expander.py 2008-04-30 14:24:52 UTC (rev 7288) @@ -4,17 +4,17 @@ def label_escape(text): escapes = [("\n", '\\n'), ("\r", '\\r')] - return reduce(lambda text, escape: text.replace(*escape), escapes, text) + return reduce(lambda text, escape: text.replace(*escape), escapes, text) class LabelExpander(gtk.EventBox): __gproperties__ = { "expanded": (gobject.TYPE_BOOLEAN, - "expanded", + "expanded", "A boolean indicating whether this widget has been expanded to show its contained widget", False, gobject.PARAM_READWRITE), } - + def __init__(self, widget, get_text, expanded=False): super(LabelExpander, self).__init__() @@ -22,37 +22,37 @@ label_text.set_single_line_mode(True) label_text.set_ellipsize(pango.ELLIPSIZE_END) label_text.set_justify(gtk.JUSTIFY_LEFT) - + self.label = gtk.EventBox() self.label.add(label_text) - + self.widget = widget self.get_text = get_text - + self.expanded = expanded - + #self.label.connect('button-release-event', lambda widget, *args: setattr(self, 'expanded', True)) def do_get_property(self, prop): return getattr(self, prop.name) - + def do_set_property(self, prop, value): setattr(self, prop.name, value) - + def _get_expanded(self): return self.child == self.widget - + def _set_expanded(self, value): if self.child != None: self.remove(self.child) if value: - self.add(self.widget) + self.add(self.widget) else: self.add(self.label) self.label.child.set_text(label_escape(self.get_text())) - + self.child.show() - + expanded = property(_get_expanded, _set_expanded) - + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |