5537: Crash when making an archive for the Narrative Web Site with the option Include Family Map with all places (merged from trunk)

svn: r18956
This commit is contained in:
Jérôme Rapinat 2012-02-23 07:29:28 +00:00
parent abe45952c0
commit 7315e9a7f2

View File

@ -1218,16 +1218,17 @@ class BasePage(object):
tbody += trow tbody += trow
return section return section
def source_link(self, source_handle, source_title, source_gid, cindex = None, uplink = False): def source_link(self, source_handle, source_title, gid = None, cindex = None, uplink = False):
""" """
creates a link to the source object creates a link to the source object
@param: source -- source object from database @param: source_handle -- source handle from database
@param: source_title -- title from the source object @param: source_title from the source object
@param: source_gid -- gramps id from the source object @param: gid -- source gramps id from the source object
@param: cindex - count index @param: cindex - count index
@param: up - rather to add back directories or not? @param: up - rather to add back directories or not?
""" """
url = self.report.build_url_fname_html(source_handle, "src", uplink) url = self.report.build_url_fname_html(source_handle, "src", uplink)
hyper = Html("a", source_title, hyper = Html("a", source_title,
href = url, href = url,
@ -1238,8 +1239,8 @@ class BasePage(object):
hyper.attr += ' name ="sref%d"' % cindex hyper.attr += ' name ="sref%d"' % cindex
# add GRAMPS ID # add GRAMPS ID
if not self.noid and source_gid: if not self.noid and gid:
hyper += Html("span", ' [%s]' % source_gid, class_ = "grampsid", inline = True) hyper += Html("span", ' [%s]' % gid, class_ = "grampsid", inline = True)
return hyper return hyper
def display_addr_list(self, addrlist, showsrc): def display_addr_list(self, addrlist, showsrc):
@ -2702,7 +2703,7 @@ class BasePage(object):
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
# # Web Page Fortmatter and writer # # Web Page Fortmatter and writer
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
def XHTMLWriter(self, htmlinstance, of): def XHTMLWriter(self, htmlinstance, of, sio):
""" """
Will format, write, and close the file Will format, write, and close the file
@ -2714,7 +2715,8 @@ class BasePage(object):
htmlinstance.write(partial(print, file=of)) htmlinstance.write(partial(print, file=of))
# closes the file # closes the file
self.report.close_file(of) self.report.close_file(of, sio)
################################################# #################################################
# #
# creates the Individual List Page # creates the Individual List Page
@ -2731,7 +2733,7 @@ class IndividualListPage(BasePage):
showpartner = report.options['showpartner'] showpartner = report.options['showpartner']
showparents = report.options['showparents'] showparents = report.options['showparents']
of = self.report.create_file("individuals") of, sio = self.report.create_file("individuals")
indlistpage, head, body = self.write_header(_("Individuals")) indlistpage, head, body = self.write_header(_("Individuals"))
# begin Individuals division # begin Individuals division
@ -2906,7 +2908,7 @@ class IndividualListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(indlistpage, of) self.XHTMLWriter(indlistpage, of, sio)
################################################# #################################################
# #
@ -2928,7 +2930,7 @@ class SurnamePage(BasePage):
showpartner = report.options['showpartner'] showpartner = report.options['showpartner']
showparents = report.options['showparents'] showparents = report.options['showparents']
of = self.report.create_file(name_to_md5(surname), "srn") of, sio = self.report.create_file(name_to_md5(surname), "srn")
self.up = True self.up = True
surnamepage, head, body = self.write_header("%s - %s" % (_("Surname"), surname)) surnamepage, head, body = self.write_header("%s - %s" % (_("Surname"), surname))
@ -3072,14 +3074,14 @@ class SurnamePage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(surnamepage, of) self.XHTMLWriter(surnamepage, of, sio)
class FamilyListPage(BasePage): class FamilyListPage(BasePage):
def __init__(self, report, title, ind_list, db_family_handles): def __init__(self, report, title, ind_list, db_family_handles):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("families") of, sio = self.report.create_file("families")
familiesListPage, head, body = self.write_header(_("Families")) familiesListPage, head, body = self.write_header(_("Families"))
# begin Family Division # begin Family Division
@ -3227,7 +3229,7 @@ class FamilyListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(familiesListPage, of) self.XHTMLWriter(familiesListPage, of, sio)
class FamilyPage(BasePage): class FamilyPage(BasePage):
def __init__(self, report, title, family_handle, place_list, ppl_handle_list, place_lat_long): def __init__(self, report, title, family_handle, place_list, ppl_handle_list, place_lat_long):
@ -3244,7 +3246,7 @@ class FamilyPage(BasePage):
birthorder = report.options["birthorder"] birthorder = report.options["birthorder"]
self.familymappages = report.options["familymappages"] self.familymappages = report.options["familymappages"]
of = self.report.create_file(family.get_handle(), "fam") of, sio = self.report.create_file(family.get_handle(), "fam")
familydetailpage, head, body = self.write_header(_("Family/ Relationship")) familydetailpage, head, body = self.write_header(_("Family/ Relationship"))
# begin FamilyDetaill division # begin FamilyDetaill division
@ -3322,14 +3324,14 @@ class FamilyPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(familydetailpage, of) self.XHTMLWriter(familydetailpage, of, sio)
class PlaceListPage(BasePage): class PlaceListPage(BasePage):
def __init__(self, report, title, place_handles, db_place_handles): def __init__(self, report, title, place_handles, db_place_handles):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("places") of, sio = self.report.create_file("places")
placelistpage, head, body = self.write_header(_("Places")) placelistpage, head, body = self.write_header(_("Places"))
# begin places division # begin places division
@ -3435,7 +3437,7 @@ class PlaceListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(placelistpage, of) self.XHTMLWriter(placelistpage, of, sio)
###################################################### ######################################################
# # # #
@ -3451,7 +3453,7 @@ class PlacePage(BasePage):
return None return None
BasePage.__init__(self, report, title, place.get_gramps_id()) BasePage.__init__(self, report, title, place.get_gramps_id())
of = self.report.create_file(place_handle, "plc") of, sio = self.report.create_file(place_handle, "plc")
self.src_list = src_list self.src_list = src_list
self.up = True self.up = True
self.page_title = place.get_title() self.page_title = place.get_title()
@ -3567,7 +3569,7 @@ class PlacePage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(placepage, of) self.XHTMLWriter(placepage, of, sio)
class EventListPage(BasePage): class EventListPage(BasePage):
def __init__(self, report, title, event_types, event_handle_list, ppl_handle_list, db_event_handles): def __init__(self, report, title, event_types, event_handle_list, ppl_handle_list, db_event_handles):
@ -3580,7 +3582,7 @@ class EventListPage(BasePage):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("events") of, sio = self.report.create_file("events")
eventslistpage, head, body = self.write_header(_("Events")) eventslistpage, head, body = self.write_header(_("Events"))
# begin events list division # begin events list division
@ -3723,7 +3725,7 @@ class EventListPage(BasePage):
# send page ut for processing # send page ut for processing
# and close the file # and close the file
self.XHTMLWriter(eventslistpage, of) self.XHTMLWriter(eventslistpage, of, sio)
def _getEventDate(self, event_handle): def _getEventDate(self, event_handle):
event_date = gen.lib.Date.EMPTY event_date = gen.lib.Date.EMPTY
@ -3769,7 +3771,7 @@ class EventPage(BasePage):
subdirs = True subdirs = True
self.bibli = Bibliography() self.bibli = Bibliography()
of = self.report.create_file(event_handle, "evt") of, sio = self.report.create_file(event_handle, "evt")
eventpage, head, body = self.write_header(_("Events")) eventpage, head, body = self.write_header(_("Events"))
# start event detail division # start event detail division
@ -3861,7 +3863,7 @@ class EventPage(BasePage):
# send page out for processing # send page out for processing
# and close the page # and close the page
self.XHTMLWriter(eventpage, of) self.XHTMLWriter(eventpage, of, sio)
class MediaPage(BasePage): class MediaPage(BasePage):
def __init__(self, report, title, handle, src_list, my_media_list, info): def __init__(self, report, title, handle, src_list, my_media_list, info):
@ -3875,7 +3877,7 @@ class MediaPage(BasePage):
# get media rectangles # get media rectangles
_region_items = self.media_ref_rect_regions(handle) _region_items = self.media_ref_rect_regions(handle)
of = self.report.create_file(handle, "img") of, sio = self.report.create_file(handle, "img")
self.up = True self.up = True
self.src_list = src_list self.src_list = src_list
@ -4103,7 +4105,7 @@ class MediaPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(mediapage, of) self.XHTMLWriter(mediapage, of, sio)
def media_nav_link(self, handle, name, up = False): def media_nav_link(self, handle, name, up = False):
""" """
@ -4163,10 +4165,10 @@ class SurnameListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
if order_by == self.ORDER_BY_NAME: if order_by == self.ORDER_BY_NAME:
of = self.report.create_file(filename) of, sio = self.report.create_file(filename)
surnamelistpage, head, body = self.write_header(_('Surnames')) surnamelistpage, head, body = self.write_header(_('Surnames'))
else: else:
of = self.report.create_file("surnames_count") of, sio = self.report.create_file("surnames_count")
surnamelistpage, head, body = self.write_header(_('Surnames by person count')) surnamelistpage, head, body = self.write_header(_('Surnames by person count'))
# begin surnames division # begin surnames division
@ -4275,7 +4277,7 @@ class SurnameListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(surnamelistpage, of) self.XHTMLWriter(surnamelistpage, of, sio)
def surname_link(self, fname, name, opt_val = None, up = False): def surname_link(self, fname, name, opt_val = None, up = False):
url = self.report.build_url_fname_html(fname, "srn", up) url = self.report.build_url_fname_html(fname, "srn", up)
@ -4291,7 +4293,7 @@ class IntroductionPage(BasePage):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file(report.intro_fname) of, sio = self.report.create_file(report.intro_fname)
intropage, head, body = self.write_header(_('Introduction')) intropage, head, body = self.write_header(_('Introduction'))
# begin Introduction division # begin Introduction division
@ -4317,14 +4319,14 @@ class IntroductionPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(intropage, of) self.XHTMLWriter(intropage, of, sio)
class HomePage(BasePage): class HomePage(BasePage):
def __init__(self, report, title): def __init__(self, report, title):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("index") of, sio = self.report.create_file("index")
homepage, head, body = self.write_header(_('Home')) homepage, head, body = self.write_header(_('Home'))
# begin home division # begin home division
@ -4350,7 +4352,7 @@ class HomePage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(homepage, of) self.XHTMLWriter(homepage, of, sio)
class SourceListPage(BasePage): class SourceListPage(BasePage):
def __init__(self, report, title, handle_set): def __init__(self, report, title, handle_set):
@ -4360,7 +4362,7 @@ class SourceListPage(BasePage):
handle_list = list(handle_set) handle_list = list(handle_set)
source_dict = {} source_dict = {}
of = self.report.create_file("sources") of, sio = self.report.create_file("sources")
sourcelistpage, head, body = self.write_header(_("Sources")) sourcelistpage, head, body = self.write_header(_("Sources"))
# begin source list division # begin source list division
@ -4406,12 +4408,12 @@ class SourceListPage(BasePage):
source, source_handle = source_dict[key] source, source_handle = source_dict[key]
trow = Html("tr") + ( trow = Html("tr") + (
Html("td", index + 1, class_ ="ColumnRowLabel", inline =True) Html("td", index + 1, class_ ="ColumnRowLabel", inline = True)
) )
tbody += trow tbody += trow
trow.extend( trow.extend(
Html("td", self.source_link(source_handle, source.get_title(), Html("td", self.source_link(source_handle, source.get_title(),
source.get_gramps_id()), class_ = "ColumnName") source.get_gramps_id()), class_ ="ColumnName")
) )
# add clearline for proper styling # add clearline for proper styling
@ -4421,7 +4423,7 @@ class SourceListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(sourcelistpage, of) self.XHTMLWriter(sourcelistpage, of, sio)
""" """
# #
@ -4448,7 +4450,7 @@ class SourcePage(BasePage):
inc_repositories = self.report.options["inc_repository"] inc_repositories = self.report.options["inc_repository"]
self.navigation = self.report.options["navigation"] self.navigation = self.report.options["navigation"]
of = self.report.create_file(src_handle, "src") of, sio = self.report.create_file(src_handle, "src")
self.up = True self.up = True
sourcepage, head, body = self.write_header(_('Sources')) sourcepage, head, body = self.write_header(_('Sources'))
@ -4732,7 +4734,7 @@ class SourcePage(BasePage):
if source: if source:
unordered3.extend( unordered3.extend(
Html("li", self.source_link(source_handle, Html("li", self.source_link(source_handle,
source.get_title(), source.get_gramps_id(), source.get_title(), source.get_gramps_id(),
uplink = self.up), inline = True) uplink = self.up), inline = True)
) )
@ -4740,7 +4742,8 @@ class SourcePage(BasePage):
unordered2 += list2 unordered2 += list2
# remove repositories if they are not in this report database... # remove repositories if they are not in this report database...
repo_list = [repo_handle for repo_handle in repo_list if repo_handle in db_repository_handles] repo_list = [repo_handle for repo_handle in repo_list
if repo_handle in db_repository_handles]
# Citation Referents have Repository Objects... # Citation Referents have Repository Objects...
if (inc_repositories and repo_list): if (inc_repositories and repo_list):
@ -4814,14 +4817,14 @@ class SourcePage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(sourcepage, of) self.XHTMLWriter(sourcepage, of, sio)
class MediaListPage(BasePage): class MediaListPage(BasePage):
def __init__(self, report, title, db_media_handles): def __init__(self, report, title, db_media_handles):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("media") of, sio = self.report.create_file("media")
media_listpage, head, body = self.write_header(_('Media')) media_listpage, head, body = self.write_header(_('Media'))
# begin gallery division # begin gallery division
@ -4893,7 +4896,7 @@ class MediaListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(media_listpage, of) self.XHTMLWriter(media_listpage, of, sio)
def media_ref_link(self, handle, name, up = False): def media_ref_link(self, handle, name, up = False):
@ -4935,7 +4938,7 @@ class ThumbnailPreviewPage(BasePage):
media_list.sort() media_list.sort()
# reate thumbnail preview page... # reate thumbnail preview page...
of = self.report.create_file("thumbnails") of, sio = self.report.create_file("thumbnails")
thumbnailpage, head, body = self.write_header(_("Thumbnails")) thumbnailpage, head, body = self.write_header(_("Thumbnails"))
with Html("div", class_ ="content", id ="Preview") as previewpage: with Html("div", class_ ="content", id ="Preview") as previewpage:
@ -5056,7 +5059,7 @@ class ThumbnailPreviewPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(thumbnailpage, of) self.XHTMLWriter(thumbnailpage, of, sio)
def thumbnail_link(self, name, index): def thumbnail_link(self, name, index):
""" """
@ -5109,7 +5112,7 @@ class DownloadPage(BasePage):
# if no filenames at all, return??? # if no filenames at all, return???
if dlfname1 or dlfname2: if dlfname1 or dlfname2:
of = self.report.create_file("download") of, sio = self.report.create_file("download")
downloadpage, head, body = self.write_header(_('Download')) downloadpage, head, body = self.write_header(_('Download'))
# begin download page and table # begin download page and table
@ -5202,14 +5205,14 @@ class DownloadPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(downloadpage, of) self.XHTMLWriter(downloadpage, of, sio)
class ContactPage(BasePage): class ContactPage(BasePage):
def __init__(self, report, title): def __init__(self, report, title):
self.dbase_ = report.database self.dbase_ = report.database
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
of = self.report.create_file("contact") of, sio = self.report.create_file("contact")
contactpage, head, body = self.write_header(_('Contact')) contactpage, head, body = self.write_header(_('Contact'))
# begin contact division # begin contact division
@ -5268,7 +5271,7 @@ class ContactPage(BasePage):
# send page out for porcessing # send page out for porcessing
# and close the file # and close the file
self.XHTMLWriter(contactpage, of) self.XHTMLWriter(contactpage, of, sio)
""" """
# #
@ -5307,7 +5310,7 @@ class IndividualPage(BasePage):
# bio, half, step- siblings for use in display_ind_parents() ... # bio, half, step- siblings for use in display_ind_parents() ...
self.rel_class = rel_class self.rel_class = rel_class
of = self.report.create_file(person.get_handle(), "ppl") of, sio = self.report.create_file(person.get_handle(), "ppl")
self.up = True self.up = True
indivdetpage, head, body = self.write_header(self.sort_name) indivdetpage, head, body = self.write_header(self.sort_name)
@ -5405,7 +5408,15 @@ class IndividualPage(BasePage):
# for use in family map pages... # for use in family map pages...
if len(place_lat_long): if len(place_lat_long):
if self.report.options["familymappages"]: if self.report.options["familymappages"]:
# save of, string_io and cur_fname before creating a new page
sof = of
sstring_io = sio
sfname = self.report.cur_fname
individualdetail += self.__display_family_map(person, place_lat_long) individualdetail += self.__display_family_map(person, place_lat_long)
# restore of, string_io and cur_fname after creating a new page
of = sof
sio = sstring_io
self.report.cur_fname = sfname
# display pedigree # display pedigree
sect13 = self.display_ind_pedigree() sect13 = self.display_ind_pedigree()
@ -5430,7 +5441,7 @@ class IndividualPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(indivdetpage, of) self.XHTMLWriter(indivdetpage, of, sio)
def __create_family_map(self, person, place_lat_long): def __create_family_map(self, person, place_lat_long):
""" """
@ -5442,7 +5453,7 @@ class IndividualPage(BasePage):
if not place_lat_long: if not place_lat_long:
return return
of = self.report.create_file(person.get_handle(), "maps") of, sio = self.report.create_file(person.get_handle(), "maps")
self.up = True self.up = True
familymappage, head, body = self.write_header(_("Family Map")) familymappage, head, body = self.write_header(_("Family Map"))
@ -5672,7 +5683,7 @@ class IndividualPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(familymappage, of) self.XHTMLWriter(familymappage, of, sio)
def __display_family_map(self, person, place_lat_long): def __display_family_map(self, person, place_lat_long):
""" """
@ -6484,7 +6495,7 @@ class RepositoryListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
inc_repos = self.report.options["inc_repository"] inc_repos = self.report.options["inc_repository"]
of = self.report.create_file("repositories") of, sio = self.report.create_file("repositories")
repolistpage, head, body = self.write_header(_("Repositories")) repolistpage, head, body = self.write_header(_("Repositories"))
# begin RepositoryList division # begin RepositoryList division
@ -6542,7 +6553,7 @@ class RepositoryListPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(repolistpage, of) self.XHTMLWriter(repolistpage, of, sio)
#----------------------------------------------------- #-----------------------------------------------------
# #
@ -6555,7 +6566,7 @@ class RepositoryPage(BasePage):
BasePage.__init__(self, report, title, gid) BasePage.__init__(self, report, title, gid)
self.dbase_ = report.database self.dbase_ = report.database
of = self.report.create_file(handle, 'repo') of, sio = self.report.create_file(handle, 'repo')
self.up = True self.up = True
repositorypage, head, body = self.write_header(_('Repositories')) repositorypage, head, body = self.write_header(_('Repositories'))
@ -6611,7 +6622,7 @@ class RepositoryPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(repositorypage, of) self.XHTMLWriter(repositorypage, of, sio)
def __write_referenced_sources(self, handle, source_list): def __write_referenced_sources(self, handle, source_list):
""" """
@ -6660,7 +6671,7 @@ class AddressBookListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
# Name the file, and create it # Name the file, and create it
of = self.report.create_file("addressbook") of, sio = self.report.create_file("addressbook")
# Add xml, doctype, meta and stylesheets # Add xml, doctype, meta and stylesheets
addressbooklistpage, head, body = self.write_header(_("Address Book")) addressbooklistpage, head, body = self.write_header(_("Address Book"))
@ -6744,7 +6755,7 @@ class AddressBookListPage(BasePage):
# send the page out for processing # send the page out for processing
# and close the file # and close the file
self.XHTMLWriter(addressbooklistpage, of) self.XHTMLWriter(addressbooklistpage, of, sio)
class AddressBookPage(BasePage): class AddressBookPage(BasePage):
def __init__(self, report, title, person_handle, has_add, has_res, has_url): def __init__(self, report, title, person_handle, has_add, has_res, has_url):
@ -6756,7 +6767,7 @@ class AddressBookPage(BasePage):
self.up = True self.up = True
# set the file name and open file # set the file name and open file
of = self.report.create_file(person_handle, "addr") of, sio = self.report.create_file(person_handle, "addr")
addressbookpage, head, body = self.write_header(_("Address Book")) addressbookpage, head, body = self.write_header(_("Address Book"))
# begin address book page division and section title # begin address book page division and section title
@ -6788,7 +6799,7 @@ class AddressBookPage(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
self.XHTMLWriter(addressbookpage, of) self.XHTMLWriter(addressbookpage, of, sio)
class NavWebReport(Report): class NavWebReport(Report):
@ -7153,12 +7164,16 @@ class NavWebReport(Report):
if self.inc_gendex: if self.inc_gendex:
self.user.begin_progress(_("Narrated Web Site Report"), self.user.begin_progress(_("Narrated Web Site Report"),
_('Creating GENDEX file'), len(ind_list)) _('Creating GENDEX file'), len(ind_list))
fp_gendex = self.create_file("gendex", ext=".txt") fp_gendex, gendex_io = self.create_file("gendex", ext=".txt")
for person_handle in ind_list: for person_handle in ind_list:
self.user.step_progress() self.user.step_progress()
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
self.write_gendex(fp_gendex, person) self.write_gendex(fp_gendex, person)
self.close_file(fp_gendex) if self.archive:
self.write_gendex(gendex_io, person)
else:
self.write_gendex(fp_gendex, person)
self.close_file(fp_gendex, gendex_io)
self.user.end_progress() self.user.end_progress()
def write_gendex(self, fp, person): def write_gendex(self, fp, person):
@ -7530,10 +7545,11 @@ class NavWebReport(Report):
else: else:
self.cur_fname = fname + ext self.cur_fname = fname + ext
if self.archive: if self.archive:
self.string_io = StringIO() string_io = StringIO()
of = codecs.EncodedFile(self.string_io, 'utf-8', of = codecs.EncodedFile(string_io, 'utf-8',
self.encoding, 'xmlcharrefreplace') self.encoding, 'xmlcharrefreplace')
else: else:
string_io = None
if subdir: if subdir:
subdir = os.path.join(self.html_dir, subdir) subdir = os.path.join(self.html_dir, subdir)
if not os.path.isdir(subdir): if not os.path.isdir(subdir):
@ -7541,27 +7557,25 @@ class NavWebReport(Report):
fname = os.path.join(self.html_dir, self.cur_fname) fname = os.path.join(self.html_dir, self.cur_fname)
of = codecs.EncodedFile(open(fname, "w"), 'utf-8', of = codecs.EncodedFile(open(fname, "w"), 'utf-8',
self.encoding, 'xmlcharrefreplace') self.encoding, 'xmlcharrefreplace')
return of return (of, string_io)
def close_file(self, of): def close_file(self, of, string_io):
""" """
will close any file passed to it will close any file passed to it
""" """
if self.archive: if self.archive:
tarinfo = tarfile.TarInfo(self.cur_fname) tarinfo = tarfile.TarInfo(self.cur_fname)
tarinfo.size = len(self.string_io.getvalue()) tarinfo.size = len(string_io.getvalue())
tarinfo.mtime = time.time() tarinfo.mtime = time.time()
if not constfunc.win(): if not constfunc.win():
tarinfo.uid = os.getuid() tarinfo.uid = os.getuid()
tarinfo.gid = os.getgid() tarinfo.gid = os.getgid()
self.string_io.seek(0) string_io.seek(0)
self.archive.addfile(tarinfo, self.string_io) self.archive.addfile(tarinfo, string_io)
self.string_io = None
of.close() of.close()
else: else:
of.close() of.close()
self.cur_fname = None
def add_lnkref_to_photo(self, photo, lnkref): def add_lnkref_to_photo(self, photo, lnkref):
""" """