Skip to content

Commit

Permalink
GEPS045 update addons for Enhanced Places
Browse files Browse the repository at this point in the history
  • Loading branch information
prculley committed Jul 9, 2019
1 parent e720c94 commit 5865eec
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 418 deletions.
6 changes: 3 additions & 3 deletions D3Charts/DescendantIndentedTree.py
Expand Up @@ -62,6 +62,7 @@
#
#------------------------------------------------------------------------
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import ReportError
from gramps.gen.lib import ChildRefType
from gramps.gen.plug.menu import (ColorOption, NumberOption, PersonOption,
Expand Down Expand Up @@ -317,9 +318,8 @@ def get_date_place(self,event):
date = get_date(event)
place_handle = event.get_place_handle()
if place_handle:
place = self.database.get_place_from_handle(
place_handle).get_title()

place = place_displayer.display_event(self.database, event)

return("%(event_abbrev)s %(date)s %(place)s" % {
'event_abbrev': event.type.get_abbreviation(),
'date' : date,
Expand Down
4 changes: 2 additions & 2 deletions DescendantBooks/DescendantBookReport.py
Expand Up @@ -40,6 +40,7 @@
from gramps.gen.plug.menu import (NumberOption, PersonOption, BooleanOption,
EnumeratedListOption, FilterOption)
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import ReportError
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils
Expand Down Expand Up @@ -158,8 +159,7 @@ def __date_place(self,event):
date = gramps.gen.datehandler.get_date(event)
place_handle = event.get_place_handle()
if place_handle:
place = self.database.get_place_from_handle(
place_handle).get_title()
place = place_displayer.display_event(self.database, event)
return("%(event_abbrev)s %(date)s - %(place)s" % {
'event_abbrev': event.type.get_abbreviation(),
'date' : date,
Expand Down
15 changes: 3 additions & 12 deletions DescendantBooks/DetailedDescendantBookReport.py
Expand Up @@ -38,6 +38,7 @@
#
#------------------------------------------------------------------------
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import ReportError
from gramps.gen.lib import FamilyRelType, Person, NoteType
from gramps.gen.plug.menu import (BooleanOption, NumberOption, PersonOption,
Expand Down Expand Up @@ -779,12 +780,7 @@ def append_event(self, event_ref, family = False):
event = self.database.get_event_from_handle(event_ref.ref)

date = self._get_date(event.get_date_object())

ph = event.get_place_handle()
if ph:
place = self.database.get_place_from_handle(ph).get_title()
else:
place = ''
place = place_displayer.display_event(self.database, event)

event_name = self._get_type(event.get_type())

Expand Down Expand Up @@ -823,12 +819,7 @@ def write_event(self, event_ref):
else:
date = event.get_date_object().get_year()

ph = event.get_place_handle()
if ph:
place = self.database.get_place_from_handle(ph).get_title()
else:
place = ''

place = place_displayer.display_event(self.database, event)
self.doc.start_paragraph('DDR-EventHeader') #BOOK
event_name = self._get_type(event.get_type())

Expand Down
66 changes: 0 additions & 66 deletions DescendantsLines/substkw.py
Expand Up @@ -51,11 +51,6 @@
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.display.place import displayer as _pd
from gramps.gen.lib import EventType, PlaceType, Location
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.utils.location import get_main_location
from gramps.gen.const import GRAMPS_LOCALE as glocale
from gramps.plugins.lib.libsubstkeyword import *

import logging
Expand Down Expand Up @@ -624,67 +619,6 @@ def replace_and_clean(self, lines, event):
return new


class PlaceFormat(GenericFormat):
""" The place format class.
If no format string, the place is displayed as per preference options
otherwise, parse through a format string and put the place parts in
"""

def __init__(self, database, _in):
self.database = database
GenericFormat.__init__(self, _in)
self.date = None

def get_place(self, database, event):
""" A helper method for retrieving a place from an event """
if event:
bplace_handle = event.get_place_handle()
self.date = event.date
if bplace_handle:
return database.get_place_from_handle(bplace_handle)
return None

def _default_format(self, place):
return _pd.display(self.database, place, date=self.date)

def parse_format(self, database, place):
""" Parse the place """

if self.is_blank(place):
return

code = "elcuspn" + "oitxy"
upper = code.upper()

main_loc = get_main_location(database, place, date=self.date)
location = Location()
location.set_street(main_loc.get(PlaceType.STREET, ''))
location.set_locality(main_loc.get(PlaceType.LOCALITY, ''))
location.set_parish(main_loc.get(PlaceType.PARISH, ''))
location.set_city(main_loc.get(PlaceType.CITY, ''))
location.set_county(main_loc.get(PlaceType.COUNTY, ''))
location.set_state(main_loc.get(PlaceType.STATE, ''))
location.set_postal_code(main_loc.get(PlaceType.STREET, ''))
location.set_country(main_loc.get(PlaceType.COUNTRY, ''))

function = [location.get_street,
location.get_locality,
location.get_city,
location.get_county,
location.get_state,
place.get_code,
location.get_country,

location.get_phone,
location.get_parish,
place.get_title,
place.get_longitude,
place.get_latitude
]

return self.generic_format(place, code, upper, function)


#
# if __name__ == '__main__':
#-------------------------------------------------------------------------
Expand Down
15 changes: 13 additions & 2 deletions DynamicWeb/dynamicweb.py
Expand Up @@ -167,6 +167,8 @@
DWR_VERSION_412 = (VERSION_TUPLE[0] >= 5) or ((VERSION_TUPLE[0] >= 4) and (VERSION_TUPLE[1] >= 1) and (VERSION_TUPLE[2] >= 2))
DWR_VERSION_420 = (VERSION_TUPLE[0] >= 5) or ((VERSION_TUPLE[0] >= 4) and (VERSION_TUPLE[1] >= 2))
DWR_VERSION_500 = (VERSION_TUPLE[0] >= 5)
DWR_VERSION_520 = True # TODO adjust when we have the real 5.2.x out with enhanced places

from gramps.gen.lib import (ChildRefType, Date, EventType, FamilyRelType, Name,
NameType, Person, UrlType, NoteType,
EventRoleType, Family, Event, Place, Source,
Expand Down Expand Up @@ -226,6 +228,8 @@
from gramps.gen.relationship import get_relationship_calculator
if (DWR_VERSION_410):
from gramps.gen.utils.location import get_main_location
if DWR_VERSION_520:
from gramps.gen.utils.location import get_code


if (DWR_VERSION_500):
Expand Down Expand Up @@ -1518,13 +1522,19 @@ def _export_places(self):
if (not self.inc_places):
jdatas.append(jdata)
continue
#if DWR_VERSION_520: # TODO
# Enhanced places support multiple types with dates
# Enhanced places support multiple attributes
# Enhanced places support multiple events
# we may want to display some of these...
if DWR_VERSION_410:
jdata['type'] = str(place.get_type())
else:
jdata['type'] = ''
jdata['names'] = []
if DWR_VERSION_410:
for pn in place.get_all_names():
for pn in (place.get_names() if DWR_VERSION_520 else
place.get_all_names()):
lang = pn.get_language()
if lang != '' and pref_lang!= '' and lang != pref_lang: continue
date = format_date(pn.get_date_object())
Expand Down Expand Up @@ -1583,7 +1593,8 @@ def _export_places(self):
else:
coords = ("", "")
jdata['coords'] = coords
jdata['code'] = place.get_code()
jdata['code'] = (get_code(place) if DWR_VERSION_520 else
place.get_code())
# Get place notes
jdata['note'] = self.get_notes_text(place)
# Get place media
Expand Down
9 changes: 6 additions & 3 deletions ExtractCity/extractcity.py
Expand Up @@ -51,7 +51,7 @@
from gramps.plugins.lib.libplaceimport import PlaceImport
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType, PlaceName
from gramps.gen.lib import PlaceType, PlaceName, Attribute, AttributeType

from gramps.gui.plug import tool
from gramps.gui.utils import ProgressMeter
Expand Down Expand Up @@ -610,7 +610,7 @@ def on_help_clicked(self, obj):
display_help()

def on_ok_clicked(self, obj):
with DbTxn(_("Extract Place data"), self.db, batch=True) as self.trans:
with DbTxn(_("Extract Place data"), self.db, batch=False) as self.trans:
self.db.disable_signals()
changelist = [node for node in self.iter_list
if self.model.get_value(node, 0)]
Expand All @@ -624,7 +624,10 @@ def on_ok_clicked(self, obj):
place.set_name(PlaceName(value=row[2]))
place.set_type(PlaceType.CITY)
if row[4]:
place.set_code(row[4])
attr = Attribute()
attr.set_type(AttributeType.POSTAL)
attr.set_value(row[4])
place.add_attribute(attr)
self.db.commit_place(place, self.trans)

self.place_import.generate_hierarchy(self.trans)
Expand Down

0 comments on commit 5865eec

Please sign in to comment.