Ejemplo n.º 1
0
def get_attributes(person, event_handle):
    """
    Return the row number of the person in the census along with a
    dictionary of attributes.
    """
    attrs = {}
    order = None
    for event_ref in person.get_event_ref_list():
        if event_ref.ref == event_handle:
            for attr in event_ref.get_attribute_list():
                if str(attr.get_type()) == ORDER_ATTR:
                    order = int(attr.get_value())
                else:
                    attrs[str(attr.get_type())] = attr.get_value()

    return (order, name_displayer.display_formal(person), attrs)
Ejemplo n.º 2
0
def get_attributes(person, event_handle):
    """
    Return the row number of the person in the census along with a
    dictionary of attributes.
    """
    attrs = {}
    order = None
    for event_ref in person.get_event_ref_list():
        if event_ref.ref == event_handle:
            for attr in event_ref.get_attribute_list():
                if cuni(attr.get_type()) == ORDER_ATTR:
                    order = int(attr.get_value())
                else:
                    attrs[cuni(attr.get_type())] = attr.get_value()

    return (order, name_displayer.display_formal(person), attrs)
Ejemplo n.º 3
0
    def write_report(self):
        """
        The routine the actually creates the report. At this point, the document
        is opened and ready for writing.
        """

        # Title
        name = name_displayer.display_formal(self.person)
        title = _("Census Report for %s") % name
        mark = IndexMark(title, INDEX_TYPE_TOC, 1)        
        self.doc.start_paragraph("CEN-Title")
        self.doc.write_text(title, mark)
        self.doc.end_paragraph()

        self.first_page = True
        if self.report_type in (TYPE_ALL, TYPE_SOURCE):
            for handle in self.database.get_event_handles():
                self.check_event(handle)
        else:
            for event_ref in self.person.get_event_ref_list():
                self.check_event(event_ref.ref)
Ejemplo n.º 4
0
    def write_report(self):
        """
        The routine the actually creates the report. At this point, the document
        is opened and ready for writing.
        """

        # Title
        name = name_displayer.display_formal(self.person)
        title = _("Census Report for %s") % name
        mark = IndexMark(title, INDEX_TYPE_TOC, 1)        
        self.doc.start_paragraph("CEN-Title")
        self.doc.write_text(title, mark)
        self.doc.end_paragraph()

        self.first_page = True
        if self.report_type in (TYPE_ALL, TYPE_SOURCE):
            for handle in self.database.get_event_handles():
                self.check_event(handle)
        else:
            for event_ref in self.person.get_event_ref_list():
                self.check_event(event_ref.ref)
    def add_menu_options(self, menu):
        """
        Add options to the menu for the ancestral collapsible tree report.
        """
        category_name = _("Ancestral Collapsible Tree Options")

        pid = PersonOption(_("Center Person"))
        pid.set_help(_("The center person for the report"))
        menu.add_option(category_name, "pid", pid)

        pid = menu.get_option_by_name('pid').get_value()
        center_person = self._dbase.get_person_from_gramps_id(
            menu.get_option_by_name('pid').get_value())
        if center_person :
            name_str = global_name_display.display_formal(center_person)
        else:
            name_str = ""

        # We must figure out the value of the first option before we can
        # create the EnumeratedListOption
        fmt_list = global_name_display.get_name_format()
        name_format = EnumeratedListOption(_("Name format"), 0)
        name_format.add_item(0, _("Default"))
        for num, name, fmt_str, act in fmt_list:
            name_format.add_item(num, name)
        name_format.set_help(_("Select the format to display names"))
        menu.add_option(category_name, "name_format", name_format)

        self.maxgen = NumberOption(_("Include Generations"), 10, 1, 100)
        self.maxgen.set_help(_("The number of generations to include in the " +
            "report"))
        menu.add_option(category_name, "maxgen", self.maxgen)
        self.maxgen.connect('value-changed', self.validate_gen)

        male_bg = ColorOption(_("Male Background Color"), "#ffffff")
        male_bg.set_help(_("RGB-color for male box background."))
        menu.add_option(category_name, "male_bg", male_bg)

        exp_male_bg = ColorOption(_("Male Expandable Background Color"),
            "#B4C4D9")
        exp_male_bg.set_help(_("RGB-color for male expandable box background."))
        menu.add_option(category_name, "exp_male_bg", exp_male_bg)

        female_bg = ColorOption(_("Female Background"), "#ffffff")
        female_bg.set_help(_("RGB-color for female box background."))
        menu.add_option(category_name, "female_bg", female_bg)

        exp_female_bg = ColorOption(_("Female Expandable Background"),
            "#F0D5D7")
        exp_female_bg.set_help(_("RGB-color for female expandable box " +
            "background."))
        menu.add_option(category_name, "exp_female_bg", exp_female_bg)

        dest_path = DestinationOption(_("Destination"),
            config.get('paths.website-directory'))
        dest_path.set_help(_("The destination path for generated files."))
        dest_path.set_directory_entry(True)
        menu.add_option(category_name, "dest_path", dest_path)

        dest_file = StringOption(_("Filename"), "AncestralCollapsible.html")
        dest_file.set_help(_("The destination file name for html content."))
        menu.add_option(category_name, "dest_file", dest_file)
