diff --git a/gramps/plugins/lib/maps/__init__.py b/gramps/plugins/lib/maps/__init__.py
index 609e30a89..bee25a99e 100644
--- a/gramps/plugins/lib/maps/__init__.py
+++ b/gramps/plugins/lib/maps/__init__.py
@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2010-2012 Serge Noiraud
+# Copyright (C) 2010-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gramps/plugins/lib/maps/cairoprint.py b/gramps/plugins/lib/maps/cairoprint.py
index b78afa29a..718e2d6c4 100644
--- a/gramps/plugins/lib/maps/cairoprint.py
+++ b/gramps/plugins/lib/maps/cairoprint.py
@@ -2,7 +2,7 @@
#
# Copyright (C) 2001-2007 Donald N. Allingham, Martin Hawlisch
# Copyright (C) 2009 Douglas S. Blank
-# Copyright (C) 2009 Serge Noiraud
+# Copyright (C) 2009-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,9 +23,7 @@
# Python modules
#
#-------------------------------------------------------------------------
-from gi.repository import Gdk
from gi.repository import Gtk
-import cairo
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
@@ -38,13 +36,18 @@ _ = glocale.translation.gettext
# the print settings to remember between print sessions
PRINT_SETTINGS = None
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+# pylint: disable=unused-argument
+
#------------------------------------------------------------------------
#
# CairoPrintSave class
#
#------------------------------------------------------------------------
-class CairoPrintSave():
- """Act as an abstract document that can render onto a cairo context.
+class CairoPrintSave(object):
+ """
+ Act as an abstract document that can render onto a cairo context.
It can render the model onto cairo context pages, according to the received
page style.
@@ -64,9 +67,11 @@ class CairoPrintSave():
self.heightpx = heightpx
self.drawfunc = drawfunc
self.parent = parent
+ self.preview = None
def run(self):
- """Create the physical output from the meta document.
+ """
+ Create the physical output from the meta document.
"""
global PRINT_SETTINGS
@@ -79,7 +84,8 @@ class CairoPrintSave():
page_setup = Gtk.PageSetup()
if PRINT_SETTINGS is None:
PRINT_SETTINGS = Gtk.PrintSettings()
- page_setup = Gtk.print_run_page_setup_dialog(None, page_setup, PRINT_SETTINGS)
+ page_setup = Gtk.print_run_page_setup_dialog(None, page_setup,
+ PRINT_SETTINGS)
paper_size_used = page_setup.get_paper_size()
if self.widthpx > self.heightpx:
szw = self.widthpx
@@ -89,12 +95,13 @@ class CairoPrintSave():
szw = self.heightpx
height_used = paper_size_used.get_height(Gtk.Unit.POINTS)
width_used = paper_size_used.get_width(Gtk.Unit.POINTS)
- coefx = szw / height_used # width and height depends on the selected page (A4, A3, ...)
+ coefx = szw / height_used # width and height depends on the selected
+ # page (A4, A3, ...)
coefy = szh / width_used
if coefx < coefy:
- self.scale = 100.0 / coefy
+ self.scale = 100.0 / coefy
else:
- self.scale = 100.0 / coefx
+ self.scale = 100.0 / coefx
PRINT_SETTINGS.set_scale(self.scale)
if self.widthpx > self.heightpx:
page_setup.set_orientation(Gtk.PageOrientation.LANDSCAPE)
@@ -127,13 +134,14 @@ class CairoPrintSave():
def on_draw_page(self, operation, context, page_nr):
"""Draw a page on a Cairo context.
"""
- cr = context.get_cairo_context()
- self.drawfunc(self.parent, cr)
+ ctx = context.get_cairo_context()
+ self.drawfunc(self.parent, ctx)
def on_preview(self, operation, preview, context, parent):
"""Implement custom print preview functionality.
We provide a dummy holder here, because on_preview crashes if no
- default application is set with gir 3.3.2 (typically evince not installed)!
+ default application is set with gir 3.3.2 (typically evince not
+ installed)!
"""
operation.run(Gtk.PrintOperationAction.PREVIEW, None)
return False
diff --git a/gramps/plugins/lib/maps/constants.py b/gramps/plugins/lib/maps/constants.py
index 5e1057b18..391552351 100644
--- a/gramps/plugins/lib/maps/constants.py
+++ b/gramps/plugins/lib/maps/constants.py
@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2010-2012 Serge Noiraud
+# Copyright (C) 2010-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -39,6 +39,8 @@ from gi.repository import OsmGpsMap as osmgpsmap
#-------------------------------------------------------------------------
GEOGRAPHY_PATH = os.path.join(HOME_DIR, "maps")
+# pylint: disable=bad-whitespace
+
ICONS = {
EventType.BIRTH : 'gramps-geo-birth',
EventType.DEATH : 'gramps-geo-death',
@@ -63,7 +65,7 @@ YAHOO_STREET = 14
YAHOO_SATELLITE = 15
YAHOO_HYBRID = 16
-tiles_path = {
+TILES_PATH = {
OPENSTREETMAP : "openstreetmap",
OPENSTREETMAP_RENDERER : "openstreetmaprenderer",
OPENAERIALMAP : "openaerialmap",
@@ -82,7 +84,7 @@ tiles_path = {
YAHOO_HYBRID : "yahoohybrid",
}
-map_title = {
+MAP_TITLE = {
OPENSTREETMAP : "OpenStreetMap",
OPENSTREETMAP_RENDERER : "OpenStreetMap renderer",
OPENAERIALMAP : "OpenAerialMap",
@@ -101,22 +103,16 @@ map_title = {
YAHOO_HYBRID : "Yahoo hybrid",
}
-map_type = {
+MAP_TYPE = {
OPENSTREETMAP : osmgpsmap.MapSource_t.OPENSTREETMAP,
- #OPENSTREETMAP_RENDERER : osmgpsmap.MapSource_t.OPENSTREETMAP_RENDERER,
- #OPENAERIALMAP : osmgpsmap.MapSource_t.OPENAERIALMAP,
MAPS_FOR_FREE : osmgpsmap.MapSource_t.MAPS_FOR_FREE,
OPENCYCLEMAP : osmgpsmap.MapSource_t.OPENCYCLEMAP,
OSM_PUBLIC_TRANSPORT : osmgpsmap.MapSource_t.OSM_PUBLIC_TRANSPORT,
- #OSMC_TRAILS : osmgpsmap.MapSource_t.OSMC_TRAILS,
GOOGLE_STREET : osmgpsmap.MapSource_t.GOOGLE_STREET,
GOOGLE_SATELLITE : osmgpsmap.MapSource_t.GOOGLE_SATELLITE,
GOOGLE_HYBRID : osmgpsmap.MapSource_t.GOOGLE_HYBRID,
VIRTUAL_EARTH_STREET : osmgpsmap.MapSource_t.VIRTUAL_EARTH_STREET,
VIRTUAL_EARTH_SATELLITE : osmgpsmap.MapSource_t.VIRTUAL_EARTH_SATELLITE,
VIRTUAL_EARTH_HYBRID : osmgpsmap.MapSource_t.VIRTUAL_EARTH_HYBRID,
- #YAHOO_STREET : osmgpsmap.MapSource_t.YAHOO_STREET,
- #YAHOO_SATELLITE : osmgpsmap.MapSource_t.YAHOO_SATELLITE,
- #YAHOO_HYBRID : osmgpsmap.MapSource_t.YAHOO_HYBRID,
}
diff --git a/gramps/plugins/lib/maps/datelayer.py b/gramps/plugins/lib/maps/datelayer.py
index 59422db95..823a814ea 100644
--- a/gramps/plugins/lib/maps/datelayer.py
+++ b/gramps/plugins/lib/maps/datelayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,10 +25,7 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
-import operator
-from math import *
#------------------------------------------------------------------------
#
@@ -43,15 +40,14 @@ _LOG = logging.getLogger("maps.datelayer")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
-from gi.repository import Gtk
from gi.repository import Gdk
+import cairo
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
-import cairo
#-------------------------------------------------------------------------
#
@@ -66,9 +62,12 @@ try:
except:
raise
+# pylint: disable=unused-argument
+
class DateLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
- This is the layer used to display the two extreme dates on the top left of the view
+ This is the layer used to display the two extreme dates
+ on the top left of the view
"""
def __init__(self):
"""
diff --git a/gramps/plugins/lib/maps/dummylayer.py b/gramps/plugins/lib/maps/dummylayer.py
index 73b4a27ab..f0f1569bd 100644
--- a/gramps/plugins/lib/maps/dummylayer.py
+++ b/gramps/plugins/lib/maps/dummylayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
#------------------------------------------------------------------------
@@ -55,7 +54,12 @@ try:
except:
raise
+# pylint: disable=unused-argument
+
class DummyLayer(GObject.GObject, osmgpsmap.MapLayer):
+ """
+ This is the class for the Dummy layer.
+ """
def __init__(self):
"""
Initialize the dummy layer
diff --git a/gramps/plugins/lib/maps/dummynogps.py b/gramps/plugins/lib/maps/dummynogps.py
index dff9f215b..aa53899f8 100644
--- a/gramps/plugins/lib/maps/dummynogps.py
+++ b/gramps/plugins/lib/maps/dummynogps.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
#------------------------------------------------------------------------
@@ -56,7 +55,9 @@ except:
raise
class DummyMapNoGpsPoint(osmgpsmap.Map):
+ """ . """
def do_draw_gps_point(self, drawable):
+ """ . """
pass
GObject.type_register(DummyMapNoGpsPoint)
diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py
index bfc2fcaa7..34d0af059 100644
--- a/gramps/plugins/lib/maps/geography.py
+++ b/gramps/plugins/lib/maps/geography.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,12 +28,9 @@
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
import os
-import sys
import re
-from gi.repository import GObject
import time
from gi.repository import GLib
-from math import pi
#-------------------------------------------------------------------------
#
@@ -41,22 +38,19 @@ from math import pi
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
-from gi.repository import GdkPixbuf
-import cairo
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
-from gramps.gen.lib import EventType, Place, PlaceType, PlaceRef, PlaceName
+from gramps.gen.lib import EventType, Place, PlaceRef, PlaceName
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gui.views.navigationview import NavigationView
from gramps.gen.utils.libformatting import FormattingHelper
from gramps.gen.errors import WindowActiveError
-from gramps.gen.const import HOME_DIR, IMAGE_DIR
-from gramps.gui.managedwindow import ManagedWindow
+from gramps.gen.const import HOME_DIR
from gramps.gen.config import config
from gramps.gui.editors import EditPlace, EditEvent, EditFamily, EditPerson
from gramps.gui.selectors.selectplace import SelectPlace
@@ -94,6 +88,11 @@ GEOGRAPHY_PATH = os.path.join(HOME_DIR, "maps")
PLACE_REGEXP = re.compile('(.*)')
PLACE_STRING = '%s'
+# pylint: disable=unused-argument
+# pylint: disable=unused-variable
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+
def _get_sign(value):
"""
return 1 if we have a negative number, 0 in other case
@@ -134,6 +133,7 @@ class GeoGraphyView(OsmGps, NavigationView):
NavigationView.__init__(self, title, pdata, dbstate, uistate,
bm_type, nav_group)
+ OsmGps.__init__(self)
self.dbstate = dbstate
self.dbstate.connect('database-changed', self.change_db)
self.default_text = "Enter location here!"
@@ -141,9 +141,8 @@ class GeoGraphyView(OsmGps, NavigationView):
self.centerlat = config.get("geography.center-lat")
self.zoom = config.get("geography.zoom")
self.lock = config.get("geography.lock")
- if config.get('geography.path') == "" :
- config.set('geography.path', GEOGRAPHY_PATH )
- OsmGps.__init__(self)
+ if config.get('geography.path') == "":
+ config.set('geography.path', GEOGRAPHY_PATH)
self.format_helper = FormattingHelper(self.dbstate)
self.centerlat = self.centerlon = 0.0
@@ -159,23 +158,41 @@ class GeoGraphyView(OsmGps, NavigationView):
None, 0)
self.geo_altmap = theme.load_surface('gramps-geo-altmap', 48, 1,
None, 0)
- if ( config.get('geography.map_service') in
- ( constants.OPENSTREETMAP,
- constants.MAPS_FOR_FREE,
- constants.OPENCYCLEMAP,
- constants.OSM_PUBLIC_TRANSPORT,
+ if (config.get('geography.map_service') in
+ (constants.OPENSTREETMAP,
+ constants.MAPS_FOR_FREE,
+ constants.OPENCYCLEMAP,
+ constants.OSM_PUBLIC_TRANSPORT,
)):
default_image = self.geo_mainmap
else:
default_image = self.geo_altmap
self.geo_othermap = {}
- for ident in ( EventType.BIRTH,
- EventType.DEATH,
- EventType.MARRIAGE ):
+ for ident in (EventType.BIRTH,
+ EventType.DEATH,
+ EventType.MARRIAGE):
icon = constants.ICONS.get(int(ident))
self.geo_othermap[ident] = theme.load_surface(icon, 48, 1, None, 0)
+ self.maxyear = 0
+ self.minyear = 9999
+ self.maxlat = 0.0
+ self.minlat = 0.0
+ self.maxlon = 0.0
+ self.minlon = 0.0
+ self.longt = 0.0
+ self.latit = 0.0
+ self.itemoption = None
+ self.menu = None
+ self.mark = None
+ self.path_entry = None
+ self.changemap = None
+ self.clearmap = None
+ self.nbplaces = 0
def add_bookmark(self, menu):
+ """
+ Add the place to the bookmark
+ """
mlist = self.selected_handles()
if mlist:
self.bookmarks.add(mlist[0])
@@ -188,6 +205,9 @@ class GeoGraphyView(OsmGps, NavigationView):
def add_bookmark_from_popup(self, menu, handle):
+ """
+ Add the place to the bookmark from the popup menu
+ """
if handle:
self.uistate.set_active(handle, self.navigation_type())
self.bookmarks.add(handle)
@@ -320,7 +340,7 @@ class GeoGraphyView(OsmGps, NavigationView):
else:
title = _('Add cross hair')
add_item = Gtk.MenuItem(label=title)
- add_item.connect("activate", self.config_crosshair, event, lat , lon)
+ add_item.connect("activate", self.config_crosshair, event, lat, lon)
add_item.show()
menu.append(add_item)
@@ -330,27 +350,27 @@ class GeoGraphyView(OsmGps, NavigationView):
title = _('Lock zoom and position')
add_item = Gtk.MenuItem(label=title)
add_item.connect("activate", self.config_zoom_and_position,
- event, lat , lon)
+ event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Add place"))
- add_item.connect("activate", self.add_place, event, lat , lon)
+ add_item.connect("activate", self.add_place, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Link place"))
- add_item.connect("activate", self.link_place, event, lat , lon)
+ add_item.connect("activate", self.link_place, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Add place from kml"))
- add_item.connect("activate", self.add_place_from_kml, event, lat , lon)
+ add_item.connect("activate", self.add_place_from_kml, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Center here"))
- add_item.connect("activate", self.set_center, event, lat , lon)
+ add_item.connect("activate", self.set_center, event, lat, lon)
add_item.show()
menu.append(add_item)
@@ -361,7 +381,7 @@ class GeoGraphyView(OsmGps, NavigationView):
add_item.show()
menu.append(add_item)
- map_name = constants.map_title[config.get("geography.map_service")]
+ map_name = constants.MAP_TITLE[config.get("geography.map_service")]
title = _("Replace '%(map)s' by =>") % {
'map' : map_name
}
@@ -375,10 +395,10 @@ class GeoGraphyView(OsmGps, NavigationView):
changemap.show()
add_item.set_submenu(changemap)
# show in the map menu all available providers
- for map in constants.map_type:
- changemapitem = Gtk.MenuItem(label=constants.map_title[map])
+ for my_map in constants.MAP_TYPE:
+ changemapitem = Gtk.MenuItem(label=constants.MAP_TITLE[my_map])
changemapitem.show()
- changemapitem.connect("activate", self.change_map, map)
+ changemapitem.connect("activate", self.change_map, my_map)
changemap.append(changemapitem)
clear_text = _("Clear the '%(map)s' tiles cache.") % {
@@ -386,7 +406,9 @@ class GeoGraphyView(OsmGps, NavigationView):
}
self.clearmap = Gtk.MenuItem(label=clear_text)
clearmap = self.clearmap
- clearmap.connect("activate", self.clear_map, constants.tiles_path[config.get("geography.map_service")])
+ clearmap.connect("activate", self.clear_map,
+ constants.TILES_PATH[config.get(
+ "geography.map_service")])
clearmap.show()
menu.append(clearmap)
@@ -402,7 +424,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
import shutil
- path = "%s%c%s" % ( config.get('geography.path'), os.sep, the_map )
+ path = "%s%c%s" % (config.get('geography.path'), os.sep, the_map)
shutil.rmtree(path)
def add_specific_menu(self, menu, event, lat, lon):
@@ -450,22 +472,21 @@ class GeoGraphyView(OsmGps, NavigationView):
14 : 0.0005, 15 : 0.0003, 16 : 0.0001,
17 : 0.0001, 18 : 0.0001
}.get(config.get("geography.zoom"), 5.0)
- latp = precision % lat
- lonp = precision % lon
+ latp = precision % lat
+ lonp = precision % lon
mlatp = precision % float(mark[3])
mlonp = precision % float(mark[4])
latok = lonok = False
_LOG.debug(" compare latitude : %s with %s (precision = %s)"
- " place='%s'" % (float(mark[3]), lat, precision,
- mark[0]))
+ " place='%s'", float(mark[3]), lat, precision, mark[0])
_LOG.debug("compare longitude : %s with %s (precision = %s)"
- " zoom=%d" % (float(mark[4]), lon, precision,
- config.get("geography.zoom")))
- if (float(mlatp) >= (float(latp) - shift) ) and \
- (float(mlatp) <= (float(latp) + shift) ):
+ " zoom=%d", float(mark[4]), lon, precision,
+ config.get("geography.zoom"))
+ if (float(mlatp) >= (float(latp) - shift)) and \
+ (float(mlatp) <= (float(latp) + shift)):
latok = True
- if (float(mlonp) >= (float(lonp) - shift) ) and \
- (float(mlonp) <= (float(lonp) + shift) ):
+ if (float(mlonp) >= (float(lonp) - shift)) and \
+ (float(mlonp) <= (float(lonp) + shift)):
lonok = True
if latok and lonok:
mark_selected.append(mark)
@@ -499,8 +520,8 @@ class GeoGraphyView(OsmGps, NavigationView):
Add a new marker
"""
mapservice = config.get('geography.map_service')
- if ( mapservice in ( constants.OPENSTREETMAP,
- constants.OPENSTREETMAP_RENDERER )):
+ if (mapservice in (constants.OPENSTREETMAP,
+ constants.OPENSTREETMAP_RENDERER)):
default_image = self.geo_mainmap
else:
default_image = self.geo_altmap
@@ -544,7 +565,8 @@ class GeoGraphyView(OsmGps, NavigationView):
Create a list of places with coordinates.
"""
found = any(p[0] == place for p in self.places_found)
- if not found and self.nbplaces < self._config.get("geography.max_places"):
+ if not found and (self.nbplaces <
+ self._config.get("geography.max_places")):
# We only show the first "geography.max_places".
# over 3000 or 4000 places, the geography become unusable.
# In this case, filter the places ...
@@ -590,19 +612,19 @@ class GeoGraphyView(OsmGps, NavigationView):
self.remove_all_markers()
self.remove_all_gps()
self.remove_all_tracks()
- if ( self.current_map is not None and
- self.current_map != config.get("geography.map_service") ):
+ if (self.current_map is not None and
+ self.current_map != config.get("geography.map_service")):
self.change_map(self.osm, config.get("geography.map_service"))
last = ""
current = ""
differtype = False
- savetype = None
+ #savetype = None
lat = 0.0
lon = 0.0
icon = None
count = 0
self.uistate.set_busy_cursor(True)
- _LOG.debug("%s" % time.strftime("start create_marker : "
+ _LOG.debug("%s", time.strftime("start create_marker : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
for mark in self.sort:
current = ([mark[3], mark[4]])
@@ -626,10 +648,10 @@ class GeoGraphyView(OsmGps, NavigationView):
count += 1
if icon != mark[7]:
differtype = True
- if ( lat != 0.0 and lon != 0.0 ):
+ if lat != 0.0 and lon != 0.0:
self.add_marker(None, None, lat, lon, icon, differtype, count)
self._set_center_and_zoom()
- _LOG.debug("%s" % time.strftime(" stop create_marker : "
+ _LOG.debug("%s", time.strftime(" stop create_marker : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
self.uistate.set_busy_cursor(False)
@@ -646,17 +668,17 @@ class GeoGraphyView(OsmGps, NavigationView):
pt2 = bbox[1]
s_bbox_lat2 = pt2.rlat + 10.0
s_bbox_lon2 = pt2.rlon + 10.0
- result = ( s_bbox_lat1 > s_lat > s_bbox_lat2 ) and \
- ( s_bbox_lon1 < s_lon < s_bbox_lon2 )
+ result = ((s_bbox_lat1 > s_lat > s_bbox_lat2) and
+ (s_bbox_lon1 < s_lon < s_bbox_lon2))
return result
def _autozoom_in(self, lvl, p1lat, p1lon, p2lat, p2lon):
"""
We zoom in until at least one marker missing.
"""
- if ( ( self._visible_marker(p1lat, p1lon)
- and self._visible_marker(p2lat, p2lon) )
- and lvl < 18 ):
+ if ((self._visible_marker(p1lat, p1lon)
+ and self._visible_marker(p2lat, p2lon))
+ and lvl < 18):
lvl += 1
self.osm.set_zoom(lvl)
GLib.timeout_add(int(50), self._autozoom_in, lvl,
@@ -669,9 +691,9 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
We zoom out until all markers visible.
"""
- if ( not ( self._visible_marker(p1lat, p1lon)
- and self._visible_marker(p2lat, p2lon) )
- and lvl > 1 ):
+ if (not (self._visible_marker(p1lat, p1lon)
+ and self._visible_marker(p2lat, p2lon))
+ and lvl > 1):
lvl -= 1
self.osm.set_zoom(lvl)
GLib.timeout_add(int(50), self._autozoom_out, lvl,
@@ -691,8 +713,8 @@ class GeoGraphyView(OsmGps, NavigationView):
level_start = self.osm.props.zoom
p1lat, p1lon = self.begin_selection.get_degrees()
p2lat, p2lon = self.end_selection.get_degrees()
- lat = p1lat + ( p2lat - p1lat ) / 2
- lon = p1lon + ( p2lon - p1lon ) / 2
+ lat = p1lat + (p2lat - p1lat) / 2
+ lon = p1lon + (p2lon - p1lon) / 2
# We center the map on the center of the region
self.osm.set_center(lat, lon)
self.save_center(lat, lon)
@@ -733,7 +755,7 @@ class GeoGraphyView(OsmGps, NavigationView):
maxlat = abs(abs(self.minlat) + abs(self.maxlat))
latit = longt = 0.0
for mark in self.sort:
- if ( signminlat == signmaxlat ):
+ if signminlat == signmaxlat:
if signminlat == 1:
latit = self.minlat+self.centerlat
else:
@@ -742,7 +764,7 @@ class GeoGraphyView(OsmGps, NavigationView):
latit = self.maxlat-self.centerlat
else:
latit = self.minlat+self.centerlat
- if ( signminlon == signmaxlon ):
+ if signminlon == signmaxlon:
if signminlon == 1:
longt = self.minlon+self.centerlon
else:
@@ -759,7 +781,7 @@ class GeoGraphyView(OsmGps, NavigationView):
if config.get("geography.lock"):
self.osm.set_center_and_zoom(config.get("geography.center-lat"),
config.get("geography.center-lon"),
- config.get("geography.zoom") )
+ config.get("geography.zoom"))
else:
self._autozoom()
self.save_center(self.latit, self.longt)
@@ -789,7 +811,7 @@ class GeoGraphyView(OsmGps, NavigationView):
mother = dbstate.db.get_person_from_handle(handle)
fnam = _nd.display(father) if father else _("Unknown")
mnam = _nd.display(mother) if mother else _("Unknown")
- return ( fnam, mnam )
+ return (fnam, mnam)
#-------------------------------------------------------------------------
#
@@ -884,7 +906,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
Edit the selected person at the marker position
"""
- _LOG.debug("edit_person : %s" % mark[8])
+ _LOG.debug("edit_person : %s", mark[8])
# need to add code here to edit the person.
person = self.dbstate.db.get_person_from_gramps_id(mark[8])
try:
@@ -896,7 +918,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
Edit the selected family at the marker position
"""
- _LOG.debug("edit_family : %s" % mark[11])
+ _LOG.debug("edit_family : %s", mark[11])
family = self.dbstate.db.get_family_from_gramps_id(mark[11])
try:
EditFamily(self.dbstate, self.uistate, [], family)
@@ -907,7 +929,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
Edit the selected event at the marker position
"""
- _LOG.debug("edit_event : %s" % mark[10])
+ _LOG.debug("edit_event : %s", mark[10])
event = self.dbstate.db.get_event_from_gramps_id(mark[10])
try:
EditEvent(self.dbstate, self.uistate, [], event)
@@ -933,8 +955,8 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
# Ask for the kml file
- filter = Gtk.FileFilter()
- filter.add_pattern("*.kml")
+ filtering = Gtk.FileFilter()
+ filtering.add_pattern("*.kml")
kml = Gtk.FileChooserDialog(
_("Select a kml file used to add places"),
action=Gtk.FileChooserAction.OPEN,
@@ -943,7 +965,7 @@ class GeoGraphyView(OsmGps, NavigationView):
_('_Apply'), Gtk.ResponseType.OK))
mpath = HOME_DIR
kml.set_current_folder(os.path.dirname(mpath))
- kml.set_filter(filter)
+ kml.set_filter(filtering)
status = kml.run()
if status == Gtk.ResponseType.OK:
@@ -1167,20 +1189,27 @@ class GeoGraphyView(OsmGps, NavigationView):
(1000, 10000))
configdialog.add_checkbox(grid,
_('Use keypad for shortcuts :\n'
- 'Either we choose the + and - from the keypad if we select this,\n'
+ 'Either we choose the + and - from the keypad if we '
+ 'select this,\n'
'or we use the characters from the keyboard.'),
5, 'geography.use-keypad',
extra_callback=self.update_shortcuts)
return _('The map'), grid
def set_tilepath(self, *obj):
+ """
+ Save the tile path in the config section.
+ """
if self.path_entry.get_text().strip():
config.set('geography.path', self.path_entry.get_text())
else:
- config.set('geography.path', GEOGRAPHY_PATH )
+ config.set('geography.path', GEOGRAPHY_PATH)
def select_tilepath(self, *obj):
- f = Gtk.FileChooserDialog(
+ """
+ Call a file chooser selection box to select the tile path.
+ """
+ selected_dir = Gtk.FileChooserDialog(
_("Select tile cache directory for offline mode"),
action=Gtk.FileChooserAction.SELECT_FOLDER,
parent=self.uistate.window,
@@ -1191,12 +1220,11 @@ class GeoGraphyView(OsmGps, NavigationView):
mpath = config.get('geography.path')
if not mpath:
mpath = HOME_DIR
- f.set_current_folder(os.path.dirname(mpath))
+ selected_dir.set_current_folder(os.path.dirname(mpath))
- status = f.run()
+ status = selected_dir.run()
if status == Gtk.ResponseType.OK:
- val = f.get_filename()
+ val = selected_dir.get_filename()
if val:
self.path_entry.set_text(val)
- f.destroy()
-
+ selected_dir.destroy()
diff --git a/gramps/plugins/lib/maps/kmllayer.py b/gramps/plugins/lib/maps/kmllayer.py
index f7b879ebb..07422f639 100644
--- a/gramps/plugins/lib/maps/kmllayer.py
+++ b/gramps/plugins/lib/maps/kmllayer.py
@@ -20,18 +20,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# $Id: dummynogps.py 20708 2012-11-27 04:31:14Z paul-franklin $
-
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
-import os,sys
from gi.repository import GObject
-import operator
-from math import *
-import xml.etree.ElementTree as ETree
#------------------------------------------------------------------------
#
@@ -47,7 +41,6 @@ _LOG = logging.getLogger("maps.kmllayer")
#-------------------------------------------------------------------------
from gi.repository import Gdk
import cairo
-from gi.repository import Pango, PangoCairo
#-------------------------------------------------------------------------
#
@@ -69,14 +62,20 @@ try:
except:
raise
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+# pylint: disable=no-member
+
class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
This is the layer used to display kml files over the map
* Allowed : points, paths and polygons.
* One point : name, (latitude, longitude)
- * One path : name, type, color, transparency, [ (latitude, longitude), (latitude, longitude), ...]
- * One polygon : name, type, color, transparency, [ (latitude, longitude), (latitude, longitude), ...]
+ * One path : name, type, color, transparency,
+ * [ (latitude, longitude), (latitude, longitude), ...]
+ * One polygon : name, type, color, transparency,
+ * [ (latitude, longitude), (latitude, longitude), ...]
"""
def __init__(self):
"""
@@ -89,6 +88,7 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
self.name = ""
self.type = ""
self.points = []
+ self.kml = None
def clear(self):
"""
@@ -122,7 +122,8 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
map_points = []
for point in points:
conv_pt = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
- coord_x, coord_y = gpsmap.convert_geographic_to_screen(conv_pt)
+ (coord_x,
+ coord_y) = gpsmap.convert_geographic_to_screen(conv_pt)
map_points.append((coord_x, coord_y))
first = True
ctx.save()
@@ -137,9 +138,11 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
for idx_pt in range(0, len(map_points)):
if first:
first = False
- ctx.move_to(map_points[idx_pt][0], map_points[idx_pt][1])
+ ctx.move_to(map_points[idx_pt][0],
+ map_points[idx_pt][1])
else:
- ctx.line_to(map_points[idx_pt][0], map_points[idx_pt][1])
+ ctx.line_to(map_points[idx_pt][0],
+ map_points[idx_pt][1])
ctx.close_path()
if ptype == "Polygon":
ctx.stroke()
@@ -156,7 +159,8 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
map_points = []
for point in points:
conv_pt = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
- coord_x, coord_y = gpsmap.convert_geographic_to_screen(conv_pt)
+ (coord_x,
+ coord_y) = gpsmap.convert_geographic_to_screen(conv_pt)
map_points.append((coord_x, coord_y))
first = True
ctx.save()
@@ -169,9 +173,11 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
for idx_pt in range(0, len(map_points)):
if first:
first = False
- ctx.move_to(map_points[idx_pt][0], map_points[idx_pt][1])
+ ctx.move_to(map_points[idx_pt][0],
+ map_points[idx_pt][1])
else:
- ctx.line_to(map_points[idx_pt][0], map_points[idx_pt][1])
+ ctx.line_to(map_points[idx_pt][0],
+ map_points[idx_pt][1])
ctx.stroke()
ctx.restore()
diff --git a/gramps/plugins/lib/maps/libkml.py b/gramps/plugins/lib/maps/libkml.py
index d9af1195c..c1c4b514a 100644
--- a/gramps/plugins/lib/maps/libkml.py
+++ b/gramps/plugins/lib/maps/libkml.py
@@ -25,10 +25,8 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os,sys
+import os
from gi.repository import GObject
-import operator
-from math import *
import xml.etree.ElementTree as ETree
#------------------------------------------------------------------------
@@ -39,6 +37,8 @@ import xml.etree.ElementTree as ETree
import logging
_LOG = logging.getLogger("maps.libkml")
+# pylint: disable=unused-variable
+
class Kml(GObject.GObject):
"""
This is the library used to read kml files
@@ -46,7 +46,8 @@ class Kml(GObject.GObject):
* One point : name, (latitude, longitude)
* One path : name, [ (latitude, longitude), (latitude, longitude), ...]
- * One polygon : name, type, color, [ (latitude, longitude), (latitude, longitude), ...]
+ * One polygon : name, type, color,
+ * [ (latitude, longitude), (latitude, longitude), ...]
* Some kml files use the altitude. We don't use it.
@@ -54,7 +55,8 @@ class Kml(GObject.GObject):
def __init__(self, kml_file):
"""
Initialize the library
- The access right and validity of the kmlfile must be verified before this method.
+ The access right and validity of the kmlfile must be verified
+ before this method.
"""
GObject.GObject.__init__(self)
self.tag = ""
@@ -68,8 +70,8 @@ class Kml(GObject.GObject):
self.polygons = []
self.tree = ETree.parse(kml_file)
root = self.tree.getroot()
- self.tag = root.tag.replace('}kml','}')
- _LOG.debug("Tag version of kml file %s is %s" % (kml_file, self.tag))
+ self.tag = root.tag.replace('}kml', '}')
+ _LOG.debug("Tag version of kml file %s is %s", kml_file, self.tag)
fname, extension = os.path.splitext(kml_file)
fdir, self.kmlfile = os.path.split(fname)
@@ -110,49 +112,50 @@ class Kml(GObject.GObject):
"""
Get all the coordinates for this marker
"""
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'coordinates':
- self.get_coordinates(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'coordinates':
+ self.get_coordinates(sub_attribute)
def get_polygon_outer_boundary(self, attributes):
"""
This function get the coordinates used to draw a filled polygon.
"""
self.type = 'OuterPolygon'
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'LinearRing':
- self.get_linear_ring(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'LinearRing':
+ self.get_linear_ring(sub_attribute)
def get_polygon_inner_boundary(self, attributes):
"""
- This function get the coordinates used to draw a hole inside a filled polygon.
+ This function get the coordinates used to draw a hole inside
+ a filled polygon.
"""
self.type = 'InnerPolygon'
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'LinearRing':
- self.get_linear_ring(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'LinearRing':
+ self.get_linear_ring(sub_attribute)
def get_polygon(self, attributes):
"""
Get all the coordinates for the polygon
"""
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'outerBoundaryIs':
- self.get_polygon_outer_boundary(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'outerBoundaryIs':
+ self.get_polygon_outer_boundary(sub_attribute)
self.polygons.append((self.name,
self.type,
self.color,
self.transparency,
self.points))
- if subAttribute.tag == self.tag + 'innerBoundaryIs':
- self.get_polygon_inner_boundary(subAttribute)
+ if sub_attribute.tag == self.tag + 'innerBoundaryIs':
+ self.get_polygon_inner_boundary(sub_attribute)
self.polygons.append((self.name,
self.type,
self.color,
self.transparency,
self.points))
- if subAttribute.tag == self.tag + 'LinearRing':
- self.get_linear_ring(subAttribute)
+ if sub_attribute.tag == self.tag + 'LinearRing':
+ self.get_linear_ring(sub_attribute)
self.type = 'Polygon'
self.polygons.append((self.name,
self.type,
@@ -165,18 +168,18 @@ class Kml(GObject.GObject):
Get all the coordinates for this marker
"""
self.type = 'Point'
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'coordinates':
- self.get_coordinates(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'coordinates':
+ self.get_coordinates(sub_attribute)
def get_path(self, attributes):
"""
Get all the coordinates for this marker
"""
self.type = 'Path'
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'coordinates':
- self.get_coordinates(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'coordinates':
+ self.get_coordinates(sub_attribute)
self.paths.append((self.name,
self.type,
self.color,
@@ -184,45 +187,48 @@ class Kml(GObject.GObject):
self.points))
def get_multi_geometry(self, attributes):
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'Polygon':
- self.polygon(subAttribute)
- if subAttribute.tag == self.tag + 'LineString':
- self.get_path(subAttribute)
+ """
+ Do we have some sub structures ?
+ """
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'Polygon':
+ self.get_polygon(sub_attribute)
+ if sub_attribute.tag == self.tag + 'LineString':
+ self.get_path(sub_attribute)
def add_kml(self):
"""
Add a kml file.
"""
- lineStrings = self.tree.findall('.//' + self.tag + 'Placemark')
- for attributes in lineStrings:
+ line_strings = self.tree.findall('.//' + self.tag + 'Placemark')
+ for attributes in line_strings:
self.points = []
self.set_default()
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'name':
- self.name = subAttribute.text
- if subAttribute.tag == self.tag + 'Polygon':
- self.get_polygon(subAttribute)
- if subAttribute.tag == self.tag + 'LineString':
- self.get_path(subAttribute)
- if subAttribute.tag == self.tag + 'MultiGeometry':
- self.get_multi_geometry(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'name':
+ self.name = sub_attribute.text
+ if sub_attribute.tag == self.tag + 'Polygon':
+ self.get_polygon(sub_attribute)
+ if sub_attribute.tag == self.tag + 'LineString':
+ self.get_path(sub_attribute)
+ if sub_attribute.tag == self.tag + 'MultiGeometry':
+ self.get_multi_geometry(sub_attribute)
return (self.paths, self.polygons)
def add_points(self):
"""
Add points or markers
"""
- lineStrings = self.tree.findall('.//' + self.tag + 'Placemark')
+ line_strings = self.tree.findall('.//' + self.tag + 'Placemark')
self.markers = []
- for attributes in lineStrings:
+ for attributes in line_strings:
self.points = []
self.set_default()
- for subAttribute in attributes:
- if subAttribute.tag == self.tag + 'name':
- self.name = subAttribute.text
- if subAttribute.tag == self.tag + 'Point':
- self.get_point(subAttribute)
+ for sub_attribute in attributes:
+ if sub_attribute.tag == self.tag + 'name':
+ self.name = sub_attribute.text
+ if sub_attribute.tag == self.tag + 'Point':
+ self.get_point(sub_attribute)
self.markers.append((self.name, self.points))
return self.markers
diff --git a/gramps/plugins/lib/maps/lifewaylayer.py b/gramps/plugins/lib/maps/lifewaylayer.py
index 9809b1e53..84f9aa675 100644
--- a/gramps/plugins/lib/maps/lifewaylayer.py
+++ b/gramps/plugins/lib/maps/lifewaylayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,9 +25,8 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
-from math import *
+from math import pi
#------------------------------------------------------------------------
#
@@ -42,15 +41,14 @@ _LOG = logging.getLogger("maps.lifeway")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
-from gi.repository import Gtk
from gi.repository import Gdk
+import cairo
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
-import cairo
#-------------------------------------------------------------------------
#
@@ -65,6 +63,8 @@ try:
except:
raise
+# pylint: disable=unused-argument
+
class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
This is the layer used to display tracks or the life way for one or several
@@ -93,7 +93,7 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
alpha is the transparence
radius is the size of the track.
"""
- if isinstance(color,str):
+ if isinstance(color, str):
color = Gdk.color_parse(color)
self.lifeways_ref.append((points, color, radius))
@@ -101,7 +101,7 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
Add a track or life way.
"""
- if isinstance(color,str):
+ if isinstance(color, str):
color = Gdk.color_parse(color)
self.lifeways.append((points, color))
@@ -121,24 +121,29 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
rds = float(lifeway[2])
for point in lifeway[0]:
conv_pt1 = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
- coord_x1, coord_y1 = gpsmap.convert_geographic_to_screen(conv_pt1)
- conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0]+rds, point[1])
- coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(conv_pt2)
+ coord_x1, coord_y1 = gpsmap.convert_geographic_to_screen(
+ conv_pt1)
+ conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0]+rds,
+ point[1])
+ coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(
+ conv_pt2)
coy = abs(coord_y2-coord_y1)
- conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0], point[1]+rds)
- coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(conv_pt2)
+ conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0],
+ point[1]+rds)
+ coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(
+ conv_pt2)
cox = abs(coord_x2-coord_x1)
cox = cox if cox > 1.2 else 1.2
coy = coy if coy > 1.2 else 1.2
- coz = abs( 1.0 / float(cox) * float(coy) )
+ coz = abs(1.0 / float(cox) * float(coy))
coz = coz if coz > 1.2 else 1.2
ctx.save()
- ctx.scale(1.0,coz)
+ ctx.scale(1.0, coz)
ctx.move_to(coord_x1, coord_y1)
ctx.translate(coord_x1, coord_y1/coz)
ctx.arc(0.0, 0.0, cox, 0.0, 2*pi)
ctx.fill()
- ctx.set_source_rgba(1.0,0.0,0.0,0.5)
+ ctx.set_source_rgba(1.0, 0.0, 0.0, 0.5)
ctx.set_line_width(2.0)
ctx.arc(0.0, 0.0, cox, 0.0, 2*pi)
ctx.stroke()
@@ -164,7 +169,7 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
else:
ctx.line_to(map_points[idx_pt][0], map_points[idx_pt][1])
ctx.stroke()
- if len(map_points) == 1 : # We have only one point
+ if len(map_points) == 1: # We have only one point
crdx = map_points[0][0]
crdy = map_points[0][1]
ctx.move_to(crdx, crdy)
diff --git a/gramps/plugins/lib/maps/markerlayer.py b/gramps/plugins/lib/maps/markerlayer.py
index 94c64864c..ff5fe8916 100644
--- a/gramps/plugins/lib/maps/markerlayer.py
+++ b/gramps/plugins/lib/maps/markerlayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,9 +25,7 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
-from math import *
import time
#------------------------------------------------------------------------
@@ -37,15 +35,12 @@ import time
#------------------------------------------------------------------------
import logging
_LOG = logging.getLogger("maps.markerlayer")
-#_LOG = logging.getLogger("GeoGraphy.markerlayer")
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
-from gi.repository import Gtk
-import cairo
#-------------------------------------------------------------------------
#
@@ -66,6 +61,8 @@ try:
except:
raise
+# pylint: disable=unused-argument
+
class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
This is the layer used to display the markers.
@@ -121,7 +118,7 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
max_interval = 0.01
if min_interval == 0: # This to avoid divide by zero
min_interval = 0.01
- _LOG.debug("%s" % time.strftime("start drawing : "
+ _LOG.debug("%s", time.strftime("start drawing : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
for marker in self.markers:
ctx.save()
@@ -131,28 +128,28 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
if mark > self.nb_ref_by_places:
# at maximum, we'll have an icon size = (0.6 + 0.3) * 48 = 43.2
size += (0.3 * ((mark - self.nb_ref_by_places)
- / max_interval) )
+ / max_interval))
else:
# at minimum, we'll have an icon size = (0.6 - 0.3) * 48 = 14.4
size -= (0.3 * ((self.nb_ref_by_places - mark)
- / min_interval) )
+ / min_interval))
conv_pt = osmgpsmap.MapPoint.new_degrees(float(marker[0][0]),
- float(marker[0][1]))
+ float(marker[0][1]))
coord_x, coord_y = gpsmap.convert_geographic_to_screen(conv_pt)
ctx.translate(coord_x, coord_y)
- ctx.scale( size, size)
+ ctx.scale(size, size)
# below, we try to place exactly the marker depending on its size.
- # Normaly, the left top corner of the image is set to the coordinates.
+ # The left top corner of the image is set to the coordinates.
# The tip of the pin which should be at the marker position is at
# 3/18 of the width and to the height of the image.
# So we shift the image position.
- posY = - int( 48 * size + 0.5 ) - 10
- posX = - int(( 48 * size ) / 6 + 0.5 ) - 10
- ctx.set_source_surface(marker[1], posX, posY)
+ pos_y = - int(48 * size + 0.5) - 10
+ pos_x = - int((48 * size) / 6 + 0.5) - 10
+ ctx.set_source_surface(marker[1], pos_x, pos_y)
ctx.paint()
ctx.restore()
- _LOG.debug("%s" % time.strftime("end drawing : "
+ _LOG.debug("%s", time.strftime("end drawing : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
def do_render(self, gpsmap):
diff --git a/gramps/plugins/lib/maps/messagelayer.py b/gramps/plugins/lib/maps/messagelayer.py
index af3b542a7..d4d9ed962 100644
--- a/gramps/plugins/lib/maps/messagelayer.py
+++ b/gramps/plugins/lib/maps/messagelayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,10 +25,7 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from gi.repository import GObject
-import operator
-from math import *
#------------------------------------------------------------------------
#
@@ -44,7 +41,6 @@ _LOG = logging.getLogger("maps.messagelayer")
#
#-------------------------------------------------------------------------
from gi.repository import Gdk
-import cairo
from gi.repository import Pango, PangoCairo
#-------------------------------------------------------------------------
@@ -66,6 +62,10 @@ try:
except:
raise
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+# pylint: disable=no-member
+
class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
"""
This is the layer used to display messages over the map
diff --git a/gramps/plugins/lib/maps/osmgps.py b/gramps/plugins/lib/maps/osmgps.py
index b6b1419fe..aefb6eb6c 100644
--- a/gramps/plugins/lib/maps/osmgps.py
+++ b/gramps/plugins/lib/maps/osmgps.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,6 @@
#
#-------------------------------------------------------------------------
import os
-from gi.repository import GObject
#------------------------------------------------------------------------
#
@@ -78,7 +77,14 @@ try:
except:
raise
-class OsmGps():
+# pylint: disable=unused-argument
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+
+class OsmGps(object):
+ """
+ This class is used to create a map
+ """
def __init__(self):
"""
Initialize the map
@@ -111,7 +117,7 @@ class OsmGps():
os.makedirs(cache_path, 0o755) # create dir like mkdir -p
except:
ErrorDialog(_("Can't create tiles cache directory %s") %
- cache_path )
+ cache_path)
return self.vbox
self.change_map(None, config.get("geography.map_service"))
@@ -127,13 +133,13 @@ class OsmGps():
self.vbox.remove(self.osm)
self.osm.destroy()
tiles_path = os.path.join(config.get('geography.path'),
- constants.tiles_path[map_type])
+ constants.TILES_PATH[map_type])
if not os.path.isdir(tiles_path):
try:
os.makedirs(tiles_path, 0o755) # create dir like mkdir -p
except:
ErrorDialog(_("Can't create tiles cache directory for '%s'.") %
- constants.map_title[map_type])
+ constants.MAP_TITLE[map_type])
config.set("geography.map_service", map_type)
self.current_map = map_type
http_proxy = get_env_var('http_proxy')
@@ -143,12 +149,14 @@ class OsmGps():
if http_proxy:
self.osm = osmgpsmap.Map(tile_cache=tiles_path,
proxy_uri=http_proxy,
- map_source=constants.map_type[map_type])
+ map_source=constants.MAP_TYPE[
+ map_type])
else:
self.osm = osmgpsmap.Map(tile_cache=tiles_path,
- map_source=constants.map_type[map_type])
+ map_source=constants.MAP_TYPE[
+ map_type])
self.osm.props.tile_cache = osmgpsmap.MAP_CACHE_AUTO
- current_map = osmgpsmap.MapOsd( show_dpad=False, show_zoom=True)
+ current_map = osmgpsmap.MapOsd(show_dpad=False, show_zoom=True)
self.end_selection = None
self.osm.layer_add(current_map)
self.osm.layer_add(DummyLayer())
@@ -158,11 +166,11 @@ class OsmGps():
self.marker_layer = self.add_marker_layer()
self.date_layer = self.add_date_layer()
self.message_layer = self.add_message_layer()
- self.cross_map = osmgpsmap.MapOsd( show_crosshair=False)
+ self.cross_map = osmgpsmap.MapOsd(show_crosshair=False)
self.set_crosshair(config.get("geography.show_cross"))
self.osm.set_center_and_zoom(config.get("geography.center-lat"),
config.get("geography.center-lon"),
- config.get("geography.zoom") )
+ config.get("geography.zoom"))
self.osm.connect('button_release_event', self.map_clicked)
self.osm.connect('button_press_event', self.map_clicked)
@@ -176,21 +184,30 @@ class OsmGps():
def update_shortcuts(self, arg):
"""
connect the keyboard or the keypad for shortcuts
- arg is mandatory because this function is also called by the checkbox button
+ arg is mandatory because this function is also called by
+ the checkbox button
"""
config.set('geography.use-keypad',
self._config.get('geography.use-keypad'))
if config.get('geography.use-keypad'):
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN, Gdk.keyval_from_name("KP_Add"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT, Gdk.keyval_from_name("KP_Subtract"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN,
+ Gdk.keyval_from_name("KP_Add"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT,
+ Gdk.keyval_from_name("KP_Subtract"))
else:
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN, Gdk.keyval_from_name("plus"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT, Gdk.keyval_from_name("minus"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN,
+ Gdk.keyval_from_name("plus"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT,
+ Gdk.keyval_from_name("minus"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.UP, Gdk.keyval_from_name("Up"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.DOWN, Gdk.keyval_from_name("Down"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.LEFT, Gdk.keyval_from_name("Left"))
- self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.UP,
+ Gdk.keyval_from_name("Up"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.DOWN,
+ Gdk.keyval_from_name("Down"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.LEFT,
+ Gdk.keyval_from_name("Left"))
+ self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.RIGHT,
+ Gdk.keyval_from_name("Right"))
# For shortcuts work, we must grab the focus
self.osm.grab_focus()
@@ -296,7 +313,8 @@ class OsmGps():
"""
Moving during selection
"""
- current = osmmap.convert_screen_to_geographic(int(event.x), int(event.y))
+ current = osmmap.convert_screen_to_geographic(int(event.x),
+ int(event.y))
lat, lon = current.get_degrees()
if self.zone_selection:
# We draw a rectangle to show the selected region.
@@ -324,17 +342,17 @@ class OsmGps():
"""
Save the longitude and lontitude in case we switch between maps.
"""
- _LOG.debug("save_center : %s,%s" % (lat, lon) )
- if ( -90.0 < lat < +90.0 ) and ( -180.0 < lon < +180.0 ):
+ _LOG.debug("save_center : %s,%s", lat, lon)
+ if (-90.0 < lat < +90.0) and (-180.0 < lon < +180.0):
config.set("geography.center-lat", lat)
config.set("geography.center-lon", lon)
else:
- _LOG.debug("save_center : new coordinates : %s,%s" % (lat, lon) )
- _LOG.debug("save_center : old coordinates : %s,%s" % (lat, lon) )
+ _LOG.debug("save_center : new coordinates : %s,%s", lat, lon)
+ _LOG.debug("save_center : old coordinates : %s,%s", lat, lon)
# osmgpsmap bug ? reset to prior values to avoid osmgpsmap problems.
self.osm.set_center_and_zoom(config.get("geography.center-lat"),
config.get("geography.center-lon"),
- config.get("geography.zoom") )
+ config.get("geography.zoom"))
def activate_selection_zoom(self, osm, event):
"""
@@ -383,7 +401,7 @@ class OsmGps():
if self.no_show_places_in_status_bar:
return mark_selected
oldplace = ""
- _LOG.debug("%s" % time.strftime("start is_there_a_place_here : "
+ _LOG.debug("%s", time.strftime("start is_there_a_place_here : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
for mark in self.places_found:
# as we are not precise with our hand, reduce the precision
@@ -406,20 +424,20 @@ class OsmGps():
14 : 0.0005, 15 : 0.0003, 16 : 0.0001,
17 : 0.0001, 18 : 0.0001
}.get(config.get("geography.zoom"), 5.0)
- latp = precision % lat
- lonp = precision % lon
+ latp = precision % lat
+ lonp = precision % lon
mlatp = precision % float(mark[1])
mlonp = precision % float(mark[2])
latok = lonok = False
- if (float(mlatp) >= (float(latp) - shift) ) and \
- (float(mlatp) <= (float(latp) + shift) ):
+ if (float(mlatp) >= (float(latp) - shift)) and \
+ (float(mlatp) <= (float(latp) + shift)):
latok = True
- if (float(mlonp) >= (float(lonp) - shift) ) and \
- (float(mlonp) <= (float(lonp) + shift) ):
+ if (float(mlonp) >= (float(lonp) - shift)) and \
+ (float(mlonp) <= (float(lonp) + shift)):
lonok = True
if latok and lonok:
mark_selected.append(mark)
- _LOG.debug("%s" % time.strftime(" end is_there_a_place_here : "
+ _LOG.debug("%s", time.strftime(" end is_there_a_place_here : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
return mark_selected
@@ -441,9 +459,9 @@ class OsmGps():
"""
if active:
self.osm.layer_remove(self.cross_map)
- self.cross_map = osmgpsmap.MapOsd( show_crosshair=True)
- self.osm.layer_add( self.cross_map )
+ self.cross_map = osmgpsmap.MapOsd(show_crosshair=True)
+ self.osm.layer_add(self.cross_map)
else:
self.osm.layer_remove(self.cross_map)
- self.cross_map = osmgpsmap.MapOsd( show_crosshair=False)
- self.osm.layer_add( self.cross_map )
+ self.cross_map = osmgpsmap.MapOsd(show_crosshair=False)
+ self.osm.layer_add(self.cross_map)
diff --git a/gramps/plugins/lib/maps/placeselection.py b/gramps/plugins/lib/maps/placeselection.py
index d3bfde381..6c097f920 100644
--- a/gramps/plugins/lib/maps/placeselection.py
+++ b/gramps/plugins/lib/maps/placeselection.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
import re
-from gi.repository import GObject
import math
#------------------------------------------------------------------------
@@ -56,7 +55,6 @@ from gramps.gui.managedwindow import ManagedWindow
from .osmgps import OsmGps
from gramps.gen.utils.location import get_main_location
from gramps.gen.lib import PlaceType
-from gramps.gen.display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@@ -66,6 +64,9 @@ from gramps.gen.display.place import displayer as place_displayer
PLACE_REGEXP = re.compile('(.*)')
PLACE_STRING = '%s'
+# pylint: disable=unused-argument
+# pylint: disable=no-member
+
#-------------------------------------------------------------------------
#
# PlaceSelection
@@ -87,8 +88,10 @@ class PlaceSelection(ManagedWindow, OsmGps):
ManagedWindow.__init__(self, uistate, [], PlaceSelection)
except WindowActiveError:
return
+ OsmGps.__init__(self)
self.uistate = uistate
self.dbstate = dbstate
+ self.places = []
self.lat = lat
self.lon = lon
self.osm = maps
@@ -162,7 +165,8 @@ class PlaceSelection(ManagedWindow, OsmGps):
def slider_change(self, obj, lat, lon):
"""
- Display on the map a circle in which we select all the places inside this region.
+ Display on the map a circle in which we select all the places
+ inside this region.
"""
self.radius = obj.get_value() if obj else 1.0
self.show_the_region(self.radius)
@@ -183,14 +187,15 @@ class PlaceSelection(ManagedWindow, OsmGps):
)
for place in self.places:
if not place[0]:
- _LOG.info('No hierarchy yet: %s' % place)
+ _LOG.info('No hierarchy yet: %s', place)
continue
- p = (place[0], place[1], place[2], place[3], place[4])
- self.plist.append(p)
+ self.plist.append((place[0], place[1],
+ place[2], place[3], place[4]))
# here, we could add value from geography names services ...
# if we found no place, we must create a default place.
- self.plist.append((_("New place with empty fields"), "", "...", "", None))
+ self.plist.append((_("New place with empty fields"), "",
+ "...", "", None))
def hide_the_region(self):
"""
@@ -251,7 +256,8 @@ class PlaceSelection(ManagedWindow, OsmGps):
if (math.hypot(lat-float(entry[3]),
lon-float(entry[4])) <= rds) == True:
# Do we already have this place ? avoid duplicates
- country, state, county, place, other = self.get_location(entry[9])
+ (country, state, county,
+ place, other) = self.get_location(entry[9])
if not [country, state, county, place, other] in self.places:
self.places.append([country, state, county, place, other])
for place in self.dbstate.db.iter_places():
@@ -260,9 +266,12 @@ class PlaceSelection(ManagedWindow, OsmGps):
if latn and lonn:
if (math.hypot(lat-float(latn),
lon-float(lonn)) <= rds) == True:
- country, state, county, place, other = self.get_location(place.get_gramps_id())
- if not [country, state, county, place, other] in self.places:
- self.places.append([country, state, county, place, other])
+ (country, state, county,
+ place, other) = self.get_location(place.get_gramps_id())
+ if not [country, state, county,
+ place, other] in self.places:
+ self.places.append([country, state, county,
+ place, other])
def selection(self, obj, index, column, function):
"""
diff --git a/gramps/plugins/lib/maps/selectionlayer.py b/gramps/plugins/lib/maps/selectionlayer.py
index dcde19c02..f49268115 100644
--- a/gramps/plugins/lib/maps/selectionlayer.py
+++ b/gramps/plugins/lib/maps/selectionlayer.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011-2012 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
# Python modules
#
#-------------------------------------------------------------------------
-import os
from math import pi
from gi.repository import GObject
@@ -56,7 +55,12 @@ try:
except:
raise
+# pylint: disable=unused-argument
+
class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
+ """
+ This class is used to select an area on the map
+ """
def __init__(self):
"""
Initialize thz selection layer
@@ -108,16 +112,17 @@ class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
crd_x, crd_y = gpsmap.convert_geographic_to_screen(top_left)
crd_x2, crd_y2 = gpsmap.convert_geographic_to_screen(bottom_right)
# be sure when can select a region in all case.
- if ( crd_x < crd_x2 ):
- if ( crd_y < crd_y2 ):
+ if crd_x < crd_x2:
+ if crd_y < crd_y2:
ctx.rectangle(crd_x, crd_y, crd_x2 - crd_x, crd_y2 - crd_y)
else:
ctx.rectangle(crd_x, crd_y2, crd_x2 - crd_x, crd_y - crd_y2)
else:
- if ( crd_y < crd_y2 ):
+ if crd_y < crd_y2:
ctx.rectangle(crd_x2, crd_y, crd_x - crd_x2, crd_y2 - crd_y)
else:
- ctx.rectangle(crd_x2, crd_y2, crd_x - crd_x2, crd_y - crd_y2)
+ ctx.rectangle(crd_x2, crd_y2, crd_x - crd_x2,
+ crd_y - crd_y2)
ctx.stroke()
def do_render(self, gpsmap):
diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py
index 9caf3ce06..8c6ec02c9 100644
--- a/gramps/plugins/view/geoclose.py
+++ b/gramps/plugins/view/geoclose.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import operator
from gi.repository import Gtk
-from math import *
+from math import hypot
from html import escape
#-------------------------------------------------------------------------
@@ -105,6 +105,9 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=unused-argument
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -163,6 +166,9 @@ class GeoClose(GeoGraphyView):
self.place_list_ref = []
self.cal = config.get('preferences.calendar-format-report')
self.no_show_places_in_status_bar = False
+ self.add_item = None
+ self.newmenu = None
+ self.config_meeting_slider = None
def get_title(self):
"""
@@ -215,20 +221,22 @@ class GeoClose(GeoGraphyView):
self.message_layer.clear_messages()
active = self.get_active()
if active:
- p1 = self.dbstate.db.get_person_from_handle(active)
+ indiv1 = self.dbstate.db.get_person_from_handle(active)
color = self._config.get('geography.color2')
- self._createmap(p1, color, self.place_list_active, False)
+ self._createmap(indiv1, color, self.place_list_active, False)
if self.refperson:
color = self._config.get('geography.color1')
- self.message_layer.add_message(_("Reference : %(name)s ( %(birth)s - %(death)s )") % {
- 'name': _nd.display(self.refperson),
- 'birth': self.birth(self.refperson),
- 'death': self.death(self.refperson)})
- if p1:
- self.message_layer.add_message(_("The other : %(name)s ( %(birth)s - %(death)s )") % {
- 'name': _nd.display(p1),
- 'birth': self.birth(p1),
- 'death': self.death(p1)})
+ self.message_layer.add_message(
+ _("Reference : %(name)s ( %(birth)s - %(death)s )") % {
+ 'name': _nd.display(self.refperson),
+ 'birth': self.birth(self.refperson),
+ 'death': self.death(self.refperson)})
+ if indiv1:
+ self.message_layer.add_message(
+ _("The other : %(name)s ( %(birth)s - %(death)s )") % {
+ 'name': _nd.display(indiv1),
+ 'birth': self.birth(indiv1),
+ 'death': self.death(indiv1)})
else:
self.message_layer.add_message(_("The other person is unknown"))
self._createmap(self.refperson, color, self.place_list_ref, True)
@@ -236,10 +244,12 @@ class GeoClose(GeoGraphyView):
self.refperson_bookmark = self.refperson.get_handle()
self.add_bookmark_from_popup(None, self.refperson_bookmark)
else:
- self.message_layer.add_message(_("You must choose one reference person."))
+ self.message_layer.add_message(
+ _("You must choose one reference person."))
self.message_layer.add_message(_("Go to the person view and select "
"the people you want to compare. "
- "Return to this view and use the history."))
+ "Return to this view and use the"
+ " history."))
self.possible_meeting(self.place_list_ref, self.place_list_active)
self.uistate.modify_statusbar(self.dbstate)
@@ -286,13 +296,13 @@ class GeoClose(GeoGraphyView):
self.define_print_actions()
self.ref_person = Gtk.ActionGroup(name=self.title + '/Selection')
self.ref_person.add_actions([
- ('RefPerson', 'gramps-person', _('reference _Person'), None ,
+ ('RefPerson', 'gramps-person', _('reference _Person'), None,
_("Select the person which is the reference for life ways"),
- self.selectPerson),
+ self.select_person),
])
self._add_action_group(self.ref_person)
- def selectPerson(self, obj):
+ def select_person(self, obj):
"""
Open a selection box to choose the ref person.
"""
@@ -300,8 +310,8 @@ class GeoClose(GeoGraphyView):
self.skip_list = []
self.refperson = None
self.refperson_bookmark = None
- SelectPerson = SelectorFactory('Person')
- sel = SelectPerson(self.dbstate, self.uistate, self.track,
+ selectperson = SelectorFactory('Person')
+ sel = selectperson(self.dbstate, self.uistate, self.track,
_("Select the person which will be our reference."),
skip=self.skip_list)
self.refperson = sel.run()
@@ -342,7 +352,7 @@ class GeoClose(GeoGraphyView):
self.lifeway_layer.add_way(points, color)
if reference:
self.lifeway_layer.add_way_ref(points, 'orange',
- float(self._config.get("geography.maximum_meeting_zone")) / 10)
+ float(self._config.get("geography.maximum_meeting_zone")) / 10)
return False
def possible_meeting(self, place_list_ref, place_list_active):
@@ -405,7 +415,7 @@ class GeoClose(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr, evt,
_nd.display(person),
latitude, longitude,
@@ -433,7 +443,7 @@ class GeoClose(GeoGraphyView):
handle = fam.get_mother_handle()
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- descr1 = "%s%s" % ( descr1, _nd.display(mother))
+ descr1 = "%s%s" % (descr1, _nd.display(mother))
for event_ref in family.get_event_ref_list():
if event_ref:
event = dbstate.db.get_event_from_handle(
@@ -450,12 +460,12 @@ class GeoClose(GeoGraphyView):
latitude, longitude = conv_lat_lon(
latitude, longitude, "D.D8")
descr = _pd.display(dbstate.db, place)
- evt = EventType(
- event.get_type())
- eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
- if ( longitude and latitude ):
+ evt = EventType(event.get_type())
+ eyear = str(
+ "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
+ if longitude and latitude:
self._append_to_places_list(descr,
evt, _nd.display(person),
latitude, longitude,
@@ -467,13 +477,14 @@ class GeoClose(GeoGraphyView):
role
)
else:
- self._append_to_places_without_coord( place.gramps_id, descr)
+ self._append_to_places_without_coord(place.gramps_id, descr)
sort1 = sorted(self.place_list, key=operator.itemgetter(6))
self.draw(None, sort1, color, reference)
# merge with the last results
merge_list = []
- for the_list in self.sort, sort1 : merge_list += the_list
+ for the_list in self.sort, sort1:
+ merge_list += the_list
self.sort = sorted(merge_list, key=operator.itemgetter(6))
def bubble_message(self, event, lat, lon, marks):
@@ -489,7 +500,7 @@ class GeoClose(GeoGraphyView):
prevmark = None
for mark in marks:
for plce in self.all_place_list:
- if (plce[3] == mark[3] and plce[4] == mark[4]):
+ if plce[3] == mark[3] and plce[4] == mark[4]:
if plce[10] in events:
continue
else:
@@ -507,18 +518,19 @@ class GeoClose(GeoGraphyView):
date = displayer.display(evt.get_date_object())
if date == "":
date = _("Unknown")
- if ( plce[11] == EventRoleType.PRIMARY ):
- message = "(%s) %s : %s" % ( date, plce[2], plce[1] )
- elif ( plce[11] == EventRoleType.FAMILY ):
- (father_name, mother_name) = self._get_father_and_mother_name(evt)
+ if plce[11] == EventRoleType.PRIMARY:
+ message = "(%s) %s : %s" % (date, plce[2], plce[1])
+ elif plce[11] == EventRoleType.FAMILY:
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(evt)
message = "(%s) %s : %s - %s" % (date, plce[7],
father_name,
- mother_name )
+ mother_name)
else:
descr = evt.get_description()
if descr == "":
descr = _('No description')
- message = "(%s) %s => %s" % ( date, plce[11], descr)
+ message = "(%s) %s => %s" % (date, plce[11], descr)
prevmark = plce
self.add_item = Gtk.MenuItem(label=message)
add_item = self.add_item
@@ -551,8 +563,9 @@ class GeoClose(GeoGraphyView):
add_item = Gtk.MenuItem()
add_item.show()
menu.append(add_item)
- add_item = Gtk.MenuItem(label=_("Choose and bookmark the new reference person"))
- add_item.connect("activate", self.selectPerson)
+ add_item = Gtk.MenuItem(
+ label=_("Choose and bookmark the new reference person"))
+ add_item.connect("activate", self.select_person)
add_item.show()
menu.append(add_item)
return
diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py
index 440b3690e..698e25ddc 100644
--- a/gramps/plugins/view/geoevents.py
+++ b/gramps/plugins/view/geoevents.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,12 +28,9 @@ Geography for events
# Python modules
#
#-------------------------------------------------------------------------
-import os
-import sys
import operator
from gi.repository import Gdk
KEY_TAB = Gdk.KEY_Tab
-import socket
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -57,11 +54,6 @@ from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
-from gramps.gui.views.pageview import PageView
-from gramps.gui.editors import EditPlace
-from gramps.gui.selectors.selectplace import SelectPlace
-from gramps.gui.filters.sidebar import EventSidebarFilter
-from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import EventBookmarks
from gramps.plugins.lib.maps.geography import GeoGraphyView
from gramps.gui.utils import ProgressMeter
@@ -106,6 +98,10 @@ _UI_DEF = '''\
'''
+# pylint: disable=unused-argument
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -136,6 +132,7 @@ class GeoEvents(GeoGraphyView):
self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False
self.show_all = False
+ self.cal = None
def get_title(self):
"""
@@ -196,7 +193,7 @@ class GeoEvents(GeoGraphyView):
else:
self._createmap(None)
- def _createmap_for_one_event(self,event):
+ def _createmap_for_one_event(self, event):
"""
Create all markers for each people's event in the database which has
a lat/lon.
@@ -204,7 +201,7 @@ class GeoEvents(GeoGraphyView):
dbstate = self.dbstate
if self.nbplaces >= self._config.get("geography.max_places"):
return
- descr = descr2 = ""
+ descr1 = descr2 = ""
if event:
place_handle = event.get_place_handle()
eventyear = event.get_date_object().to_calendar(self.cal).get_year()
@@ -220,7 +217,7 @@ class GeoEvents(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
person_list = [
dbstate.db.get_person_from_handle(ref_handle)
for (ref_type, ref_handle) in
@@ -232,8 +229,8 @@ class GeoEvents(GeoGraphyView):
if descr2 == "":
descr2 = ("%s") % _nd.display(person)
else:
- descr2 = ("%s - %s") % ( descr2,
- _nd.display(person))
+ descr2 = ("%s - %s") % (descr2,
+ _nd.display(person))
else:
# family list ?
family_list = [
@@ -247,13 +244,15 @@ class GeoEvents(GeoGraphyView):
father = mother = None
hdle = family.get_father_handle()
if hdle:
- father = dbstate.db.get_person_from_handle(hdle)
+ father = dbstate.db.get_person_from_handle(
+ hdle)
hdle = family.get_mother_handle()
if hdle:
- mother = dbstate.db.get_person_from_handle(hdle)
+ mother = dbstate.db.get_person_from_handle(
+ hdle)
descr2 = ("%(father)s - %(mother)s") % {
- 'father': _nd.display(father) if father is not None else "?",
- 'mother': _nd.display(mother) if mother is not None else "?"
+ 'father': _nd.display(father) if father is not None else "?",
+ 'mother': _nd.display(mother) if mother is not None else "?"
}
else:
descr2 = _("incomplete or unreferenced event ?")
@@ -269,7 +268,7 @@ class GeoEvents(GeoGraphyView):
None
)
- def _createmap(self,obj):
+ def _createmap(self, obj):
"""
Create all markers for each people's event in the database which has
a lat/lon.
@@ -283,8 +282,6 @@ class GeoEvents(GeoGraphyView):
self.maxyear = 0
self.nbmarkers = 0
self.nbplaces = 0
- latitude = ""
- longitude = ""
self.without = 0
self.cal = config.get('preferences.calendar-format-report')
self.no_show_places_in_status_bar = False
@@ -317,7 +314,7 @@ class GeoEvents(GeoGraphyView):
self.sort = sorted(self.place_list,
key=operator.itemgetter(3, 4, 6)
)
- if self.nbmarkers > 500 : # performance issue. Is it the good value ?
+ if self.nbmarkers > 500: # performance issue. Is it the good value ?
self.no_show_places_in_status_bar = True
self._create_markers()
@@ -362,7 +359,7 @@ class GeoEvents(GeoGraphyView):
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
# format the date as described in preferences.
date = displayer.display(evt.get_date_object())
- message = "(%s) %s : %s" % (date, EventType( mark[7] ), mark[5] )
+ message = "(%s) %s : %s" % (date, EventType(mark[7]), mark[5])
prevmark = mark
add_item = Gtk.MenuItem(label=message)
add_item.show()
@@ -398,7 +395,7 @@ class GeoEvents(GeoGraphyView):
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Show all events"))
- add_item.connect("activate", self.show_all_events, event, lat , lon)
+ add_item.connect("activate", self.show_all_events, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Centering on Place"))
@@ -415,7 +412,8 @@ class GeoEvents(GeoGraphyView):
oldplace = mark[0]
modify = Gtk.MenuItem(label=mark[0])
modify.show()
- modify.connect("activate", self.goto_place, float(mark[3]), float(mark[4]))
+ modify.connect("activate", self.goto_place,
+ float(mark[3]), float(mark[4]))
itemoption.append(modify)
def goto_place(self, obj, lat, lon):
diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py
index 8854d3085..a5eb58530 100644
--- a/gramps/plugins/view/geofamclose.py
+++ b/gramps/plugins/view/geofamclose.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import operator
from gi.repository import Gtk
-from math import *
+from math import hypot
#-------------------------------------------------------------------------
#
@@ -103,6 +103,10 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -135,10 +139,10 @@ class GeoFamClose(GeoGraphyView):
)
def __init__(self, pdata, dbstate, uistate, nav_group=0):
- GeoGraphyView.__init__(self, _("Have these two families been able to meet?"),
- pdata, dbstate, uistate,
- FamilyBookmarks,
- nav_group)
+ GeoGraphyView.__init__(self,
+ _("Have these two families been able to meet?"),
+ pdata, dbstate, uistate,
+ FamilyBookmarks, nav_group)
self.dbstate = dbstate
self.uistate = uistate
self.place_list = []
@@ -161,6 +165,7 @@ class GeoFamClose(GeoGraphyView):
self.place_list_ref = []
self.cal = config.get('preferences.calendar-format-report')
self.no_show_places_in_status_bar = False
+ self.config_meeting_slider = None
def get_title(self):
"""
@@ -195,30 +200,33 @@ class GeoFamClose(GeoGraphyView):
"""
return 'Family'
- def family_label(self,family):
+ def family_label(self, family):
+ """
+ Create the family label depending on existence of father and mother
+ """
if family is None:
return "Unknown"
- f = m = None
+ father = mother = None
hdl = family.get_father_handle()
if hdl:
- f = self.dbstate.db.get_person_from_handle(hdl)
+ father = self.dbstate.db.get_person_from_handle(hdl)
hdl = family.get_mother_handle()
if hdl:
- m = self.dbstate.db.get_person_from_handle(hdl)
- if f and m:
+ mother = self.dbstate.db.get_person_from_handle(hdl)
+ if father and mother:
label = _("%(gramps_id)s : %(father)s and %(mother)s") % {
- 'father' : _nd.display(f),
- 'mother' : _nd.display(m),
+ 'father' : _nd.display(father),
+ 'mother' : _nd.display(mother),
'gramps_id' : family.gramps_id,
}
- elif f:
+ elif father:
label = "%(gramps_id)s : %(father)s" % {
- 'father' : _nd.display(f),
+ 'father' : _nd.display(father),
'gramps_id' : family.gramps_id,
}
- elif m:
+ elif mother:
label = "%(gramps_id)s : %(mother)s" % {
- 'mother' : _nd.display(m),
+ 'mother' : _nd.display(mother),
'gramps_id' : family.gramps_id,
}
else:
@@ -245,29 +253,35 @@ class GeoFamClose(GeoGraphyView):
self.lifeway_layer.clear_ways()
self.message_layer.clear_messages()
active = self.get_active()
- f1 = None
+ family = None
if active:
- f1 = self.dbstate.db.get_family_from_handle(active)
+ family = self.dbstate.db.get_family_from_handle(active)
color = self._config.get('geography.color2')
- self._createmap(f1, color, self.place_list_active, False)
+ self._createmap(family, color, self.place_list_active, False)
if self.reffamily:
color = self._config.get('geography.color1')
self._createmap(self.reffamily, color, self.place_list_ref, True)
- self.message_layer.add_message(_("Family reference : %s" % self.family_label(self.reffamily)))
- if f1:
- self.message_layer.add_message(_("The other family : %s" % self.family_label(f1)))
+ self.message_layer.add_message(
+ _("Family reference : %s" % self.family_label(self.reffamily)))
+ if family:
+ self.message_layer.add_message(
+ _("The other family : %s" % self.family_label(
+ family)))
else:
- self.message_layer.add_message(_("The other family : %s" % _("Unknown")))
+ self.message_layer.add_message(
+ _("The other family : %s" % _("Unknown")))
if self.reffamily_bookmark is None:
self.reffamily_bookmark = self.reffamily.get_handle()
self.add_bookmark_from_popup(None, self.reffamily_bookmark)
else:
- self.message_layer.add_message(_("You must choose one reference family."))
- self.message_layer.add_message(_("Go to the family view and select "
- "the families you want to compare. "
- "Return to this view and use the history."))
- if f1 is not None:
- self._possible_family_meeting(self.reffamily, f1)
+ self.message_layer.add_message(
+ _("You must choose one reference family."))
+ self.message_layer.add_message(
+ _("Go to the family view and select "
+ "the families you want to compare. "
+ "Return to this view and use the history."))
+ if family is not None:
+ self._possible_family_meeting(self.reffamily, family)
self.uistate.modify_statusbar(self.dbstate)
def define_actions(self):
@@ -279,13 +293,13 @@ class GeoFamClose(GeoGraphyView):
self.define_print_actions()
self.ref_family = Gtk.ActionGroup(self.title + '/Selection')
self.ref_family.add_actions([
- ('RefFamily', 'gramps-family', _('reference _Family'), None ,
+ ('RefFamily', 'gramps-family', _('reference _Family'), None,
_("Select the family which is the reference for life ways"),
- self.selectFamily),
+ self.select_family),
])
self._add_action_group(self.ref_family)
- def selectFamily(self, obj):
+ def select_family(self, obj):
"""
Open a selection box to choose the ref family.
"""
@@ -293,8 +307,8 @@ class GeoFamClose(GeoGraphyView):
self.skip_list = []
self.ref_family = None
self.reffamily_bookmark = None
- selectFamily = SelectorFactory('Family')
- sel = selectFamily(self.dbstate, self.uistate)
+ select_family = SelectorFactory('Family')
+ sel = select_family(self.dbstate, self.uistate)
self.reffamily = sel.run()
self.goto_handle(None)
@@ -332,18 +346,19 @@ class GeoFamClose(GeoGraphyView):
self.lifeway_layer.add_way(points, color)
if reference:
self.lifeway_layer.add_way_ref(points, 'orange',
- float(self._config.get("geography.maximum_meeting_zone")) / 10)
+ float(
+ self._config.get("geography.maximum_meeting_zone")) / 10)
return False
def _place_list_for_person(self, person):
"""
get place list for one person
"""
- list = []
+ place_list = []
for event in self.sort:
- if ( event[1] == _nd.display(person)):
- list.append(event)
- return list
+ if event[1] == _nd.display(person):
+ place_list.append(event)
+ return place_list
def possible_meeting(self, ref_person, person):
"""
@@ -370,11 +385,13 @@ class GeoFamClose(GeoGraphyView):
"""
dbstate = self.dbstate
try:
- person = dbstate.db.get_person_from_handle(family.get_father_handle())
+ person = dbstate.db.get_person_from_handle(
+ family.get_father_handle())
except:
return
if person is None: # family without father ?
- person = dbstate.db.get_person_from_handle(family.get_mother_handle())
+ person = dbstate.db.get_person_from_handle(
+ family.get_mother_handle())
if person is not None:
family_list = person.get_family_handle_list()
if len(family_list) > 0:
@@ -408,7 +425,8 @@ class GeoFamClose(GeoGraphyView):
dbstate = self.dbstate
person = None
try:
- person = dbstate.db.get_person_from_handle(reference.get_father_handle())
+ person = dbstate.db.get_person_from_handle(
+ reference.get_father_handle())
except:
return
if person is None: # family without father ?
@@ -464,8 +482,8 @@ class GeoFamClose(GeoGraphyView):
except:
continue
eyear = str("%04d" % date.get_year()) + \
- str("%02d" % date.get_month()) + \
- str("%02d" % date.get_day())
+ str("%02d" % date.get_month()) + \
+ str("%02d" % date.get_day())
place_handle = event.get_place_handle()
if place_handle:
place = dbstate.db.get_place_from_handle(place_handle)
@@ -482,7 +500,7 @@ class GeoFamClose(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr, evt,
_nd.display(person),
latitude, longitude,
@@ -513,7 +531,7 @@ class GeoFamClose(GeoGraphyView):
if handle:
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- descr1 = "%s%s" % ( descr1, _nd.display(mother))
+ descr1 = "%s%s" % (descr1, _nd.display(mother))
for event_ref in family.get_event_ref_list():
if event_ref:
event = dbstate.db.get_event_from_handle(
@@ -532,10 +550,11 @@ class GeoFamClose(GeoGraphyView):
descr = _pd.display(dbstate.db, place)
evt = EventType(
event.get_type())
- eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
- if ( longitude and latitude ):
+ eyear = str(
+ "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
+ if longitude and latitude:
self._append_to_places_list(descr,
evt, _nd.display(person),
latitude, longitude,
@@ -547,13 +566,14 @@ class GeoFamClose(GeoGraphyView):
role
)
else:
- self._append_to_places_without_coord( place.gramps_id, descr)
+ self._append_to_places_without_coord(place.gramps_id, descr)
sort1 = sorted(self.place_list, key=operator.itemgetter(6))
self.draw(None, sort1, color, reference)
# merge with the last results
merge_list = []
- for the_list in self.sort, sort1 : merge_list += the_list
+ for the_list in self.sort, sort1:
+ merge_list += the_list
self.sort = sorted(merge_list, key=operator.itemgetter(6))
def _createmap_for_one_family(self, family, color, place_list, reference):
@@ -563,7 +583,8 @@ class GeoFamClose(GeoGraphyView):
dbstate = self.dbstate
person = None
try:
- person = dbstate.db.get_person_from_handle(family.get_father_handle())
+ person = dbstate.db.get_person_from_handle(
+ family.get_father_handle())
except:
return
family_id = family.gramps_id
@@ -585,16 +606,20 @@ class GeoFamClose(GeoGraphyView):
if handle:
father = dbstate.db.get_person_from_handle(handle)
if father:
- comment = _("Father : %(id)s : %(name)s") % {'id': father.gramps_id,
- 'name': _nd.display(father)}
- self._createmap_for_one_person(father, color, place_list, reference)
+ comment = _("Father : %(id)s : %(name)s") % {
+ 'id': father.gramps_id,
+ 'name': _nd.display(father)}
+ self._createmap_for_one_person(father, color,
+ place_list, reference)
handle = fam.get_mother_handle()
if handle:
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- comment = _("Mother : %(id)s : %(name)s") % {'id': mother.gramps_id,
- 'name': _nd.display(mother)}
- self._createmap_for_one_person(mother, color, place_list, reference)
+ comment = _("Mother : %(id)s : %(name)s") % {
+ 'id': mother.gramps_id,
+ 'name': _nd.display(mother)}
+ self._createmap_for_one_person(mother, color,
+ place_list, reference)
index = 0
child_ref_list = fam.get_child_ref_list()
if child_ref_list:
@@ -608,13 +633,16 @@ class GeoFamClose(GeoGraphyView):
'index' : index,
'name' : _nd.display(child)
}
- self._createmap_for_one_person(child, color, place_list, reference)
+ self._createmap_for_one_person(child, color,
+ place_list,
+ reference)
else:
comment = _("Person : %(id)s %(name)s has no family.") % {
- 'id' : person.gramps_id ,
+ 'id' : person.gramps_id,
'name' : _nd.display(person)
}
- self._createmap_for_one_person(person, color, place_list, reference)
+ self._createmap_for_one_person(person, color,
+ place_list, reference)
def _createmap(self, family_x, color, place_list, reference):
"""
@@ -646,7 +674,8 @@ class GeoFamClose(GeoGraphyView):
for family_hdl in family_list:
family = self.dbstate.db.get_family_from_handle(family_hdl)
if family is not None:
- self._createmap_for_one_family(family, color, place_list, reference)
+ self._createmap_for_one_family(family, color,
+ place_list, reference)
else:
self._createmap_for_one_family(family, color, place_list, reference)
#self._create_markers()
@@ -664,7 +693,7 @@ class GeoFamClose(GeoGraphyView):
prevmark = None
for mark in marks:
for plce in self.all_place_list:
- if (plce[3] == mark[3] and plce[4] == mark[4]):
+ if plce[3] == mark[3] and plce[4] == mark[4]:
if plce[10] in events:
continue
else:
@@ -682,18 +711,19 @@ class GeoFamClose(GeoGraphyView):
date = displayer.display(evt.get_date_object())
if date == "":
date = _("Unknown")
- if ( plce[11] == EventRoleType.PRIMARY ):
- message = "(%s) %s : %s" % ( date, plce[2], plce[1] )
- elif ( plce[11] == EventRoleType.FAMILY ):
- (father_name, mother_name) = self._get_father_and_mother_name(evt)
+ if plce[11] == EventRoleType.PRIMARY:
+ message = "(%s) %s : %s" % (date, plce[2], plce[1])
+ elif plce[11] == EventRoleType.FAMILY:
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(evt)
message = "(%s) %s : %s - %s" % (date, plce[7],
father_name,
- mother_name )
+ mother_name)
else:
descr = evt.get_description()
if descr == "":
descr = _('No description')
- message = "(%s) %s => %s" % ( date, plce[11], descr)
+ message = "(%s) %s => %s" % (date, plce[11], descr)
prevmark = plce
add_item = Gtk.MenuItem(label=message)
add_item.show()
@@ -725,8 +755,9 @@ class GeoFamClose(GeoGraphyView):
add_item = Gtk.MenuItem()
add_item.show()
menu.append(add_item)
- add_item = Gtk.MenuItem(label=_("Choose and bookmark the new reference family"))
- add_item.connect("activate", self.selectFamily)
+ add_item = Gtk.MenuItem(
+ label=_("Choose and bookmark the new reference family"))
+ add_item.connect("activate", self.select_family)
add_item.show()
menu.append(add_item)
return
diff --git a/gramps/plugins/view/geofamily.py b/gramps/plugins/view/geofamily.py
index 65cc53998..78825118b 100644
--- a/gramps/plugins/view/geofamily.py
+++ b/gramps/plugins/view/geofamily.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,12 +28,9 @@ Geography for one family
# Python modules
#
#-------------------------------------------------------------------------
-import os
-import sys
import operator
from gi.repository import Gdk
KEY_TAB = Gdk.KEY_Tab
-import socket
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -57,11 +54,6 @@ from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
-from gramps.gui.views.pageview import PageView
-from gramps.gui.editors import EditPlace
-from gramps.gui.selectors.selectplace import SelectPlace
-from gramps.gui.filters.sidebar import FamilySidebarFilter
-from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import FamilyBookmarks
from gramps.plugins.lib.maps.geography import GeoGraphyView
@@ -105,6 +97,10 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -112,7 +108,7 @@ _UI_DEF = '''\
#-------------------------------------------------------------------------
class GeoFamily(GeoGraphyView):
"""
- The view used to render person map.
+ The view used to render family map.
"""
def __init__(self, pdata, dbstate, uistate, nav_group=0):
@@ -132,6 +128,7 @@ class GeoFamily(GeoGraphyView):
self.sort = []
self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False
+ self.cal = None
def get_title(self):
"""
@@ -213,8 +210,9 @@ class GeoFamily(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
- if not self._present_in_places_list(2, str(descr1 + descr + str(evt))):
+ if longitude and latitude:
+ if not self._present_in_places_list(2,
+ str(descr1 + descr + str(evt))):
self._append_to_places_list(descr,
str(descr1 + descr + str(evt)),
_nd.display(person),
@@ -235,63 +233,74 @@ class GeoFamily(GeoGraphyView):
if family is not None:
for event_ref in family.get_event_ref_list():
if event_ref:
- event = dbstate.db.get_event_from_handle(event_ref.ref)
+ event = dbstate.db.get_event_from_handle(
+ event_ref.ref)
role = event_ref.get_role()
if event.get_place_handle():
place_handle = event.get_place_handle()
if place_handle:
- place = dbstate.db.get_place_from_handle(place_handle)
+ place = dbstate.db.get_place_from_handle(
+ place_handle)
if place:
longitude = place.get_longitude()
latitude = place.get_latitude()
- latitude, longitude = conv_lat_lon(latitude,
- longitude, "D.D8")
+ (latitude,
+ longitude) = conv_lat_lon(latitude,
+ longitude,
+ "D.D8")
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
- (father_name, mother_name) = self._get_father_and_mother_name(event)
- descr1 = "%s : %s - " % ( evt, father_name )
- descr1 = "%s%s" % ( descr1, mother_name )
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(event)
+ descr1 = "%s : %s - " % (evt,
+ father_name)
+ descr1 = "%s%s" % (descr1, mother_name)
eyear = event.get_date_object().to_calendar(self.cal).get_year()
- if ( longitude and latitude ):
- if not self._present_in_places_list(2, str(descr1 + descr + str(evt))):
- self._append_to_places_list(descr,
- str(descr1 + descr + str(evt)),
- _nd.display(person),
- latitude, longitude,
- role, eyear,
- event.get_type(),
- person.gramps_id,
- place.gramps_id,
- event.gramps_id,
- family.gramps_id
- )
+ if longitude and latitude:
+ if not self._present_in_places_list(
+ 2, str(descr1 + descr + str(evt))):
+ self._append_to_places_list(
+ descr,
+ str(descr1 + descr + str(evt)),
+ _nd.display(person),
+ latitude, longitude,
+ role, eyear,
+ event.get_type(),
+ person.gramps_id,
+ place.gramps_id,
+ event.gramps_id,
+ family.gramps_id
+ )
else:
- self._append_to_places_without_coord( place.gramps_id, descr)
+ self._append_to_places_without_coord(place.gramps_id, descr)
- def family_label(self,family):
+ def family_label(self, family):
+ """
+ Create the family label depending on existence of the father and mother
+ """
if family is None:
return "Unknown"
- f = m = None
+ father = mother = None
hdl = family.get_father_handle()
if hdl:
- f = self.dbstate.db.get_person_from_handle(hdl)
+ father = self.dbstate.db.get_person_from_handle(hdl)
hdl = family.get_mother_handle()
if hdl:
- m = self.dbstate.db.get_person_from_handle(hdl)
- if f and m:
+ mother = self.dbstate.db.get_person_from_handle(hdl)
+ if father and mother:
label = _("%(gramps_id)s : %(father)s and %(mother)s") % {
- 'father' : _nd.display(f),
- 'mother' : _nd.display(m),
+ 'father' : _nd.display(father),
+ 'mother' : _nd.display(mother),
'gramps_id' : family.gramps_id,
}
- elif f:
+ elif father:
label = "%(gramps_id)s : %(father)s" % {
- 'father' : _nd.display(f),
+ 'father' : _nd.display(father),
'gramps_id' : family.gramps_id,
}
- elif m:
+ elif mother:
label = "%(gramps_id)s : %(mother)s" % {
- 'mother' : _nd.display(m),
+ 'mother' : _nd.display(mother),
'gramps_id' : family.gramps_id,
}
else:
@@ -306,10 +315,12 @@ class GeoFamily(GeoGraphyView):
Create all markers for one family : all event's places with a lat/lon.
"""
dbstate = self.dbstate
- self.message_layer.add_message(_("Family places for %s") % self.family_label(family))
+ self.message_layer.add_message(
+ _("Family places for %s") % self.family_label(family))
person = None
if family:
- person = dbstate.db.get_person_from_handle(family.get_father_handle())
+ person = dbstate.db.get_person_from_handle(
+ family.get_father_handle())
else:
return
family_id = family.gramps_id
@@ -331,16 +342,18 @@ class GeoFamily(GeoGraphyView):
if handle:
father = dbstate.db.get_person_from_handle(handle)
if father:
- comment = _("Father : %(id)s : %(name)s") % {'id': father.gramps_id,
- 'name': _nd.display(father) }
+ comment = _("Father : %(id)s : %(name)s") % {
+ 'id': father.gramps_id,
+ 'name': _nd.display(father)}
self._createpersonmarkers(dbstate, father,
comment, family_id)
handle = fam.get_mother_handle()
if handle:
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- comment = _("Mother : %(id)s : %(name)s") % {'id': mother.gramps_id,
- 'name': _nd.display(mother) }
+ comment = _("Mother : %(id)s : %(name)s") % {
+ 'id': mother.gramps_id,
+ 'name': _nd.display(mother)}
self._createpersonmarkers(dbstate, mother,
comment, family_id)
index = 0
@@ -360,7 +373,7 @@ class GeoFamily(GeoGraphyView):
comment, family_id)
else:
comment = _("Person : %(id)s %(name)s has no family.") % {
- 'id' : person.gramps_id ,
+ 'id' : person.gramps_id,
'name' : _nd.display(person)
}
self._createpersonmarkers(dbstate, person, comment, family_id)
@@ -399,6 +412,9 @@ class GeoFamily(GeoGraphyView):
self._create_markers()
def add_event_bubble_message(self, event, lat, lon, mark, menu):
+ """
+ Add an item to the popup menu.
+ """
self.itemoption = Gtk.Menu()
itemoption = self.itemoption
itemoption.show()
@@ -421,6 +437,9 @@ class GeoFamily(GeoGraphyView):
itemoption.append(center)
def bubble_message(self, event, lat, lon, marks):
+ """
+ Add the popup menu.
+ """
self.menu = Gtk.Menu()
menu = self.menu
menu.set_title("family")
@@ -444,18 +463,20 @@ class GeoFamily(GeoGraphyView):
date = displayer.display(evt.get_date_object())
if date == "":
date = _("Unknown")
- if ( mark[5] == EventRoleType.PRIMARY ):
- message = "(%s) %s : %s" % ( date, mark[7], mark[1] )
- elif ( mark[5] == EventRoleType.FAMILY ):
+ if mark[5] == EventRoleType.PRIMARY:
+ message = "(%s) %s : %s" % (date, mark[7], mark[1])
+ elif mark[5] == EventRoleType.FAMILY:
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
- (father_name, mother_name) = self._get_father_and_mother_name(evt)
- message = "(%s) %s : %s - %s" % ( date, mark[7], father_name, mother_name )
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(evt)
+ message = "(%s) %s : %s - %s" % (date, mark[7],
+ father_name, mother_name)
else:
evt = self.dbstate.db.get_event_from_gramps_id(mark[10])
descr = evt.get_description()
if descr == "":
descr = _('No description')
- message = "(%s) %s => %s" % ( date, mark[5], descr)
+ message = "(%s) %s => %s" % (date, mark[5], descr)
prevmark = mark
add_item = Gtk.MenuItem(label=message)
add_item.show()
diff --git a/gramps/plugins/view/geography.gpr.py b/gramps/plugins/view/geography.gpr.py
index 66e342bda..00beacb6e 100644
--- a/gramps/plugins/view/geography.gpr.py
+++ b/gramps/plugins/view/geography.gpr.py
@@ -2,7 +2,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,9 +25,15 @@
#
#------------------------------------------------------------------------
-MODULE_VERSION="5.0"
+# pylint: disable=bad-whitespace
+# pylint: disable=bad-whitespace
+
+MODULE_VERSION = "5.0"
from gi import Repository
+from gramps.gen.const import GRAMPS_LOCALE as glocale
+from gramps.gen.plug._pluginreg import register, VIEW, STABLE #, END, START
+_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
@@ -40,9 +46,9 @@ _LOG = logging.getLogger("Geography")
# Attempting to import OsmGpsMap gives an error dialog if OsmGpsMap is not
# available so test first and log just a warning to the console instead.
OSMGPSMAP = False
-repository = Repository.get_default()
-if repository.enumerate_versions("OsmGpsMap"):
- try :
+REPOSITORY = Repository.get_default()
+if REPOSITORY.enumerate_versions("OsmGpsMap"):
+ try:
# current osmgpsmap support GTK3
import gi
gi.require_version('OsmGpsMap', '1.0')
@@ -58,22 +64,22 @@ if not OSMGPSMAP:
if has_display():
from gramps.gui.dialog import MessageHideDialog
from gramps.gen.const import URL_WIKISTRING
- osmgps_dict = { 'gramps_wiki_build_osmgps_url' :
+ OSMGPS_DICT = {'gramps_wiki_build_osmgps_url' :
URL_WIKISTRING +
"GEPS_029:_GTK3-GObject_introspection"
- "_Conversion#OsmGpsMap_for_Geography" }
- title = _("OsmGpsMap module not loaded.")
- message = _("Geography functionality will not be available.\n"
+ "_Conversion#OsmGpsMap_for_Geography"}
+ TITLE = _("OsmGpsMap module not loaded.")
+ MESSAGE = _("Geography functionality will not be available.\n"
"To build it for Gramps see "
- "%(gramps_wiki_build_osmgps_url)s") % osmgps_dict
- MessageHideDialog(title, message, 'interface.ignore-osmgpsmap')
+ "%(gramps_wiki_build_osmgps_url)s") % OSMGPS_DICT
+ MessageHideDialog(TITLE, MESSAGE, 'interface.ignore-osmgpsmap')
else:
# Load the view only if osmgpsmap library is present.
register(VIEW,
- id = 'geo1',
- name = _("All known places for one Person"),
- description = _("A view showing the places visited by "
- "one person during his life."),
+ id = 'geo1',
+ name = _("All known places for one Person"),
+ description = _("A view showing the places visited by "
+ "one person during his life."),
version = '1.0',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -87,10 +93,10 @@ else:
)
register(VIEW,
- id = 'geo2',
- name = _("All known places for one Family"),
- description = _("A view showing the places visited by "
- "one family during all their life."),
+ id = 'geo2',
+ name = _("All known places for one Family"),
+ description = _("A view showing the places visited by "
+ "one family during all their life."),
version = '1.0',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -104,12 +110,14 @@ else:
)
register(VIEW,
- id = 'geo3',
- name = _("Every residence or move for a person and any descendants"),
- description = _("A view showing all the places visited by "
- "all persons during their life."
- "\nThis is for a person and any descendant."
- "\nYou can see the dates corresponding to the period."),
+ id = 'geo3',
+ name = _("Every residence or move for a person "
+ "and any descendants"),
+ description = _("A view showing all the places visited by "
+ "all persons during their life."
+ "\nThis is for a person and any descendant."
+ "\nYou can see the dates corresponding to "
+ "the period."),
version = '1.0',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -123,11 +131,11 @@ else:
)
register(VIEW,
- id = 'geo4',
- name = _("Have these two families been able to meet?"),
- description = _("A view showing the places visited by "
- "all family's members during their life: "
- "have these two people been able to meet?"),
+ id = 'geo4',
+ name = _("Have these two families been able to meet?"),
+ description = _("A view showing the places visited by "
+ "all family's members during their life: "
+ "have these two people been able to meet?"),
version = '1.0.1',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -141,11 +149,11 @@ else:
)
register(VIEW,
- id = 'geo5',
- name = _("Have they been able to meet?"),
- description = _("A view showing the places visited by "
- "two persons during their life: "
- "have these two people been able to meet?"),
+ id = 'geo5',
+ name = _("Have they been able to meet?"),
+ description = _("A view showing the places visited by "
+ "two persons during their life: "
+ "have these two people been able to meet?"),
version = '1.0.1',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -159,9 +167,9 @@ else:
)
register(VIEW,
- id = 'geo6',
- name = _("All known Places"),
- description = _("A view showing all places of the database."),
+ id = 'geo6',
+ name = _("All known Places"),
+ description = _("A view showing all places of the database."),
version = '1.0',
gramps_target_version = MODULE_VERSION,
status = STABLE,
@@ -175,10 +183,10 @@ else:
)
register(VIEW,
- id = 'geo7',
- name = _("All places related to Events"),
- description = _("A view showing all the event "
- "places of the database."),
+ id = 'geo7',
+ name = _("All places related to Events"),
+ description = _("A view showing all the event "
+ "places of the database."),
version = '1.0',
gramps_target_version = MODULE_VERSION,
status = STABLE,
diff --git a/gramps/plugins/view/geomoves.py b/gramps/plugins/view/geomoves.py
index e9da1531d..6855c4e14 100644
--- a/gramps/plugins/view/geomoves.py
+++ b/gramps/plugins/view/geomoves.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,10 +33,6 @@ _ = glocale.translation.gettext
import operator
from gi.repository import Gtk
from gi.repository import Gdk
-from gi.repository import GObject
-import time
-import threading
-from math import *
from gi.repository import GLib
#-------------------------------------------------------------------------
@@ -58,11 +54,9 @@ from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
-from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PersonBookmarks
from gramps.plugins.lib.maps import constants
from gramps.plugins.lib.maps.geography import GeoGraphyView
-from gramps.gui.selectors import SelectorFactory
#-------------------------------------------------------------------------
#
@@ -107,6 +101,11 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+
+
#-------------------------------------------------------------------------
#
# GeoView : GeoMoves
@@ -114,7 +113,8 @@ _UI_DEF = '''\
#-------------------------------------------------------------------------
class GeoMoves(GeoGraphyView):
"""
- The view used to render all places visited by one person and all his descendants.
+ The view used to render all places visited by one person and all
+ his descendants.
"""
CONFIGSETTINGS = (
('geography.path', constants.GEOGRAPHY_PATH),
@@ -164,6 +164,7 @@ class GeoMoves(GeoGraphyView):
self.markers_by_level = dict()
self.count = dict()
self.no_show_places_in_status_bar = False
+ self.person_list = []
def get_title(self):
"""
@@ -213,8 +214,8 @@ class GeoMoves(GeoGraphyView):
self.date_layer.clear_dates()
active = self.get_active()
if active:
- p1 = self.dbstate.db.get_person_from_handle(active)
- self._createmap(p1)
+ person = self.dbstate.db.get_person_from_handle(active)
+ self._createmap(person)
self.uistate.modify_statusbar(self.dbstate)
def build_tree(self):
@@ -294,9 +295,9 @@ class GeoMoves(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr, evt,
- person.gramps_id, #_nd.display(person),
+ person.gramps_id,
latitude, longitude,
descr1, eyear,
event.get_type(),
@@ -325,7 +326,7 @@ class GeoMoves(GeoGraphyView):
if handle:
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- descr1 = "%s%s" % ( descr1, _nd.display(mother))
+ descr1 = "%s%s" % (descr1, _nd.display(mother))
for event_ref in family.get_event_ref_list():
if event_ref:
event = dbstate.db.get_event_from_handle(
@@ -344,12 +345,15 @@ class GeoMoves(GeoGraphyView):
descr = _pd.display(dbstate.db, place)
evt = EventType(
event.get_type())
- eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
- if ( longitude and latitude ):
- self._append_to_places_list(descr, evt,
- person.gramps_id, #_nd.display(person),
+ eyear = str(
+ "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
+ if longitude and latitude:
+ self._append_to_places_list(
+ descr,
+ evt,
+ person.gramps_id,
latitude, longitude,
descr1, eyear,
event.get_type(),
@@ -359,13 +363,13 @@ class GeoMoves(GeoGraphyView):
role
)
else:
- self._append_to_places_without_coord( place.gramps_id, descr)
+ self._append_to_places_without_coord(place.gramps_id, descr)
- sort1 = sorted(self.place_list, key=operator.itemgetter(1,6))
+ sort1 = sorted(self.place_list, key=operator.itemgetter(1, 6))
self.draw(None, sort1, color)
# merge with the last results
merge_list = self.sort
- for the_event in sort1 :
+ for the_event in sort1:
if the_event not in merge_list:
merge_list.append(the_event)
self.sort = sorted(merge_list, key=operator.itemgetter(6))
@@ -388,7 +392,8 @@ class GeoMoves(GeoGraphyView):
dbstate = self.dbstate
person = None
try:
- person = dbstate.db.get_person_from_handle(family.get_father_handle())
+ person = dbstate.db.get_person_from_handle(
+ family.get_father_handle())
except:
return
family_id = family.gramps_id
@@ -425,7 +430,8 @@ class GeoMoves(GeoGraphyView):
child = dbstate.db.get_person_from_handle(child_ref.ref)
if child:
index += 1
- self._createmap_for_next_level(child, level, curlevel)
+ self._createmap_for_next_level(child, level,
+ curlevel)
self._add_person_to_list(child.gramps_id, curlevel)
def _createmap_for_one_level(self, family, level, curlevel):
@@ -480,81 +486,84 @@ class GeoMoves(GeoGraphyView):
person = self.dbstate.db.get_person_from_handle(handle)
if not person:
return
- self.message_layer.add_message(_("All descendance for %s") % _nd.display(person))
+ self.message_layer.add_message(
+ _("All descendance for %s") % _nd.display(person))
color = Gdk.color_parse(self._config.get('geography.color_base'))
GLib.timeout_add(int(self._config.get("geography.generation_interval")),
self.animate_moves, 0, person, color)
def animate_moves(self, index, person, color):
- """
- Animate all moves for one generation.
- """
- self.markers_by_level = dict()
- self._createmap_for_next_level(person, index, 0)
- try:
- persons = self.markers_by_level[index]
- except:
- return
- for people in persons:
- family_list = people.get_family_handle_list()
- for fhandle in family_list:
- family = self.dbstate.db.get_family_from_handle(fhandle)
- self._prepare_for_one_family(family, index, index+1)
- new_list = []
- for plx, level in self.person_list:
- plxp = self.dbstate.db.get_person_from_gramps_id(plx)
- birth = "0000"
- death = "0000"
- low_date = "9999"
- high_date = "0000"
- for event_ref in plxp.get_event_ref_list():
- if not event_ref:
- continue
- event = self.dbstate.db.get_event_from_handle(event_ref.ref)
- role = event_ref.get_role()
- try:
- date = event.get_date_object().to_calendar(self.cal)
- fyear = str("%04d" % date.get_year())
- if event.get_type() == EventType.BIRTH:
- birth = fyear
- if event.get_type() == EventType.DEATH:
- death = fyear
- if fyear < low_date:
- low_date = fyear
- if fyear > high_date:
- high_date = fyear
+ """
+ Animate all moves for one generation.
+ """
+ self.markers_by_level = dict()
+ self._createmap_for_next_level(person, index, 0)
+ try:
+ persons = self.markers_by_level[index]
+ except:
+ return
+ for people in persons:
+ family_list = people.get_family_handle_list()
+ for fhandle in family_list:
+ family = self.dbstate.db.get_family_from_handle(fhandle)
+ self._prepare_for_one_family(family, index, index+1)
+ new_list = []
+ for plx, level in self.person_list:
+ plxp = self.dbstate.db.get_person_from_gramps_id(plx)
+ birth = "0000"
+ death = "0000"
+ low_date = "9999"
+ high_date = "0000"
+ for event_ref in plxp.get_event_ref_list():
+ if not event_ref:
+ continue
+ event = self.dbstate.db.get_event_from_handle(event_ref.ref)
+ role = event_ref.get_role()
+ try:
+ date = event.get_date_object().to_calendar(self.cal)
+ fyear = str("%04d" % date.get_year())
+ if event.get_type() == EventType.BIRTH:
+ birth = fyear
+ if event.get_type() == EventType.DEATH:
+ death = fyear
+ if fyear < low_date:
+ low_date = fyear
+ if fyear > high_date:
+ high_date = fyear
- except:
- pass
- if birth == "0000":
- birth = low_date
- if death == "0000":
- death = high_date
- new_list.append([level, plxp, birth, death])
- pidx = 0;
- if isinstance(color, str) :
- color = Gdk.color_parse(color)
- for (level, plxp, birth, death) in sorted(new_list, key=operator.itemgetter(0,2)):
- if index == int(self._config.get("geography.maximum_generations")):
- break
- if level == index:
- pidx += 1
- self._createmap_for_one_person(plxp, color)
- color.red = (float(color.red - (index)*3000)%65535)
- if ( index % 2 ):
- color.green = float((color.green + (index)*3000)%65535)
- else:
- color.blue = float((color.blue + (index)*3000)%65535)
- self._createmap_for_one_person(person, color)
- if index < int(self._config.get("geography.maximum_generations")):
- time_to_wait = int(self._config.get("geography.generation_interval"))
- self._create_markers()
- # process next generation in a few milliseconds
- GLib.timeout_add(int(time_to_wait), self.animate_moves,
- index+1, person, color)
- else:
- self.started = False
- return False
+ except:
+ pass
+ if birth == "0000":
+ birth = low_date
+ if death == "0000":
+ death = high_date
+ new_list.append([level, plxp, birth, death])
+ pidx = 0
+ if isinstance(color, str):
+ color = Gdk.color_parse(color)
+ for (level, plxp,
+ birth, death) in sorted(new_list, key=operator.itemgetter(0, 2)):
+ if index == int(self._config.get("geography.maximum_generations")):
+ break
+ if level == index:
+ pidx += 1
+ self._createmap_for_one_person(plxp, color)
+ color.red = (float(color.red - (index)*3000)%65535)
+ if index % 2:
+ color.green = float((color.green + (index)*3000)%65535)
+ else:
+ color.blue = float((color.blue + (index)*3000)%65535)
+ self._createmap_for_one_person(person, color)
+ if index < int(self._config.get("geography.maximum_generations")):
+ time_to_wait = int(
+ self._config.get("geography.generation_interval"))
+ self._create_markers()
+ # process next generation in a few milliseconds
+ GLib.timeout_add(int(time_to_wait), self.animate_moves,
+ index+1, person, color)
+ else:
+ self.started = False
+ return False
def bubble_message(self, event, lat, lon, marks):
"""
@@ -568,7 +577,7 @@ class GeoMoves(GeoGraphyView):
oldplace = ""
prevmark = None
# Be sure all markers are sorted by place then dates.
- for mark in sorted(marks, key=operator.itemgetter(0,6)):
+ for mark in sorted(marks, key=operator.itemgetter(0, 6)):
if mark[10] in events:
continue # avoid duplicate events
else:
@@ -585,19 +594,20 @@ class GeoMoves(GeoGraphyView):
date = displayer.display(evt.get_date_object())
if date == "":
date = _("Unknown")
- if ( mark[11] == EventRoleType.PRIMARY ):
+ if mark[11] == EventRoleType.PRIMARY:
person = self.dbstate.db.get_person_from_gramps_id(mark[1])
- message = "(%s) %s : %s" % ( date, mark[2], _nd.display(person) )
- elif ( mark[11] == EventRoleType.FAMILY ):
- (father_name, mother_name) = self._get_father_and_mother_name(evt)
+ message = "(%s) %s : %s" % (date, mark[2], _nd.display(person))
+ elif mark[11] == EventRoleType.FAMILY:
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(evt)
message = "(%s) %s : %s - %s" % (date, mark[2],
father_name,
- mother_name )
+ mother_name)
else:
descr = evt.get_description()
if descr == "":
descr = _('No description')
- message = "(%s) %s => %s" % ( date, mark[11], descr)
+ message = "(%s) %s => %s" % (date, mark[11], descr)
prevmark = mark
add_item = Gtk.MenuItem(label=message)
add_item.show()
diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py
index f04346c6f..c9f4a8914 100644
--- a/gramps/plugins/view/geoperson.py
+++ b/gramps/plugins/view/geoperson.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,14 +28,10 @@ Geography for one person
# Python modules
#
#-------------------------------------------------------------------------
-import os
-import sys
import operator
from gi.repository import Gdk
KEY_TAB = Gdk.KEY_Tab
-import socket
from gi.repository import Gtk
-from gi.repository import GObject
from gi.repository import GLib
#-------------------------------------------------------------------------
@@ -59,11 +55,6 @@ from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
-from gramps.gui.views.pageview import PageView
-from gramps.gui.editors import EditPlace
-from gramps.gui.selectors.selectplace import SelectPlace
-from gramps.gui.filters.sidebar import PersonSidebarFilter
-from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PersonBookmarks
from gramps.plugins.lib.maps import constants
from gramps.plugins.lib.maps.geography import GeoGraphyView
@@ -111,6 +102,11 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -163,6 +159,9 @@ class GeoPerson(GeoGraphyView):
self.sort = []
self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False
+ self.already_started = False
+ self.large_move = False
+ self.cal = None
def get_title(self):
"""
@@ -230,8 +229,8 @@ class GeoPerson(GeoGraphyView):
self.already_started = False
return False
i = int(index)
- ni = i + 1
- if ni == len(marks) :
+ next_i = i + 1
+ if next_i == len(marks):
self.already_started = False
return False
startlat = float(marks[i][3])
@@ -241,41 +240,41 @@ class GeoPerson(GeoGraphyView):
self.remove_all_gps()
self.large_move = False
self.osm.gps_add(startlat, startlon, heading)
- endlat = float(marks[ni][3])
- endlon = float(marks[ni][4])
+ endlat = float(marks[next_i][3])
+ endlon = float(marks[next_i][4])
max_lon_lat = float(self._config.get("geography.maximum_lon_lat")) / 10
if stepyear < 9000:
- if (( abs(float(endlat) - float(startlat)) > max_lon_lat ) or
- ( abs(float(endlon) - float(startlon)) > max_lon_lat )):
+ if ((abs(float(endlat) - float(startlat)) > max_lon_lat) or
+ (abs(float(endlon) - float(startlon)) > max_lon_lat)):
self.large_move = True
stepyear = 9000
else:
self.large_move = False
# year format = YYYYMMDD ( for sort )
startyear = str(marks[i][6])[0:4]
- endyear = str(marks[ni][6])[0:4]
+ endyear = str(marks[next_i][6])[0:4]
endmov = str(marks[len(marks)-1][6])[0:4]
years = int(endyear) - int(startyear)
if years < 1:
years = 1
if stepyear > 8999:
- latstep = ( endlat - startlat ) / self._config.get("geography.steps")
- lonstep = ( endlon - startlon ) / self._config.get("geography.steps")
- startlat += ( latstep * (stepyear - 8999) )
- startlon += ( lonstep * (stepyear - 8999) )
+ latstep = (endlat - startlat) / self._config.get("geography.steps")
+ lonstep = (endlon - startlon) / self._config.get("geography.steps")
+ startlat += (latstep * (stepyear - 8999))
+ startlon += (lonstep * (stepyear - 8999))
else:
- latstep = ( endlat - startlat ) / years
- lonstep = ( endlon - startlon ) / years
+ latstep = (endlat - startlat) / years
+ lonstep = (endlon - startlon) / years
stepyear = 1 if stepyear < 1 else stepyear
- startlat += ( latstep * stepyear )
- startlon += ( lonstep * stepyear )
+ startlat += (latstep * stepyear)
+ startlon += (lonstep * stepyear)
self.osm.gps_add(startlat, startlon, heading)
stepyear += 1
- difflat = round(( startlat - endlat ) if startlat > endlat else \
- ( endlat - startlat ), 8)
- difflon = round(( startlon - endlon ) if startlon > endlon else \
- ( endlon - startlon ), 8)
- if ( difflat == 0.0 and difflon == 0.0 ):
+ difflat = round((startlat - endlat) if startlat > endlat else \
+ (endlat - startlat), 8)
+ difflon = round((startlon - endlon) if startlon > endlon else \
+ (endlon - startlon), 8)
+ if difflat == 0.0 and difflon == 0.0:
i += 1
self.large_move = False
stepyear = 1
@@ -283,13 +282,12 @@ class GeoPerson(GeoGraphyView):
# For a 100 years person, it takes 10 secondes.
# if large_move, one step is the difflat or difflon / geography.steps
# in this case, stepyear is >= 9000
- # large move means longitude or latitude differences greater than geography.maximum_lon_lat
- # degrees.
+ # large move means longitude or latitude differences greater than
+ # geography.maximum_lon_lat degrees.
GLib.timeout_add(int(self._config.get("geography.speed")), self.animate,
menu, marks, i, stepyear)
return False
- #def _createmap(self,obj):
def _createmap(self):
"""
Create all markers for each people's event in the database which has
@@ -316,16 +314,18 @@ class GeoPerson(GeoGraphyView):
if person is not None:
# For each event, if we have a place, set a marker.
self.load_kml_files(person)
- self.message_layer.add_message(_("Person places for %s") % _nd.display(person))
+ self.message_layer.add_message(
+ _("Person places for %s") % _nd.display(person))
for event_ref in person.get_event_ref_list():
if not event_ref:
continue
event = dbstate.db.get_event_from_handle(event_ref.ref)
self.load_kml_files(event)
role = event_ref.get_role()
- eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
+ eyear = str(
+ "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
place_handle = event.get_place_handle()
if place_handle:
place = dbstate.db.get_place_from_handle(place_handle)
@@ -343,7 +343,7 @@ class GeoPerson(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr, evt,
_nd.display(person),
latitude, longitude,
@@ -374,28 +374,33 @@ class GeoPerson(GeoGraphyView):
if handle:
mother = dbstate.db.get_person_from_handle(handle)
if mother:
- descr1 = "%s%s" % ( descr1, _nd.display(mother))
+ descr1 = "%s%s" % (descr1, _nd.display(mother))
for event_ref in family.get_event_ref_list():
if event_ref:
- event = dbstate.db.get_event_from_handle(event_ref.ref)
+ event = dbstate.db.get_event_from_handle(
+ event_ref.ref)
self.load_kml_files(event)
role = event_ref.get_role()
if event.get_place_handle():
place_handle = event.get_place_handle()
if place_handle:
- place = dbstate.db.get_place_from_handle(place_handle)
+ place = dbstate.db.get_place_from_handle(
+ place_handle)
if place:
longitude = place.get_longitude()
latitude = place.get_latitude()
- latitude, longitude = conv_lat_lon(latitude,
- longitude, "D.D8")
+ (latitude,
+ longitude) = conv_lat_lon(latitude,
+ longitude,
+ "D.D8")
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
- eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
- str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
+ eyear = str(
+ "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
+ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
self.load_kml_files(place)
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr,
evt, _nd.display(person),
latitude, longitude,
@@ -407,7 +412,7 @@ class GeoPerson(GeoGraphyView):
role
)
else:
- self._append_to_places_without_coord( place.gramps_id, descr)
+ self._append_to_places_without_coord(place.gramps_id, descr)
self.sort = sorted(self.place_list,
key=operator.itemgetter(6)
@@ -473,16 +478,18 @@ class GeoPerson(GeoGraphyView):
date = displayer.display(evt.get_date_object())
if date == "":
date = _("Unknown")
- if ( mark[11] == EventRoleType.PRIMARY ):
- message = "(%s) %s : %s" % ( date, mark[2], mark[1] )
- elif ( mark[11] == EventRoleType.FAMILY ):
- (father_name, mother_name) = self._get_father_and_mother_name(evt)
- message = "(%s) %s : %s - %s" % ( date, mark[7], father_name, mother_name )
+ if mark[11] == EventRoleType.PRIMARY:
+ message = "(%s) %s : %s" % (date, mark[2], mark[1])
+ elif mark[11] == EventRoleType.FAMILY:
+ (father_name,
+ mother_name) = self._get_father_and_mother_name(evt)
+ message = "(%s) %s : %s - %s" % (date, mark[7],
+ father_name, mother_name)
else:
descr = evt.get_description()
if descr == "":
descr = _('No description')
- message = "(%s) %s => %s" % ( date, mark[11], descr)
+ message = "(%s) %s => %s" % (date, mark[11], descr)
prevmark = mark
add_item = Gtk.MenuItem(label=message)
add_item.show()
@@ -541,9 +548,10 @@ class GeoPerson(GeoGraphyView):
"",
2, 'geography.speed',
(100, 1000))
- configdialog.add_text(grid,
- _('How many steps between two markers when we are on large move ?'),
- 3, line_wrap=False)
+ configdialog.add_text(
+ grid,
+ _('How many steps between two markers when we are on large move ?'),
+ 3, line_wrap=False)
configdialog.add_slider(grid,
"",
4, 'geography.steps',
diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py
index 8f3d3ff83..0a92703d7 100644
--- a/gramps/plugins/view/geoplaces.py
+++ b/gramps/plugins/view/geoplaces.py
@@ -3,7 +3,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2011 Serge Noiraud
+# Copyright (C) 2011-2016 Serge Noiraud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,13 +28,10 @@ Geography for places
# Python modules
#
#-------------------------------------------------------------------------
-import os
-import sys
import time
import operator
from gi.repository import Gdk
KEY_TAB = Gdk.KEY_Tab
-import socket
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -54,14 +51,8 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import EventType
from gramps.gen.config import config
-from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
-from gramps.gui.views.pageview import PageView
-from gramps.gui.editors import EditPlace
-from gramps.gui.selectors.selectplace import SelectPlace
-from gramps.gui.filters.sidebar import PlaceSidebarFilter
-from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PlaceBookmarks
from gramps.plugins.lib.maps.geography import GeoGraphyView
from gramps.gui.utils import ProgressMeter
@@ -106,6 +97,11 @@ _UI_DEF = '''\
'''
+# pylint: disable=no-member
+# pylint: disable=maybe-no-member
+# pylint: disable=unused-variable
+# pylint: disable=unused-argument
+
#-------------------------------------------------------------------------
#
# GeoView
@@ -136,6 +132,9 @@ class GeoPlaces(GeoGraphyView):
self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False
self.show_all = False
+ self.itemoption = None
+ self.menu = None
+ self.cal = config.get('preferences.calendar-format-report')
def get_title(self):
"""
@@ -197,7 +196,7 @@ class GeoPlaces(GeoGraphyView):
else:
self._createmap(None)
- def _create_one_place(self,place):
+ def _create_one_place(self, place):
"""
Create one entry for one place with a lat/lon.
"""
@@ -212,7 +211,7 @@ class GeoPlaces(GeoGraphyView):
# place.get_longitude and place.get_latitude return
# one string. We have coordinates when the two values
# contains non null string.
- if ( longitude and latitude ):
+ if longitude and latitude:
self._append_to_places_list(descr, None, "",
latitude, longitude,
None, None,
@@ -223,13 +222,12 @@ class GeoPlaces(GeoGraphyView):
None # family.gramps_id
)
- def _createmap(self,place_x):
+ def _createmap(self, place_x):
"""
Create all markers for each people's event in the database which has
a lat/lon.
"""
dbstate = self.dbstate
- self.cal = config.get('preferences.calendar-format-report')
self.place_list = []
self.places_found = []
self.place_without_coordinates = []
@@ -252,13 +250,17 @@ class GeoPlaces(GeoGraphyView):
# base "villes de france" : 38101 places :
# createmap : 8'50"; create_markers : 0'07" with pixbuf optimization
# base "villes de france" : 38101 places :
- # gramps 3.4 python 2.7 ( draw_markers are estimated when we move the map)
- # 38101 places : createmap : 04'32"; create_markers : 0'04"; draw markers : N/A :: 0'03"
- # 65598 places : createmap : 10'03"; create_markers : 0'07"; draw markers : N/A :: 0'05"
+ # gramps 3.4 python 2.7 (draw_markers are estimated when moving the map)
+ # 38101 places: createmap: 04'32";
+ # create_markers: 0'04"; draw markers: N/A :: 0'03"
+ # 65598 places: createmap: 10'03";
+ # create_markers: 0'07"; draw markers: N/A :: 0'05"
# gramps 3.5 python 2.7 new marker layer
- # 38101 places : createmap : 03'09"; create_markers : 0'01"; draw markers : 0'04"
- # 65598 places : createmap : 08'48"; create_markers : 0'01"; draw markers : 0'07"
- _LOG.debug("%s" % time.strftime("start createmap : "
+ # 38101 places: createmap: 03'09";
+ # create_markers: 0'01"; draw markers: 0'04"
+ # 65598 places: createmap: 08'48";
+ # create_markers: 0'01"; draw markers: 0'07"
+ _LOG.debug("%s", time.strftime("start createmap : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
if self.show_all:
self.show_all = False
@@ -287,27 +289,29 @@ class GeoPlaces(GeoGraphyView):
progress.step()
progress.close()
elif place_x:
- place = dbstate.db.get_place_from_handle(place_x)
- self._create_one_place(place)
- if ( place.get_latitude() != "" and place.get_longitude() != "" ):
- latitude, longitude = conv_lat_lon(place.get_latitude(),
- place.get_longitude(), "D.D8")
- self.osm.set_center_and_zoom(float(latitude), float(longitude),
- int(config.get("geography.zoom_when_center")))
+ place = dbstate.db.get_place_from_handle(place_x)
+ self._create_one_place(place)
+ if place.get_latitude() != "" and place.get_longitude() != "":
+ latitude, longitude = conv_lat_lon(place.get_latitude(),
+ place.get_longitude(),
+ "D.D8")
+ self.osm.set_center_and_zoom(float(latitude), float(longitude),
+ int(config.get(
+ "geography.zoom_when_center")))
_LOG.debug(" stop createmap.")
- _LOG.debug("%s" % time.strftime("begin sort : "
+ _LOG.debug("%s", time.strftime("begin sort : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
self.sort = sorted(self.place_list,
key=operator.itemgetter(0)
)
- _LOG.debug("%s" % time.strftime(" end sort : "
+ _LOG.debug("%s", time.strftime(" end sort : "
"%a %d %b %Y %H:%M:%S", time.gmtime()))
- if self.nbmarkers > 500 : # performance issue. Is it the good value ?
+ if self.nbmarkers > 500: # performance issue. Is it the good value ?
self.message_layer.add_message(
_("The place name in the status bar is disabled."))
self.no_show_places_in_status_bar = True
- if self.nbplaces >= self._config.get("geography.max_places") :
- self.message_layer.set_font_attributes(None,None,"red")
+ if self.nbplaces >= self._config.get("geography.max_places"):
+ self.message_layer.set_font_attributes(None, None, "red")
self.message_layer.add_message(
_("The maximum number of places is reached (%d)." %
self._config.get("geography.max_places")))
@@ -390,7 +394,7 @@ class GeoPlaces(GeoGraphyView):
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Show all places"))
- add_item.connect("activate", self.show_all_places, event, lat , lon)
+ add_item.connect("activate", self.show_all_places, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Centering on Place"))