diff --git a/src/DateHandler/_DateParser.py b/src/DateHandler/_DateParser.py index 089e703f3..e51c4734e 100644 --- a/src/DateHandler/_DateParser.py +++ b/src/DateHandler/_DateParser.py @@ -585,7 +585,7 @@ class DateParser(object): match = self._calny_iso.match(text) if match: cal = self.calendar_to_int[match.group(2).lower()] - newyear = tuple([int(s) for s in match.group(3).split("-")]) + newyear = tuple(map(int, match.group(3).split("-")) text = match.group(1) + match.group(4) return (text, cal, newyear) @@ -602,7 +602,7 @@ class DateParser(object): else: match = self._ny_iso.match(text) if match: - newyear = tuple([int(s) for s in match.group(2).split("-")]) + newyear = tuple(map(int, match.group(2).split("-")) text = match.group(1) + match.group(3) return (text, newyear) diff --git a/src/gen/db/read.py b/src/gen/db/read.py index 37169ab9f..36e571751 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -779,7 +779,7 @@ class DbBsddbRead(DbReadBase, Callback): """ Return the defined names that have been assigned to a default grouping. """ - return [unicode(k) for k in self.name_group.keys()] + return map(unicode, self.name_group.keys()) def has_name_group_key(self, name): """ diff --git a/src/gen/db/upgrade.py b/src/gen/db/upgrade.py index 554a9e5a6..40540267a 100644 --- a/src/gen/db/upgrade.py +++ b/src/gen/db/upgrade.py @@ -86,10 +86,9 @@ def gramps_upgrade_15(self): tags = [tag_handle] else: tags = [] - address_list = [convert_address(addr) for addr in address_list] + address_list = map(convert_address, address_list) new_primary_name = convert_name_15(primary_name) - new_alternate_names = [convert_name_15(altname) for altname in - alternate_names] + new_alternate_names = map(convert_name_15, alternate_names) new_person = (junk_handle, # 0 gramps_id, # 1 gender, # 2 @@ -193,7 +192,7 @@ def gramps_upgrade_15(self): new_place = list(place) if new_place[5] is not None: new_place[5] = convert_location(new_place[5]) - new_place[6] = [convert_location(loc) for loc in new_place[6]] + new_place[6] = map(convert_location, new_place[6]) new_place = new_place[:11] + new_place[12:] new_place = tuple(new_place) with BSDDBTxn(self.env, self.place_map) as txn: @@ -221,7 +220,7 @@ def gramps_upgrade_15(self): repository = self.repository_map[handle] new_repository = list(repository) new_repository = new_repository[:7] + new_repository[8:] - new_repository[5] = [convert_address(addr) for addr in new_repository[5]] + new_repository[5] = map(convert_address, new_repository[5]) new_repository = tuple(new_repository) with BSDDBTxn(self.env, self.repository_map) as txn: txn.put(str(handle), new_repository) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index cdc05dc74..77f91e224 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -1080,7 +1080,7 @@ class Date(object): code = Date.NEWYEAR_SEP1 elif "-" in string: try: - code = tuple([int(n) for n in string.split("-")]) + code = tuple(map(int, string.split("-"))) except: code = 0 else: diff --git a/src/gen/lib/place.py b/src/gen/lib/place.py index 1e75512b0..7ec88f6f2 100644 --- a/src/gen/lib/place.py +++ b/src/gen/lib/place.py @@ -68,7 +68,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject): self.lat = source.lat self.title = source.title self.main_loc = Location(source.main_loc) - self.alt_loc = [Location(loc) for loc in source.alt_loc] + self.alt_loc = map(Location, source.alt_loc) else: self.long = "" self.lat = "" diff --git a/src/gen/plug/_pluginreg.py b/src/gen/plug/_pluginreg.py index 4941c5832..9d4171987 100644 --- a/src/gen/plug/_pluginreg.py +++ b/src/gen/plug/_pluginreg.py @@ -161,12 +161,10 @@ def valid_plugin_version(plugin_version_string): if not isinstance(plugin_version_string, basestring): return False dots = plugin_version_string.count(".") if dots == 1: - plugin_version = tuple([int(n) for n in - plugin_version_string.split(".", 1)]) + plugin_version = tuple(map(int, plugin_version_string.split(".", 1))) return plugin_version == VERSION_TUPLE[:2] elif dots == 2: - plugin_version = tuple([int(n) for n in - plugin_version_string.split(".", 2)]) + plugin_version = tuple(map(int, plugin_version_string.split(".", 2))) return (plugin_version[:2] == VERSION_TUPLE[:2] and plugin_version <= VERSION_TUPLE) return False diff --git a/src/gen/plug/utils.py b/src/gen/plug/utils.py index e538a3ff1..81e84d49c 100644 --- a/src/gen/plug/utils.py +++ b/src/gen/plug/utils.py @@ -84,9 +84,8 @@ def version_str_to_tup(sversion, positions): (1, 2) """ try: - tup = tuple(([int(n) for n in - sversion.split(".", sversion.count("."))] + - [0] * positions)[0:positions]) + tup = tuple(map(int, sversion.split("."))) + tup += (0,) * (positions - len(tup)) except: tup = (0,) * positions return tup diff --git a/src/gui/filtereditor.py b/src/gui/filtereditor.py index addca77b5..758fa2f34 100644 --- a/src/gui/filtereditor.py +++ b/src/gui/filtereditor.py @@ -539,7 +539,7 @@ class EditRule(ManagedWindow.ManagedWindow): taglist = taglist + [tag.get_name() for tag in dbstate.db.iter_tags()] t = MyList(taglist, taglist) elif v == _('Confidence level:'): - t = MyList([str(i) for i in range(5)], + t = MyList(map(str, range(5)), [Utils.confidence[i] for i in range(5)]) else: t = MyEntry() diff --git a/src/plugins/docgen/PSDrawDoc.py b/src/plugins/docgen/PSDrawDoc.py index 6fde4eadd..d1d09fe80 100644 --- a/src/plugins/docgen/PSDrawDoc.py +++ b/src/plugins/docgen/PSDrawDoc.py @@ -270,7 +270,9 @@ class PSDrawDoc(BaseDoc, DrawDoc): self.file.write('[] 0 setdash\n') else: dash_style = stype.get_dash_style(stype.get_line_style()) - self.file.write('[%s] 0 setdash\n' % (" ".join([str(d) for d in dash_style]))) + self.file.write('[%s] 0 setdash\n' % ( + " ".join(map(str, dash_style))) + ) point = path[0] x1 = point[0] + self.paper.get_left_margin() @@ -311,7 +313,9 @@ class PSDrawDoc(BaseDoc, DrawDoc): self.file.write('[] 0 setdash\n') else: dash_style = stype.get_dash_style(stype.get_line_style()) - self.file.write('[%s] 0 setdash\n' % (" ".join([str(d) for d in dash_style]))) + self.file.write('[%s] 0 setdash\n' % ( + " ".join(map(str, dash_style))) + ) self.file.write( '2 setlinecap\n' + diff --git a/src/plugins/docgen/SvgDrawDoc.py b/src/plugins/docgen/SvgDrawDoc.py index 4aa55ce33..a56e82444 100644 --- a/src/plugins/docgen/SvgDrawDoc.py +++ b/src/plugins/docgen/SvgDrawDoc.py @@ -158,7 +158,9 @@ class SvgDrawDoc(BaseDoc, DrawDoc): line_out += 'x2="%4.2fcm" y2="%4.2fcm" ' % (x2, y2) line_out += 'style="stroke:#%02x%02x%02x; ' % s.get_color() if s.get_line_style() != SOLID: - line_out += 'stroke-dasharray: %s; ' % (",".join([str(d) for d in s.get_dash_style()])) + line_out += 'stroke-dasharray: %s; ' % ( + ",".join(map(str, s.get_dash_style())) + ) line_out += 'stroke-width:%.2fpt;"/>\n' % s.get_line_width() self.f.write(line_out) @@ -170,7 +172,9 @@ class SvgDrawDoc(BaseDoc, DrawDoc): line_out = ' 0: stab.row(person, length) matches += 1 + elif (filter_name == 'media references'): stab.columns(_("Person"), _("Reference")) for person in database.iter_people(): @@ -298,12 +327,14 @@ def run(database, document, filter_name, *args, **kwargs): for item in medialist: stab.row(person, _("media")) matches += 1 + elif (filter_name == 'unique media'): stab.columns(_("Unique Media")) for photo in database.iter_media_objects(): fullname = media_path_full(database, photo.get_path()) stab.row(fullname) matches += 1 + elif (filter_name == 'missing media'): stab.columns(_("Missing Media")) for photo in database.iter_media_objects(): @@ -313,6 +344,7 @@ def run(database, document, filter_name, *args, **kwargs): except: stab.row(fullname) matches += 1 + elif (filter_name == 'media by size'): stab.columns(_("Media"), _("Size in bytes")) for photo in database.iter_media_objects(): @@ -323,6 +355,7 @@ def run(database, document, filter_name, *args, **kwargs): matches += 1 except: pass + elif (filter_name == 'list of people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) handles = kwargs["handles"] @@ -331,6 +364,7 @@ def run(database, document, filter_name, *args, **kwargs): stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 + else: raise AttributeError, ("invalid filter name: '%s'" % filter_name) sdoc.paragraph(ngettext("Filter matched %d record."