Ejemplo n.º 6
0
    def add_menu_options(self, menu):
        """
        Add options to the menu for the ancestral collapsible tree report.
        """
        category_name = _("Ancestral Collapsible Tree Options")

        pid = PersonOption(_("Center Person"))
        pid.set_help(_("The center person for the report"))
        menu.add_option(category_name, "pid", pid)

        pid = menu.get_option_by_name('pid').get_value()
        center_person = self._dbase.get_person_from_gramps_id(
            menu.get_option_by_name('pid').get_value())
        if center_person:
            name_str = global_name_display.display_formal(center_person)
        else:
            name_str = ""

        # We must figure out the value of the first option before we can
        # create the EnumeratedListOption
        fmt_list = global_name_display.get_name_format()
        name_format = EnumeratedListOption(_("Name format"), 0)
        name_format.add_item(0, _("Default"))
        for num, name, fmt_str, act in fmt_list:
            name_format.add_item(num, name)
        name_format.set_help(_("Select the format to display names"))
        menu.add_option(category_name, "name_format", name_format)

        self.maxgen = NumberOption(_("Include Generations"), 10, 1, 100)
        self.maxgen.set_help(
            _("The number of generations to include in the " + "report"))
        menu.add_option(category_name, "maxgen", self.maxgen)
        self.maxgen.connect('value-changed', self.validate_gen)

        male_bg = ColorOption(_("Male Background Color"), "#ffffff")
        male_bg.set_help(_("RGB-color for male box background."))
        menu.add_option(category_name, "male_bg", male_bg)

        exp_male_bg = ColorOption(_("Male Expandable Background Color"),
                                  "#B4C4D9")
        exp_male_bg.set_help(
            _("RGB-color for male expandable box background."))
        menu.add_option(category_name, "exp_male_bg", exp_male_bg)

        female_bg = ColorOption(_("Female Background"), "#ffffff")
        female_bg.set_help(_("RGB-color for female box background."))
        menu.add_option(category_name, "female_bg", female_bg)

        exp_female_bg = ColorOption(_("Female Expandable Background"),
                                    "#F0D5D7")
        exp_female_bg.set_help(
            _("RGB-color for female expandable box " + "background."))
        menu.add_option(category_name, "exp_female_bg", exp_female_bg)

        dest_path = DestinationOption(_("Destination"),
                                      config.get('paths.website-directory'))
        dest_path.set_help(_("The destination path for generated files."))
        dest_path.set_directory_entry(True)
        menu.add_option(category_name, "dest_path", dest_path)

        dest_file = StringOption(_("Filename"), "AncestralCollapsible.html")
        dest_file.set_help(_("The destination file name for html content."))
        menu.add_option(category_name, "dest_file", dest_file)
