Simplify with built-in functions where possible. e.g.
change [x for x in y if x] to filter(None, y) change [f(x) for x in y] to map(f, x) change [x for x in y] to list(y) These changes reduce source code size and complexity and produce some minor performance gains svn: r14104
This commit is contained in:
@ -219,7 +219,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
self.show()
|
||||
|
||||
def toggled(self,cell,path_string):
|
||||
path = tuple([int (i) for i in path_string.split(':')])
|
||||
path = tuple(map(int, path_string.split(':')))
|
||||
row = self.model[path]
|
||||
row[0] = not row[0]
|
||||
|
||||
|
@ -578,7 +578,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
return
|
||||
|
||||
def toggled(self, cell, path_string):
|
||||
path = tuple([int (i) for i in path_string.split(':')])
|
||||
path = tuple(map(int, path_string.split(':')))
|
||||
row = self.model[path]
|
||||
row[0] = not row[0]
|
||||
|
||||
|
@ -190,7 +190,7 @@ class PatchNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
return (self.label, None)
|
||||
|
||||
def toggled(self, cell, path_string):
|
||||
path = tuple([int (i) for i in path_string.split(':')])
|
||||
path = tuple(map(int, path_string.split(':')))
|
||||
row = self.model[path]
|
||||
row[0] = not row[0]
|
||||
self.model.row_changed(path, row.iter)
|
||||
|
@ -309,7 +309,7 @@ class RemoveUnused(Tool.Tool, ManagedWindow.ManagedWindow, UpdateCallback):
|
||||
self.db.request_rebuild()
|
||||
|
||||
def selection_toggled(self, cell, path_string):
|
||||
sort_path = tuple([int (i) for i in path_string.split(':')])
|
||||
sort_path = tuple(map(int, path_string.split(':')))
|
||||
real_path = self.sort_model.convert_path_to_child_path(sort_path)
|
||||
row = self.real_model[real_path]
|
||||
row[RemoveUnused.MARK_COL] = not row[RemoveUnused.MARK_COL]
|
||||
|
@ -254,7 +254,7 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback):
|
||||
self.top.connect_signals({
|
||||
"destroy_passed_object" : self.close,
|
||||
"on_help_clicked" : self.on_help_clicked,
|
||||
"on_verify_ok_clicked" : self.on_apply_clicked
|
||||
"on_verify_ok_clicked" : self.on_apply_clicked,
|
||||
"on_delete_event" : self.close,
|
||||
})
|
||||
|
||||
@ -562,7 +562,7 @@ class VerifyResults(ManagedWindow):
|
||||
button.set_label(_("_Hide marked"))
|
||||
|
||||
def selection_toggled(self,cell,path_string):
|
||||
sort_path = tuple([int (i) for i in path_string.split(':')])
|
||||
sort_path = tuple(map(int, path_string.split(':')))
|
||||
filt_path = self.sort_model.convert_path_to_child_path(sort_path)
|
||||
real_path = self.filt_model.convert_path_to_child_path(filt_path)
|
||||
row = self.real_model[real_path]
|
||||
|
Reference in New Issue
Block a user