def init_report_options_help(self): """ Initialize help for the options that are defined by each report. (And also any docgen options, if defined by the docgen.) """ if not hasattr(self.option_class, "menu"): return menu = self.option_class.menu for name in menu.get_all_option_names(): option = menu.get_option_by_name(name) self.options_help[name] = ["", option.get_help()] if isinstance(option, PersonOption): id_list = [] for person_handle in self.database.get_person_handles(True): person = self.database.get_person_from_handle(person_handle) id_list.append("%s\t%s" % (person.get_gid(), name_displayer.display(person))) self.options_help[name].append(id_list) elif isinstance(option, FamilyOption): id_list = [] for family in self.database.iter_families(): mname = "" fname = "" mhandle = family.get_mother_handle() if mhandle: mother = self.database.get_person_from_handle(mhandle) if mother: mname = name_displayer.display(mother) fhandle = family.get_father_handle() if fhandle: father = self.database.get_person_from_handle(fhandle) if father: fname = name_displayer.display(father) text = "%s:\t%s, %s" % (family.get_gid(), fname, mname) id_list.append(text) self.options_help[name].append(id_list) elif isinstance(option, NoteOption): id_list = [] for nhandle in self.database.get_note_handles(): note = self.database.get_note_from_handle(nhandle) id_list.append(note.get_gid()) self.options_help[name].append(id_list) elif isinstance(option, MediaOption): id_list = [] for mhandle in self.database.get_media_handles(): mobject = self.database.get_media_from_handle(mhandle) id_list.append(mobject.get_gid()) self.options_help[name].append(id_list) elif isinstance(option, PersonListOption): self.options_help[name].append("") elif isinstance(option, NumberOption): self.options_help[name].append("A number") elif isinstance(option, BooleanOption): self.options_help[name].append(["False", "True"]) elif isinstance(option, DestinationOption): self.options_help[name].append("A file system path") elif isinstance(option, StringOption): self.options_help[name].append("Any text") elif isinstance(option, TextOption): self.options_help[name].append( "A list of text values. Each entry in the list " "represents one line of text.") elif isinstance(option, EnumeratedListOption): ilist = [] for (value, description) in option.get_items(): tabs = '\t' try: tabs = '\t\t' if len(value) < 10 else '\t' except TypeError: #Value is a number, use just one tab. pass val = "%s%s%s" % (value, tabs, description) ilist.append(val) self.options_help[name].append(ilist) elif isinstance(option, Option): self.options_help[name].append(option.get_help()) else: print(_("Unknown option: %s") % option, file=sys.stderr) print(_(" Valid options are:") + ", ".join(list(self.options_dict.keys())), file=sys.stderr) print(_(" Use '%(donottranslate)s' to see description " "and acceptable values" ) % {'donottranslate' : "show=option"}, file=sys.stderr)
def get_subject(self): """ Return a string that describes the subject of the report. """ gid = self.__pid.get_value() person = self.__db.get_person_from_gid(gid) return _nd.display(person)