Ejemplo n.º 7
0
    def __init__(self, database, options, user):
        """
        Initialize the report class.

        database        - the GRAMPS database instance
        options         - instance of the Options class for this report
        user            - a gramps.gen.user.User() instance

        """

        Report.__init__(self, database, options, user)

        menu = options.menu

        # BUG: somehow when calculating if we've reached the max
        # generations limit the report is stopping at one generation
        # before the max requested, so I'm bumping this up by one to
        # compensate until I find where the calculation is wrong.
        self.max_generations = menu.get_option_by_name('maxgen').get_value() + 1

        pid = menu.get_option_by_name('pid').get_value()
        self.center_person = database.get_person_from_gramps_id(pid)
        if (self.center_person == None) :
            raise ReportError(_("Person %s is not in the Database") % pid )

        self.show_parent_tags = menu.get_option_by_name('showcaptions').get_value()
        self.parent_tag_len = pt2cm(self.doc.string_width(self.get_font('PC-box'), _("Mother")))
        self.parent_tag_height = self.get_font_height('PC-box')

        name = name_displayer.display_formal(self.center_person)
        self.title = _("Pedigree Chart for %s") % name

        report_date = Date()
        report_date.set_yr_mon_day(*time.localtime()[0:3])
        # researcher = self.database.get_researcher()

#        self.footer = escape("%s: %s <%s>\n%s" % (_('Researcher'),
#                             researcher.get_name(),
#                             researcher.get_email(),
#                             gramps.gen.datehandler.displayer.display(report_date)))
        self.footer = gramps.gen.datehandler.displayer.display(report_date)

        self.map = {}
        self.page_number = PageCounter(1)
        self.page_link_counter = PageCounter(2)
        self.generation_index = 1

        page_width = self.doc.get_usable_width()
        page_height = self.doc.get_usable_height()

        self.columns = [_GUTTER_SIZE,
            page_width *  6 / 40,
            page_width * 12 / 40,
            page_width * 25 / 40,
            page_width * 32 / 40
            ]

        #print "[DEBUG] page_width = %s, columns = %s" % (page_width, self.columns)

        # The third column (index 2) has the smallest space available, so I
        # base the box sizes on it.
        #self.em_size = pt2cm(self.doc.string_width(self.get_font('PC-box'), 'm'))
        self.max_box_size = self.columns[3] - self.columns[2] - _GUTTER_SIZE
        #self.name_max_len = self.max_box_size / self.em_size

        #print "[DEBUG] columns", repr(self.columns)
        #print "[DEBUG] em size: %s, max_box_size: %s, max_name_len: %s" % (self.em_size, self.max_box_size, self.name_max_len)

        self.coordinates = { 1: (self.columns[0], page_height * 32 / 64),
                        # second generation
                        2: (self.columns[1], page_height * 16 / 64),
                        3: (self.columns[1], page_height * 48 / 64),
                        # third generation
                        4: (self.columns[2], page_height * 8 / 64),
                        5: (self.columns[2], page_height * 24 / 64),
                        6: (self.columns[2], page_height * 40 / 64),
                        7: (self.columns[2], page_height * 56 / 64),
                        # fourth generation
                        8: (self.columns[3], page_height * 4 / 64),    #  3/64
                        9: (self.columns[3], page_height * 13 / 64),   # 15/64
                        10: (self.columns[3], page_height * 20 / 64),  # 20/64
                        11: (self.columns[3], page_height * 28 / 64),  # 30
                        12: (self.columns[3], page_height * 36 / 64),  # 35
                        13: (self.columns[3], page_height * 45 / 64),  # 47
                        14: (self.columns[3], page_height * 52 / 64),  # 51
                        15: (self.columns[3], page_height * 60 / 64)   # 60
        }