Use built-in functions to replace for loops:
Old code: for x in y: f(x) New Code: map(f, y) Also use defaultdict instead of simple dict when advantageous and use list comprehensions instead of for loops where map() could be used but requires lambdas. svn: r14135
This commit is contained in:
@ -1301,9 +1301,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
person.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(person.remove_note, bad_handles)
|
||||
self.db.commit_person(person, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1318,9 +1317,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
family.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(family.remove_note, bad_handles)
|
||||
self.db.commit_family(family, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1335,9 +1333,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
place.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(place.remove_note, bad_handles)
|
||||
self.db.commit_place(place, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1355,6 +1352,7 @@ class CheckIntegrity(object):
|
||||
for bad_handle in bad_handles:
|
||||
source.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(source.remove_note, bad_handles)
|
||||
self.db.commit_source(source, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1369,9 +1367,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
obj.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(obj.remove_note, bad_handles)
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1386,9 +1383,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
event.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(event.remove_note, bad_handles)
|
||||
self.db.commit_event(event, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
@ -1403,9 +1399,8 @@ class CheckIntegrity(object):
|
||||
bad_handles = [ item[1] for item in handle_list
|
||||
if item[0] == 'Note' and
|
||||
item[1] not in known_handles ]
|
||||
for bad_handle in bad_handles:
|
||||
repo.remove_note(bad_handle)
|
||||
if bad_handles:
|
||||
map(repo.remove_note, bad_handles)
|
||||
self.db.commit_repository(repo, self.trans)
|
||||
new_bad_handles = [handle for handle in bad_handles if handle
|
||||
not in self.invalid_note_references]
|
||||
|
@ -103,10 +103,9 @@ class TableReport(object):
|
||||
def set_row(self,val):
|
||||
self.row = val + 2
|
||||
|
||||
def write_table_head(self,data):
|
||||
def write_table_head(self, data):
|
||||
self.doc.start_row()
|
||||
for item in data:
|
||||
self.doc.write_cell(item)
|
||||
map(self.doc.write_cell, data)
|
||||
self.doc.end_row()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
@ -129,8 +129,7 @@ class PHPGedViewConnector(object):
|
||||
result = []
|
||||
types = []
|
||||
if type == self.TYPE_ALL:
|
||||
for entry in self.type_trans:
|
||||
types.append(entry)
|
||||
types.extend(self.type_trans)
|
||||
else:
|
||||
types.append(type)
|
||||
for entry in types:
|
||||
|
Reference in New Issue
Block a user