Revert*2 "5098: refactor code to use User.progress
Revert*2 means re-apply :-) svn: r23102
This commit is contained in:
parent
0b936041d3
commit
6c6ca1cd20
@ -137,11 +137,11 @@ def diff_dbs(db1, db2, user=None):
|
||||
missing_from_old = []
|
||||
missing_from_new = []
|
||||
diffs = []
|
||||
user.begin_progress(_('Family Tree Differences'),
|
||||
_('Searching...'), 10)
|
||||
with user.progress(_('Family Tree Differences'),
|
||||
_('Searching...'), 10) as step:
|
||||
for item in ['Person', 'Family', 'Source', 'Citation', 'Event', 'Media',
|
||||
'Place', 'Repository', 'Note', 'Tag']:
|
||||
user.step_progress()
|
||||
step()
|
||||
handles1 = sorted(db1._tables[item]["handles_func"]())
|
||||
handles2 = sorted(db2._tables[item]["handles_func"]())
|
||||
p1 = 0
|
||||
@ -172,7 +172,6 @@ def diff_dbs(db1, db2, user=None):
|
||||
item2 = db2._tables[item]["handle_func"](handles2[p2])
|
||||
missing_from_old += [(item, item2)]
|
||||
p2 += 1
|
||||
user.end_progress()
|
||||
return diffs, missing_from_old, missing_from_new
|
||||
|
||||
def diff_db_to_file(old_db, filename, user=None):
|
||||
|
@ -707,8 +707,8 @@ class AncestorTree(Report):
|
||||
self.canvas.report_opts.box_pgap *= self.connect.get_val('box_Yscale')
|
||||
self.canvas.report_opts.box_mgap *= self.connect.get_val('box_Yscale')
|
||||
|
||||
self._user.begin_progress(_('Ancestor Tree'),
|
||||
_('Making the Tree...'), 4)
|
||||
with self._user.progress(_('Ancestor Tree'),
|
||||
_('Making the Tree...'), 4) as step:
|
||||
|
||||
#make the tree onto the canvas
|
||||
inlc_marr = self.connect.get_val("inc_marr")
|
||||
@ -719,7 +719,7 @@ class AncestorTree(Report):
|
||||
tree.start(self.connect.get_val('pid'))
|
||||
tree = None
|
||||
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
#Title
|
||||
title = self.connect.title_class(self.doc)
|
||||
@ -737,7 +737,7 @@ class AncestorTree(Report):
|
||||
self.max_generations = report.get_generations() #already know
|
||||
report = None
|
||||
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
#Note?
|
||||
if self.connect.get_val("inc_note"):
|
||||
@ -756,13 +756,11 @@ class AncestorTree(Report):
|
||||
scale = self.canvas.scale_report(one_page,
|
||||
scale_report != 0, scale_report == 2)
|
||||
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
if scale != 1 or self.connect.get_val('shadowscale') != 1.0:
|
||||
self.scale_styles(scale)
|
||||
|
||||
self._user.end_progress()
|
||||
|
||||
def write_report(self):
|
||||
|
||||
one_page = self.connect.get_val("resize_page")
|
||||
@ -796,8 +794,8 @@ class AncestorTree(Report):
|
||||
#lets finally make some pages!!!
|
||||
#####################
|
||||
pages = self.canvas.page_count(incblank)
|
||||
self._user.begin_progress( _('Ancestor Tree'),
|
||||
_('Printing the Tree...'), pages)
|
||||
with self._user.progress( _('Ancestor Tree'),
|
||||
_('Printing the Tree...'), pages) as step:
|
||||
|
||||
for page in self.canvas.page_iter_gen(incblank):
|
||||
|
||||
@ -814,12 +812,9 @@ class AncestorTree(Report):
|
||||
#Print the individual people and lines
|
||||
page.display()
|
||||
|
||||
self._user.step_progress()
|
||||
step()
|
||||
self.doc.end_page()
|
||||
|
||||
self._user.end_progress()
|
||||
|
||||
|
||||
def scale_styles(self, scale):
|
||||
"""
|
||||
Scale the styles for this report.
|
||||
|
@ -165,12 +165,11 @@ class Calendar(Report):
|
||||
# get data from database:
|
||||
self.collect_data()
|
||||
# generate the report:
|
||||
self._user.begin_progress( _('Calendar Report'),
|
||||
_('Formatting months...'), 12)
|
||||
with self._user.progress( _('Calendar Report'),
|
||||
_('Formatting months...'), 12) as step:
|
||||
for month in range(1, 13):
|
||||
self._user.step_progress()
|
||||
step()
|
||||
self.print_page(month)
|
||||
self._user.end_progress()
|
||||
|
||||
def print_page(self, month):
|
||||
"""
|
||||
@ -268,17 +267,15 @@ class Calendar(Report):
|
||||
"""
|
||||
db = self.database
|
||||
people = db.iter_person_handles()
|
||||
self._user.begin_progress(_('Calendar Report'),
|
||||
with self._user.progress(_('Calendar Report'),
|
||||
_('Applying Filter...'),
|
||||
db.get_number_of_people())
|
||||
people = self.filter.apply(self.database, people,
|
||||
self._user.step_progress)
|
||||
self._user.end_progress()
|
||||
db.get_number_of_people()) as step:
|
||||
people = self.filter.apply(self.database, people, step)
|
||||
|
||||
self._user.begin_progress(_('Calendar Report'),
|
||||
_('Reading database...'), len(people))
|
||||
with self._user.progress(_('Calendar Report'),
|
||||
_('Reading database...'), len(people)) as step:
|
||||
for person_handle in people:
|
||||
self._user.step_progress()
|
||||
step()
|
||||
person = db.get_person_from_handle(person_handle)
|
||||
mark = ReportUtils.get_person_mark(db, person)
|
||||
birth_ref = person.get_birth_ref()
|
||||
@ -395,7 +392,6 @@ class Calendar(Report):
|
||||
if ((self.alive and alive1 and alive2) or not self.alive):
|
||||
self.add_day_item(text, month, day,
|
||||
marks=[mark,s_m])
|
||||
self._user.end_progress()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -123,13 +123,12 @@ class TimeLine(Report):
|
||||
|
||||
def write_report(self):
|
||||
# Apply the filter
|
||||
self._user.begin_progress(_('Timeline'),
|
||||
with self._user.progress(_('Timeline'),
|
||||
_('Applying filter...'),
|
||||
self.database.get_number_of_people())
|
||||
self.database.get_number_of_people()) as step:
|
||||
self.plist = self.filter.apply(self.database,
|
||||
self.database.iter_person_handles(),
|
||||
self._user.step_progress)
|
||||
self._user.end_progress()
|
||||
step)
|
||||
|
||||
# Find the range of dates to include
|
||||
(low, high) = self.find_year_range()
|
||||
@ -150,9 +149,8 @@ class TimeLine(Report):
|
||||
self.header = 2.0
|
||||
|
||||
# Sort the people as requested
|
||||
self._user.begin_progress(_('Timeline'), _('Sorting dates...'), 0)
|
||||
with self._user.progress(_('Timeline'), _('Sorting dates...'), 0) as step:
|
||||
self.plist.sort(key=self.sort_func)
|
||||
self._user.end_progress()
|
||||
|
||||
self.doc.start_page()
|
||||
self.build_grid(low, high, start, stop, True)
|
||||
@ -162,8 +160,8 @@ class TimeLine(Report):
|
||||
|
||||
length = len(self.plist)
|
||||
|
||||
self._user.begin_progress(_('Timeline'),
|
||||
_('Calculating timeline...'), length)
|
||||
with self._user.progress(_('Timeline'),
|
||||
_('Calculating timeline...'), length) as step:
|
||||
|
||||
for p_id in self.plist:
|
||||
p = self.database.get_person_from_handle(p_id)
|
||||
@ -219,9 +217,8 @@ class TimeLine(Report):
|
||||
else:
|
||||
index += 1;
|
||||
current += 1
|
||||
self._user.step_progress()
|
||||
step()
|
||||
self.doc.end_page()
|
||||
self._user.end_progress()
|
||||
|
||||
def build_grid(self, year_low, year_high, start_pos, stop_pos, toc=False):
|
||||
"""
|
||||
@ -343,9 +340,9 @@ class TimeLine(Report):
|
||||
high = year
|
||||
return (low, high)
|
||||
|
||||
self._user.begin_progress(_('Timeline'),
|
||||
with self._user.progress(_('Timeline'),
|
||||
_('Finding date range...'),
|
||||
len(self.plist))
|
||||
len(self.plist)) as step:
|
||||
|
||||
for p_id in self.plist:
|
||||
p = self.database.get_person_from_handle(p_id)
|
||||
@ -358,7 +355,7 @@ class TimeLine(Report):
|
||||
if death:
|
||||
d = death.get_date_object().to_calendar(self.calendar).get_year()
|
||||
(low, high) = min_max_year(low, high, d)
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
# round the dates to the nearest decade
|
||||
if low is not None:
|
||||
@ -376,7 +373,6 @@ class TimeLine(Report):
|
||||
if low is not None and high is not None:
|
||||
low -= 50 - ((high-low) % 50)
|
||||
|
||||
self._user.end_progress()
|
||||
return (low, high)
|
||||
|
||||
def name_size(self):
|
||||
|
@ -324,19 +324,19 @@ class CSVParser(object):
|
||||
|
||||
:param filehandle: open file handle positioned at start of the file
|
||||
"""
|
||||
data = self.read_csv(filehandle)
|
||||
progress_title = _('CSV Import')
|
||||
self.user.begin_progress(progress_title,
|
||||
_('Reading data...'), 1)
|
||||
self.user.end_progress()
|
||||
self.user.begin_progress(progress_title,
|
||||
_('Importing data...'), len(data))
|
||||
with self.user.progress(progress_title,
|
||||
_('Reading data...'), 1) as step:
|
||||
data = self.read_csv(filehandle)
|
||||
|
||||
with self.user.progress(progress_title,
|
||||
_('Importing data...'), len(data)) as step:
|
||||
tym = time.time()
|
||||
self.db.disable_signals()
|
||||
with DbTxn(_("CSV import"), self.db, batch=True) as self.trans:
|
||||
if self.default_tag and self.default_tag.handle is None:
|
||||
self.db.add_tag(self.default_tag, self.trans)
|
||||
self._parse_csv_data(data)
|
||||
self._parse_csv_data(data, step)
|
||||
self.db.enable_signals()
|
||||
self.db.request_rebuild()
|
||||
tym = time.time() - tym
|
||||
@ -345,9 +345,8 @@ class CSVParser(object):
|
||||
LOG.debug(msg)
|
||||
LOG.debug("New Families: %d" % self.fam_count)
|
||||
LOG.debug("New Individuals: %d" % self.indi_count)
|
||||
self.user.end_progress()
|
||||
|
||||
def _parse_csv_data(self, data):
|
||||
def _parse_csv_data(self, data, step):
|
||||
"""Parse each line of the input data and act accordingly."""
|
||||
self.lineno = 0
|
||||
self.index = 0
|
||||
@ -358,7 +357,7 @@ class CSVParser(object):
|
||||
header = None
|
||||
line_number = 0
|
||||
for row in data:
|
||||
self.user.step_progress()
|
||||
step()
|
||||
line_number += 1
|
||||
if "".join(row) == "": # no blanks are allowed inside a table
|
||||
header = None # clear headers, ready for next "table"
|
||||
|
@ -216,12 +216,11 @@ class BirthdayReport(Report):
|
||||
self.doc.write_text(self._("Relationships shown are to %s") %
|
||||
self._name_display.display_name(name), mark)
|
||||
self.doc.end_paragraph()
|
||||
self._user.begin_progress(_('Birthday and Anniversary Report'),
|
||||
_('Formatting months...'), 12)
|
||||
with self._user.progress(_('Birthday and Anniversary Report'),
|
||||
_('Formatting months...'), 12) as step:
|
||||
for month in range(1, 13):
|
||||
self._user.step_progress()
|
||||
step()
|
||||
self.print_page(month)
|
||||
self._user.end_progress()
|
||||
|
||||
def print_page(self, month):
|
||||
""" Prints a month as a page """
|
||||
@ -256,21 +255,20 @@ class BirthdayReport(Report):
|
||||
and text.
|
||||
"""
|
||||
people = self.database.iter_person_handles()
|
||||
self._user.begin_progress(_('Birthday and Anniversary Report'),
|
||||
with self._user.progress(_('Birthday and Anniversary Report'),
|
||||
_('Applying Filter...'),
|
||||
self.database.get_number_of_people())
|
||||
self.database.get_number_of_people()) as step:
|
||||
people = self.filter.apply(self.database, people,
|
||||
self._user.step_progress)
|
||||
self._user.end_progress()
|
||||
step)
|
||||
|
||||
rel_calc = get_relationship_calculator(reinit=True,
|
||||
clocale=self._locale)
|
||||
ngettext = self._locale.translation.ngettext
|
||||
|
||||
self._user.begin_progress(_('Birthday and Anniversary Report'),
|
||||
_('Reading database...'), len(people))
|
||||
with self._user.progress(_('Birthday and Anniversary Report'),
|
||||
_('Reading database...'), len(people)) as step:
|
||||
for person_handle in people:
|
||||
self._user.step_progress()
|
||||
step()
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
birth_ref = person.get_birth_ref()
|
||||
birth_date = None
|
||||
@ -390,7 +388,6 @@ class BirthdayReport(Report):
|
||||
prob_alive_date)
|
||||
if (self.alive and alive1 and alive2) or not self.alive:
|
||||
self.add_day_item(text, month, day, spouse)
|
||||
self._user.end_progress()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -126,9 +126,9 @@ class PlaceReport(Report):
|
||||
"""
|
||||
place_nbr = 1
|
||||
|
||||
self._user.begin_progress(_("Place Report"),
|
||||
with self._user.progress(_("Place Report"),
|
||||
_("Generating report"),
|
||||
len(self.place_handles))
|
||||
len(self.place_handles)) as step:
|
||||
|
||||
for handle in self.place_handles:
|
||||
self.__write_place(handle, place_nbr)
|
||||
@ -140,9 +140,8 @@ class PlaceReport(Report):
|
||||
raise AttributeError("no such center: '%s'" % self.center)
|
||||
place_nbr += 1
|
||||
# increment progress bar
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
self._user.end_progress()
|
||||
|
||||
def __write_place(self, handle, place_nbr):
|
||||
"""
|
||||
|
@ -3037,16 +3037,15 @@ class FamilyPages(BasePage):
|
||||
for item in self.report.obj_dict[Family].items():
|
||||
log.debug(" %s" % str(item))
|
||||
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating family pages..."),
|
||||
len(self.report.obj_dict[Family]) + 1)
|
||||
len(self.report.obj_dict[Family]) + 1) as step:
|
||||
self.FamilyListPage(self.report, title,
|
||||
self.report.obj_dict[Family].keys())
|
||||
|
||||
for family_handle in self.report.obj_dict[Family]:
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.FamilyPage(self.report, title, family_handle)
|
||||
self.report.user.end_progress()
|
||||
|
||||
def FamilyListPage(self, report, title, fam_list):
|
||||
self.dbase_ = report.database
|
||||
@ -3314,17 +3313,16 @@ class PlacePages(BasePage):
|
||||
log.debug("obj_dict[Place]")
|
||||
for item in self.report.obj_dict[Place].items():
|
||||
log.debug(" %s" % str(item))
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating place pages"),
|
||||
len(self.report.obj_dict[Place]) + 1)
|
||||
len(self.report.obj_dict[Place]) + 1) as step:
|
||||
|
||||
self.PlaceListPage(self.report, title,
|
||||
self.report.obj_dict[Place].keys())
|
||||
|
||||
for place_handle in self.report.obj_dict[Place]:
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.PlacePage(self.report, title, place_handle)
|
||||
self.report.user.end_progress()
|
||||
pass
|
||||
|
||||
def PlaceListPage(self, report, title, place_handles):
|
||||
@ -3598,16 +3596,15 @@ class EventPages(BasePage):
|
||||
for event_handle in event_handle_list:
|
||||
event = self.report.database.get_event_from_handle(event_handle)
|
||||
event_types.append(str(event.get_type()))
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating event pages"),
|
||||
len(event_handle_list) + 1)
|
||||
len(event_handle_list) + 1) as step:
|
||||
self.EventListPage(self.report, title, event_types, event_handle_list)
|
||||
|
||||
for event_handle in event_handle_list:
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.EventPage(self.report, title, event_handle)
|
||||
|
||||
self.report.user.end_progress()
|
||||
|
||||
def EventListPage(self, report, title, event_types, event_handle_list):
|
||||
"""
|
||||
@ -4143,17 +4140,16 @@ class SourcePages(BasePage):
|
||||
log.debug("obj_dict[Source]")
|
||||
for item in self.report.obj_dict[Source].items():
|
||||
log.debug(" %s" % str(item))
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating source pages"),
|
||||
len(self.report.obj_dict[Source]) + 1)
|
||||
len(self.report.obj_dict[Source]) + 1) as step:
|
||||
self.SourceListPage(self.report, title,
|
||||
self.report.obj_dict[Source].keys())
|
||||
|
||||
for source_handle in self.report.obj_dict[Source]:
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.SourcePage(self.report, title, source_handle)
|
||||
|
||||
self.report.user.end_progress()
|
||||
|
||||
def SourceListPage(self, report, title, source_handles):
|
||||
"""
|
||||
@ -4358,9 +4354,9 @@ class MediaPages(BasePage):
|
||||
log.debug("obj_dict[Media]")
|
||||
for item in self.report.obj_dict[MediaObject].items():
|
||||
log.debug(" %s" % str(item))
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating media pages"),
|
||||
len(self.report.obj_dict[MediaObject]) + 1)
|
||||
len(self.report.obj_dict[MediaObject]) + 1) as step:
|
||||
|
||||
sorted_media_handles = sorted(self.report.obj_dict[MediaObject].keys(),
|
||||
key=lambda x: SORT_KEY(self.report.database.get_object_from_handle(x).desc))
|
||||
@ -4372,11 +4368,10 @@ class MediaPages(BasePage):
|
||||
for handle in sorted_media_handles:
|
||||
gc.collect() # Reduce memory usage when there are many images.
|
||||
next = None if index == total else sorted_media_handles[index]
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.MediaPage(self.report, title, handle, (prev, next, index, total))
|
||||
prev = handle
|
||||
index += 1
|
||||
self.report.user.end_progress()
|
||||
|
||||
def MediaListPage(self, report, title, sorted_media_handles):
|
||||
"""
|
||||
@ -5157,16 +5152,15 @@ class PersonPages(BasePage):
|
||||
log.debug("obj_dict[Person]")
|
||||
for item in self.report.obj_dict[Person].items():
|
||||
log.debug(" %s" % str(item))
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_('Creating individual pages'),
|
||||
len(self.report.obj_dict[Person]) + 1)
|
||||
len(self.report.obj_dict[Person]) + 1) as step:
|
||||
self.IndividualListPage(self.report, title,
|
||||
self.report.obj_dict[Person].keys())
|
||||
for person_handle in self.report.obj_dict[Person]:
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
person = self.report.database.get_person_from_handle(person_handle)
|
||||
self.IndividualPage(self.report, title, person)
|
||||
self.report.user.end_progress()
|
||||
|
||||
#################################################
|
||||
#
|
||||
@ -6520,9 +6514,9 @@ class RepositoryPages(BasePage):
|
||||
log.debug(" %s" % str(item))
|
||||
|
||||
# set progress bar pass for Repositories
|
||||
self.report.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.report.user.progress(_("Narrated Web Site Report"),
|
||||
_('Creating repository pages'),
|
||||
len(self.report.obj_dict[Repository]) + 1)
|
||||
len(self.report.obj_dict[Repository]) + 1) as step:
|
||||
# Sort the repositories
|
||||
repos_dict = {}
|
||||
for repository_handle in self.report.obj_dict[Repository]:
|
||||
@ -6538,9 +6532,8 @@ class RepositoryPages(BasePage):
|
||||
for index, key in enumerate(keys):
|
||||
(repo, handle) = repos_dict[key]
|
||||
|
||||
self.report.user.step_progress()
|
||||
step()
|
||||
self.RepositoryPage(self.report, title, repo, handle)
|
||||
self.report.user.end_progress()
|
||||
|
||||
def RepositoryListPage(self, report, title, repos_dict, keys):
|
||||
self.dbase_ = report.database
|
||||
@ -7137,24 +7130,22 @@ class NavWebReport(Report):
|
||||
self.obj_dict[obj_class] = defaultdict(set)
|
||||
|
||||
ind_list = self.database.iter_person_handles()
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_('Applying Person Filter...'),
|
||||
self.database.get_number_of_people())
|
||||
self.database.get_number_of_people()) as step:
|
||||
ind_list = self.filter.apply(self.database, ind_list,
|
||||
self.user.step_progress)
|
||||
self.user.end_progress()
|
||||
step)
|
||||
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_('Constructing list of other objects...'),
|
||||
sum(1 for _ in ind_list))
|
||||
sum(1 for _ in ind_list)) as step:
|
||||
for handle in ind_list:
|
||||
# FIXME work around bug that self.database.iter under python 3
|
||||
# returns (binary) data rather than text
|
||||
if not isinstance(handle, UNITYPE):
|
||||
handle = handle.decode('utf-8')
|
||||
self.user.step_progress()
|
||||
step()
|
||||
self._add_person(handle, "", "")
|
||||
self.user.end_progress()
|
||||
|
||||
log.debug("final object dictionary \n" +
|
||||
"".join(("%s: %s\n" % item) for item in self.obj_dict.items()))
|
||||
@ -7563,11 +7554,11 @@ class NavWebReport(Report):
|
||||
|
||||
def build_gendex(self, ind_list):
|
||||
if self.inc_gendex:
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
_('Creating GENDEX file'), len(ind_list))
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_('Creating GENDEX file'), len(ind_list)) as step:
|
||||
fp_gendex, gendex_io = self.create_file("gendex", ext=".txt")
|
||||
for person_handle in ind_list:
|
||||
self.user.step_progress()
|
||||
step()
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
self.write_gendex(fp_gendex, person)
|
||||
if self.archive:
|
||||
@ -7575,7 +7566,6 @@ class NavWebReport(Report):
|
||||
else:
|
||||
self.write_gendex(fp_gendex, person)
|
||||
self.close_file(fp_gendex, gendex_io)
|
||||
self.user.end_progress()
|
||||
|
||||
def write_gendex(self, fp, person):
|
||||
"""
|
||||
@ -7608,8 +7598,8 @@ class NavWebReport(Report):
|
||||
"""
|
||||
local_list = sort_people(self.database, ind_list)
|
||||
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
_("Creating surname pages"), len(local_list))
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating surname pages"), len(local_list)) as step:
|
||||
|
||||
SurnameListPage(self, self.title, ind_list, SurnameListPage.ORDER_BY_NAME,
|
||||
self.surname_fname)
|
||||
@ -7619,18 +7609,16 @@ class NavWebReport(Report):
|
||||
|
||||
for (surname, handle_list) in local_list:
|
||||
SurnamePage(self, self.title, surname, handle_list)
|
||||
self.user.step_progress()
|
||||
self.user.end_progress()
|
||||
step()
|
||||
|
||||
def thumbnail_preview_page(self):
|
||||
"""
|
||||
creates the thumbnail preview page
|
||||
"""
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating thumbnail preview page..."),
|
||||
len(self.obj_dict[MediaObject]))
|
||||
ThumbnailPreviewPage(self, self.title, self.user.step_progress)
|
||||
self.user.end_progress()
|
||||
len(self.obj_dict[MediaObject])) as step:
|
||||
ThumbnailPreviewPage(self, self.title, step)
|
||||
|
||||
def addressbook_pages(self, ind_list):
|
||||
"""
|
||||
@ -7668,13 +7656,12 @@ class NavWebReport(Report):
|
||||
# begin Address Book pages
|
||||
addr_size = len(url_addr_res)
|
||||
|
||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||
with self.user.progress(_("Narrated Web Site Report"),
|
||||
_("Creating address book pages ..."),
|
||||
addr_size)
|
||||
addr_size) as step:
|
||||
for (sort_name, person_handle, add, res, url) in url_addr_res:
|
||||
AddressBookPage(self, self.title, person_handle, add, res, url)
|
||||
self.user.step_progress()
|
||||
self.user.end_progress()
|
||||
step()
|
||||
|
||||
def base_pages(self):
|
||||
"""
|
||||
|
@ -296,9 +296,9 @@ class WebCalReport(Report):
|
||||
def __get_holidays(self, year):
|
||||
|
||||
# _('translation')
|
||||
self._user.begin_progress(_("Web Calendar Report"),
|
||||
with self._user.progress(_("Web Calendar Report"),
|
||||
(_('Calculating Holidays for year %04d') % year),
|
||||
365)
|
||||
365) as step:
|
||||
|
||||
""" Get the holidays for the specified country and year """
|
||||
holiday_table = libholiday.HolidayTable()
|
||||
@ -309,8 +309,7 @@ class WebCalReport(Report):
|
||||
holiday_names = holiday_table.get_holidays(month, day)
|
||||
for holiday_name in holiday_names:
|
||||
self.add_day_item(holiday_name, year, month, day, 'Holiday')
|
||||
self._user.step_progress()
|
||||
self._user.end_progress()
|
||||
step()
|
||||
|
||||
def copy_calendar_files(self):
|
||||
"""
|
||||
@ -839,8 +838,8 @@ class WebCalReport(Report):
|
||||
|
||||
nr_up = 1 # Number of directory levels up to get to self.html_dir / root
|
||||
|
||||
self._user.begin_progress(_("Web Calendar Report"),
|
||||
_('Formatting months ...'), 12)
|
||||
with self._user.progress(_("Web Calendar Report"),
|
||||
_('Formatting months ...'), 12) as step:
|
||||
|
||||
for month in range(1, 13):
|
||||
cal_fname = _dd.long_months[month]
|
||||
@ -890,8 +889,7 @@ class WebCalReport(Report):
|
||||
# and close the file
|
||||
self.XHTMLWriter(webcal, of)
|
||||
|
||||
self._user.step_progress()
|
||||
self._user.end_progress()
|
||||
step()
|
||||
|
||||
def year_glance(self, year):
|
||||
"""
|
||||
@ -902,8 +900,8 @@ class WebCalReport(Report):
|
||||
nr_up = 1 # Number of directory levels up to get to root
|
||||
|
||||
# generate progress pass for "Year At A Glance"
|
||||
self._user.begin_progress(_("Web Calendar Report"),
|
||||
_('Creating Year At A Glance calendar'), 12)
|
||||
with self._user.progress(_("Web Calendar Report"),
|
||||
_('Creating Year At A Glance calendar'), 12) as step:
|
||||
|
||||
of = self.create_file('fullyearlinked', str(year))
|
||||
|
||||
@ -940,7 +938,7 @@ class WebCalReport(Report):
|
||||
content += monthly_calendar
|
||||
|
||||
# increase progress bar
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
# create blank line for stylesheets
|
||||
# write footer section
|
||||
@ -950,7 +948,6 @@ class WebCalReport(Report):
|
||||
# send calendar page to web output
|
||||
# and close the file
|
||||
self.XHTMLWriter(yearglance, of)
|
||||
self._user.end_progress()
|
||||
|
||||
def one_day(self, event_date, fname_date, day_list):
|
||||
"""
|
||||
@ -1083,16 +1080,15 @@ class WebCalReport(Report):
|
||||
db = self.database
|
||||
|
||||
people = db.iter_person_handles()
|
||||
self._user.begin_progress(_("Web Calendar Report"),
|
||||
with self._user.progress(_("Web Calendar Report"),
|
||||
_('Applying Filter...'),
|
||||
db.get_number_of_people())
|
||||
people = self.filter.apply(db, people, self._user.step_progress)
|
||||
self._user.end_progress()
|
||||
db.get_number_of_people()) as step:
|
||||
people = self.filter.apply(db, people, step_progress)
|
||||
|
||||
self._user.begin_progress(_("Web Calendar Report"),
|
||||
_("Reading database..."), len(people))
|
||||
with self._user.progress(_("Web Calendar Report"),
|
||||
_("Reading database..."), len(people)) as step:
|
||||
for person in map(db.get_person_from_handle, people):
|
||||
self._user.step_progress()
|
||||
step()
|
||||
|
||||
family_list = person.get_family_handle_list()
|
||||
birth_ref = person.get_birth_ref()
|
||||
@ -1190,7 +1186,6 @@ class WebCalReport(Report):
|
||||
'person' : short_name}
|
||||
|
||||
self.add_day_item(text, year, month, day, 'Anniversary')
|
||||
self._user.end_progress()
|
||||
|
||||
def write_footer(self, nr_up):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user