Skip to content

Commit 5865eec

Browse files
committed
GEPS045 update addons for Enhanced Places
1 parent e720c94 commit 5865eec

File tree

11 files changed

+429
-418
lines changed

11 files changed

+429
-418
lines changed

D3Charts/DescendantIndentedTree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#
6363
#------------------------------------------------------------------------
6464
from gramps.gen.display.name import displayer as global_name_display
65+
from gramps.gen.display.place import displayer as place_displayer
6566
from gramps.gen.errors import ReportError
6667
from gramps.gen.lib import ChildRefType
6768
from gramps.gen.plug.menu import (ColorOption, NumberOption, PersonOption,
@@ -317,9 +318,8 @@ def get_date_place(self,event):
317318
date = get_date(event)
318319
place_handle = event.get_place_handle()
319320
if place_handle:
320-
place = self.database.get_place_from_handle(
321-
place_handle).get_title()
322-
321+
place = place_displayer.display_event(self.database, event)
322+
323323
return("%(event_abbrev)s %(date)s %(place)s" % {
324324
'event_abbrev': event.type.get_abbreviation(),
325325
'date' : date,

DescendantBooks/DescendantBookReport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from gramps.gen.plug.menu import (NumberOption, PersonOption, BooleanOption,
4141
EnumeratedListOption, FilterOption)
4242
from gramps.gen.display.name import displayer as global_name_display
43+
from gramps.gen.display.place import displayer as place_displayer
4344
from gramps.gen.errors import ReportError
4445
from gramps.gen.plug.report import Report
4546
from gramps.gen.plug.report import utils as ReportUtils
@@ -158,8 +159,7 @@ def __date_place(self,event):
158159
date = gramps.gen.datehandler.get_date(event)
159160
place_handle = event.get_place_handle()
160161
if place_handle:
161-
place = self.database.get_place_from_handle(
162-
place_handle).get_title()
162+
place = place_displayer.display_event(self.database, event)
163163
return("%(event_abbrev)s %(date)s - %(place)s" % {
164164
'event_abbrev': event.type.get_abbreviation(),
165165
'date' : date,

DescendantBooks/DetailedDescendantBookReport.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#
3939
#------------------------------------------------------------------------
4040
from gramps.gen.display.name import displayer as global_name_display
41+
from gramps.gen.display.place import displayer as place_displayer
4142
from gramps.gen.errors import ReportError
4243
from gramps.gen.lib import FamilyRelType, Person, NoteType
4344
from gramps.gen.plug.menu import (BooleanOption, NumberOption, PersonOption,
@@ -779,12 +780,7 @@ def append_event(self, event_ref, family = False):
779780
event = self.database.get_event_from_handle(event_ref.ref)
780781

781782
date = self._get_date(event.get_date_object())
782-
783-
ph = event.get_place_handle()
784-
if ph:
785-
place = self.database.get_place_from_handle(ph).get_title()
786-
else:
787-
place = ''
783+
place = place_displayer.display_event(self.database, event)
788784

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

@@ -823,12 +819,7 @@ def write_event(self, event_ref):
823819
else:
824820
date = event.get_date_object().get_year()
825821

826-
ph = event.get_place_handle()
827-
if ph:
828-
place = self.database.get_place_from_handle(ph).get_title()
829-
else:
830-
place = ''
831-
822+
place = place_displayer.display_event(self.database, event)
832823
self.doc.start_paragraph('DDR-EventHeader') #BOOK
833824
event_name = self._get_type(event.get_type())
834825

DescendantsLines/substkw.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@
5151
# Gramps modules
5252
#
5353
#------------------------------------------------------------------------
54-
from gramps.gen.display.place import displayer as _pd
55-
from gramps.gen.lib import EventType, PlaceType, Location
56-
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
57-
from gramps.gen.utils.location import get_main_location
58-
from gramps.gen.const import GRAMPS_LOCALE as glocale
5954
from gramps.plugins.lib.libsubstkeyword import *
6055

6156
import logging
@@ -624,67 +619,6 @@ def replace_and_clean(self, lines, event):
624619
return new
625620

626621

627-
class PlaceFormat(GenericFormat):
628-
""" The place format class.
629-
If no format string, the place is displayed as per preference options
630-
otherwise, parse through a format string and put the place parts in
631-
"""
632-
633-
def __init__(self, database, _in):
634-
self.database = database
635-
GenericFormat.__init__(self, _in)
636-
self.date = None
637-
638-
def get_place(self, database, event):
639-
""" A helper method for retrieving a place from an event """
640-
if event:
641-
bplace_handle = event.get_place_handle()
642-
self.date = event.date
643-
if bplace_handle:
644-
return database.get_place_from_handle(bplace_handle)
645-
return None
646-
647-
def _default_format(self, place):
648-
return _pd.display(self.database, place, date=self.date)
649-
650-
def parse_format(self, database, place):
651-
""" Parse the place """
652-
653-
if self.is_blank(place):
654-
return
655-
656-
code = "elcuspn" + "oitxy"
657-
upper = code.upper()
658-
659-
main_loc = get_main_location(database, place, date=self.date)
660-
location = Location()
661-
location.set_street(main_loc.get(PlaceType.STREET, ''))
662-
location.set_locality(main_loc.get(PlaceType.LOCALITY, ''))
663-
location.set_parish(main_loc.get(PlaceType.PARISH, ''))
664-
location.set_city(main_loc.get(PlaceType.CITY, ''))
665-
location.set_county(main_loc.get(PlaceType.COUNTY, ''))
666-
location.set_state(main_loc.get(PlaceType.STATE, ''))
667-
location.set_postal_code(main_loc.get(PlaceType.STREET, ''))
668-
location.set_country(main_loc.get(PlaceType.COUNTRY, ''))
669-
670-
function = [location.get_street,
671-
location.get_locality,
672-
location.get_city,
673-
location.get_county,
674-
location.get_state,
675-
place.get_code,
676-
location.get_country,
677-
678-
location.get_phone,
679-
location.get_parish,
680-
place.get_title,
681-
place.get_longitude,
682-
place.get_latitude
683-
]
684-
685-
return self.generic_format(place, code, upper, function)
686-
687-
688622
#
689623
# if __name__ == '__main__':
690624
#-------------------------------------------------------------------------

DynamicWeb/dynamicweb.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@
167167
DWR_VERSION_412 = (VERSION_TUPLE[0] >= 5) or ((VERSION_TUPLE[0] >= 4) and (VERSION_TUPLE[1] >= 1) and (VERSION_TUPLE[2] >= 2))
168168
DWR_VERSION_420 = (VERSION_TUPLE[0] >= 5) or ((VERSION_TUPLE[0] >= 4) and (VERSION_TUPLE[1] >= 2))
169169
DWR_VERSION_500 = (VERSION_TUPLE[0] >= 5)
170+
DWR_VERSION_520 = True # TODO adjust when we have the real 5.2.x out with enhanced places
171+
170172
from gramps.gen.lib import (ChildRefType, Date, EventType, FamilyRelType, Name,
171173
NameType, Person, UrlType, NoteType,
172174
EventRoleType, Family, Event, Place, Source,
@@ -226,6 +228,8 @@
226228
from gramps.gen.relationship import get_relationship_calculator
227229
if (DWR_VERSION_410):
228230
from gramps.gen.utils.location import get_main_location
231+
if DWR_VERSION_520:
232+
from gramps.gen.utils.location import get_code
229233

230234

231235
if (DWR_VERSION_500):
@@ -1518,13 +1522,19 @@ def _export_places(self):
15181522
if (not self.inc_places):
15191523
jdatas.append(jdata)
15201524
continue
1525+
#if DWR_VERSION_520: # TODO
1526+
# Enhanced places support multiple types with dates
1527+
# Enhanced places support multiple attributes
1528+
# Enhanced places support multiple events
1529+
# we may want to display some of these...
15211530
if DWR_VERSION_410:
15221531
jdata['type'] = str(place.get_type())
15231532
else:
15241533
jdata['type'] = ''
15251534
jdata['names'] = []
15261535
if DWR_VERSION_410:
1527-
for pn in place.get_all_names():
1536+
for pn in (place.get_names() if DWR_VERSION_520 else
1537+
place.get_all_names()):
15281538
lang = pn.get_language()
15291539
if lang != '' and pref_lang!= '' and lang != pref_lang: continue
15301540
date = format_date(pn.get_date_object())
@@ -1583,7 +1593,8 @@ def _export_places(self):
15831593
else:
15841594
coords = ("", "")
15851595
jdata['coords'] = coords
1586-
jdata['code'] = place.get_code()
1596+
jdata['code'] = (get_code(place) if DWR_VERSION_520 else
1597+
place.get_code())
15871598
# Get place notes
15881599
jdata['note'] = self.get_notes_text(place)
15891600
# Get place media

ExtractCity/extractcity.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from gramps.plugins.lib.libplaceimport import PlaceImport
5252
from gramps.gen.utils.location import get_main_location
5353
from gramps.gen.display.place import displayer as place_displayer
54-
from gramps.gen.lib import PlaceType, PlaceName
54+
from gramps.gen.lib import PlaceType, PlaceName, Attribute, AttributeType
5555

5656
from gramps.gui.plug import tool
5757
from gramps.gui.utils import ProgressMeter
@@ -610,7 +610,7 @@ def on_help_clicked(self, obj):
610610
display_help()
611611

612612
def on_ok_clicked(self, obj):
613-
with DbTxn(_("Extract Place data"), self.db, batch=True) as self.trans:
613+
with DbTxn(_("Extract Place data"), self.db, batch=False) as self.trans:
614614
self.db.disable_signals()
615615
changelist = [node for node in self.iter_list
616616
if self.model.get_value(node, 0)]
@@ -624,7 +624,10 @@ def on_ok_clicked(self, obj):
624624
place.set_name(PlaceName(value=row[2]))
625625
place.set_type(PlaceType.CITY)
626626
if row[4]:
627-
place.set_code(row[4])
627+
attr = Attribute()
628+
attr.set_type(AttributeType.POSTAL)
629+
attr.set_value(row[4])
630+
place.add_attribute(attr)
628631
self.db.commit_place(place, self.trans)
629632

630633
self.place_import.generate_hierarchy(self.trans)

0 commit comments

Comments
 (0)