示例#1
0
def export_file(db, filename, user):
    """
    Export the db to a file (such as a GEDCOM file).

    >>> export_file(DbDjango(), "/home/user/Untitled_1.ged", User())
    """
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False, user=user) # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    export_list = pmgr.get_reg_exporters()
    for pdata in export_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    etype, exception, traceback = error_tuple
                    print("ERROR:", name, exception)
                return False
            export_function = getattr(mod, pdata.export_function)
            export_function(db, filename, user)
            return True
    return False
示例#2
0
class Gramps:
    def __init__(self, user=None, dbstate=None):
        ## Setup:
        from gramps.cli.clidbman import CLIDbManager
        self.dbstate = dbstate or DbState()
        #we need a manager for the CLI session
        self.user = user or User(auto_accept=True, quiet=False)
        self.climanager = CLIManager(self.dbstate,
                                     setloader=True,
                                     user=self.user)
        self.clidbmanager = CLIDbManager(self.dbstate)

    def run(self, *args, stdin=None):
        with capture(stdin) as output:
            #load the plugins
            self.climanager.do_reg_plugins(self.dbstate, uistate=None)
            # handle the arguments
            args = [sys.executable] + list(args)
            argparser = ArgParser(args)
            argparser.need_gui()  # initializes some variables
            if argparser.errors:
                print(argparser.errors, file=sys.stderr)
            argparser.print_help()
            argparser.print_usage()
            handler = ArgHandler(self.dbstate, argparser, self.climanager)
            # create a manager to manage the database
            handler.handle_args_cli()
            if handler.dbstate.is_open():
                handler.dbstate.db.close()
        return output
示例#3
0
class Gramps:
    def __init__(self, user=None, dbstate=None):
        ## Setup:
        from gramps.cli.clidbman import CLIDbManager
        self.dbstate = dbstate or DbState()
        #we need a manager for the CLI session
        self.user = user or User(auto_accept=True, quiet=False)
        self.climanager = CLIManager(self.dbstate, setloader=True, user=self.user)
        self.clidbmanager = CLIDbManager(self.dbstate)

    def run(self, *args, stdin=None):
        with capture(stdin) as output:
            #load the plugins
            self.climanager.do_reg_plugins(self.dbstate, uistate=None)
            # handle the arguments
            args = [sys.executable] + list(args)
            argparser = ArgParser(args)
            argparser.need_gui() # initializes some variables
            argparser.print_help()
            argparser.print_usage()
            handler = ArgHandler(self.dbstate, argparser, self.climanager)
            # create a manager to manage the database
            handler.handle_args_cli()
            if handler.dbstate.is_open():
                handler.dbstate.db.close()
        return output
示例#4
0
文件: diff.py 项目: cicl06/gramps
def import_as_dict(filename, user=None):
    """
    Import the filename into a DictionaryDb and return it.
    """
    if user is None:
        user = User()
    db = DictionaryDb()
    db.load(None)
    db.set_feature("skip-import-additions", True)
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False, user=user)
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    import_list = pmgr.get_reg_importers()
    for pdata in import_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    # (filename, (exception-type, exception, traceback), pdata)
                    etype, exception, traceback = error_tuple
                    #print("ERROR:", name, exception)
                return False
            import_function = getattr(mod, pdata.import_function)
            results = import_function(db, filename, user)
            if results is None:
                return None
            return db
    return None
示例#5
0
def import_as_dict(filename, user=None):
    """
    Import the filename into a InMemoryDB and return it.
    """
    if user is None:
        user = User()
    db = make_database("inmemorydb")
    db.load(None)
    db.set_feature("skip-import-additions", True)
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False, user=user)
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    import_list = pmgr.get_reg_importers()
    for pdata in import_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    # (filename, (exception-type, exception, traceback), pdata)
                    etype, exception, traceback = error_tuple
                    #print("ERROR:", name, exception)
                return False
            import_function = getattr(mod, pdata.import_function)
            results = import_function(db, filename, user)
            if results is None:
                return None
            return db
    return None
示例#6
0
def export_file(db, filename, user):
    """
    Export the db to a file (such as a GEDCOM file).

    >>> export_file(DbDjango(), "/home/user/Untitled_1.ged", User())
    """
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False,
                            user=user)  # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    export_list = pmgr.get_reg_exporters()
    for pdata in export_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    etype, exception, traceback = error_tuple
                    print("ERROR:", name, exception)
                return False
            export_function = getattr(mod, pdata.export_function)
            export_function(db, filename, user)
            return True
    return False
示例#7
0
def import_file(db, filename, user):
    """
    Import a file (such as a GEDCOM file) into the given db.

    >>> import_file(DbDjango(), "/home/user/Untitled_1.ged", User())
    """
    from .grampsdb.models import Person
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False, user=user) # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    import_list = pmgr.get_reg_importers()
    for pdata in import_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    # (filename, (exception-type, exception, traceback), pdata)
                    etype, exception, traceback = error_tuple
                    print("ERROR:", name, exception)
                return False
            import_function = getattr(mod, pdata.import_function)
            #db.prepare_import()
            retval = import_function(db, filename, user)
            #db.commit_import()
            return retval
    return False
示例#8
0
def import_file(db, filename, user):
    """
    Import a file (such as a GEDCOM file) into the given db.

    >>> import_file(DbDjango(), "/home/user/Untitled_1.ged", User())
    """
    from .grampsdb.models import Person
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False,
                            user=user)  # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    (name, ext) = os.path.splitext(os.path.basename(filename))
    format = ext[1:].lower()
    import_list = pmgr.get_reg_importers()
    for pdata in import_list:
        if format == pdata.extension:
            mod = pmgr.load_plugin(pdata)
            if not mod:
                for item in pmgr.get_fail_list():
                    name, error_tuple, pdata = item
                    # (filename, (exception-type, exception, traceback), pdata)
                    etype, exception, traceback = error_tuple
                    print("ERROR:", name, exception)
                return False
            import_function = getattr(mod, pdata.import_function)
            db.prepare_import()
            retval = import_function(db, filename, user)
            db.commit_import()
            return retval
    return False
示例#9
0
 def __rebuild_reg_list(self, path=None, rescan=True):
     self._selection_reg.handler_block(self._cursor_hndlr)
     self._model_reg.clear()
     if rescan:
         CLIManager.do_reg_plugins(self, self.dbstate, self.uistate,
                                   rescan=True)
     self.__populate_reg_list()
     self._selection_reg.handler_unblock(self._cursor_hndlr)
     if not path or int(str(path)) >= len(self._model_reg):
         path = '0'
     self._selection_reg.select_path(path)
     if len(self._model_reg):
         self._list_reg.scroll_to_cell(path, None, True, 0.5, 0)
示例#10
0
 def __rebuild_reg_list(self, path=None, rescan=True):
     self._selection_reg.handler_block(self._cursor_hndlr)
     self._model_reg.clear()
     if rescan:
         CLIManager.do_reg_plugins(self, self.dbstate, self.uistate,
                                   rescan=True)
     self.__populate_reg_list()
     self._selection_reg.handler_unblock(self._cursor_hndlr)
     if not path or int(str(path)) >= len(self._model_reg):
         path = '0'
     self._selection_reg.select_path(path)
     if len(self._tree_filter):
         self._list_reg.scroll_to_cell(path, None, True, 0.5, 0)
         self._cursor_changed(None)
示例#11
0
 def __init__(self, name: str = None) -> None:
     """Prepare and import the example DB."""
     ExampleDbBase.__init__(self)
     self.db_path = os.path.join(os.environ["GRAMPSHOME"], "gramps",
                                 "grampsdb")
     os.makedirs(self.db_path, exist_ok=True)
     setconfig("database.path", self.db_path)
     dbstate = DbState()
     dbman = CLIDbManager(dbstate)
     user = User()
     smgr = CLIManager(dbstate, True, user)
     smgr.do_reg_plugins(dbstate, uistate=None)
     self.path, self.name = dbman.import_new_db(self.path, User())
     WebDbManager.__init__(self, self.name)
示例#12
0
def get_plugin_options(db, pid):
    """
    Get the default options and help for this plugin.
    """
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False, user=GUser()) # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    pdata = pmgr.get_plugin(pid)
    if hasattr(pdata, "optionclass") and pdata.optionclass:
        mod = pmgr.load_plugin(pdata)
        optionclass = eval("mod." + pdata.optionclass)
        optioninstance = optionclass("Name", db)
        optioninstance.load_previous_values()
        return optioninstance.options_dict, optioninstance.options_help
    else:
        return {}, {}
示例#13
0
class Gramps:
    def __init__(self, user=None, dbstate=None):
        ## Setup:
        from gramps.cli.clidbman import CLIDbManager
        self.dbstate = dbstate or DbState()
        #we need a manager for the CLI session
        self.user = user or User(auto_accept=True, quiet=False)
        self.climanager = CLIManager(self.dbstate,
                                     setloader=True,
                                     user=self.user)
        self.clidbmanager = CLIDbManager(self.dbstate)

    def run(self, *args, stdin=None, bytesio=False):
        with capture(stdin, bytesio=bytesio) as output:
            try:
                try:  # make sure we have user directories
                    for path in USER_DIRLIST:
                        if not os.path.isdir(path):
                            os.makedirs(path)
                except OSError as msg:
                    print("Error creating user directories: " + str(msg))
                except:
                    print("Error reading configuration.", exc_info=True)
                #load the plugins
                self.climanager.do_reg_plugins(self.dbstate, uistate=None)
                # handle the arguments
                args = [sys.executable] + list(args)
                argparser = ArgParser(args)
                argparser.need_gui()  # initializes some variables
                if argparser.errors:
                    print(argparser.errors, file=sys.stderr)
                argparser.print_help()
                argparser.print_usage()
                handler = ArgHandler(self.dbstate, argparser, self.climanager)
                # create a manager to manage the database
                handler.handle_args_cli()
                if handler.dbstate.is_open():
                    handler.dbstate.db.close()
            except:
                print("Exception in test:")
                print("-" * 60)
                traceback.print_exc(file=sys.stdout)
                print("-" * 60)

        return output
示例#14
0
def get_plugin_options(db, pid):
    """
    Get the default options and help for this plugin.
    """
    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=False,
                            user=GUser())  # do not load db_loader
    climanager.do_reg_plugins(dbstate, None)
    pmgr = BasePluginManager.get_instance()
    pdata = pmgr.get_plugin(pid)
    if hasattr(pdata, "optionclass") and pdata.optionclass:
        mod = pmgr.load_plugin(pdata)
        optionclass = eval("mod." + pdata.optionclass)
        optioninstance = optionclass("Name", db)
        optioninstance.load_previous_values()
        return optioninstance.options_dict, optioninstance.options_help
    else:
        return {}, {}
示例#15
0
class Gramps:
    def __init__(self, user=None, dbstate=None):
        ## Setup:
        from gramps.cli.clidbman import CLIDbManager
        self.dbstate = dbstate or DbState()
        #we need a manager for the CLI session
        self.user = user or User()
        self.climanager = CLIManager(self.dbstate, setloader=True, user=self.user)
        self.clidbmanager = CLIDbManager(self.dbstate)

    def run(self, *args, stdin=None, bytesio=False):
        with capture(stdin, bytesio=bytesio) as output:
            try:
                try:    # make sure we have user directories
                    for path in USER_DIRLIST:
                        if not os.path.isdir(path):
                            os.makedirs(path)
                except OSError as msg:
                    print("Error creating user directories: " + str(msg))
                except:
                    print("Error reading configuration.", exc_info=True)
                #load the plugins
                self.climanager.do_reg_plugins(self.dbstate, uistate=None)
                # handle the arguments
                args = [sys.executable] + list(args)
                argparser = ArgParser(args)
                argparser.need_gui()  # initializes some variables
                if argparser.errors:
                    print(argparser.errors, file=sys.stderr)
                argparser.print_help()
                argparser.print_usage()
                handler = ArgHandler(self.dbstate, argparser, self.climanager)
                # create a manager to manage the database
                handler.handle_args_cli()
                if handler.dbstate.is_open():
                    handler.dbstate.db.close()
            except:
                print("Exception in test:")
                print("-" * 60)
                traceback.print_exc(file=sys.stdout)
                print("-" * 60)

        return output
def build_report_set():

    reports = []

    ##################################################################
    # Load plugins
    ##################################################################

    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader = True, user = None)
    climanager.do_reg_plugins(dbstate, uistate = None)
    gpr = PluginRegister.get_instance()

    PLUGMAN = BasePluginManager.get_instance()
    CSS = PLUGMAN.process_plugin_data('WEBSTUFF')

    ##################################################################
    # GRAMPS native plugins
    ##################################################################

    # GRPH_FMT = ['odt', 'ps', 'pdf', 'svg']
    GRPH_FMT = ['pdf', 'svg']
    # GRPH_FMT = ['svg']
    GRPH_REP = [
        {
            'report': 'ancestor_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'descend_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0104',
            },
        },
        {
            'report': 'family_descend_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0104',
            },
        },
        {
            'report': 'fan_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'statistics_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
           },
        },
        {
            'report': 'timeline',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
            },
        },
        {
            'report': 'calendar',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
            },
        },
        {
            'report': 'familylines_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'gidlist': 'I0104 I0045',
                'limitchildren': True,
                'maxchildren': 20,
            },
        },
        {
            'report': 'hourglass_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0044',
                'maxascend': 2,
                'maxdescend': 2,
            },
        },
        {
            'report': 'rel_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0044',
                'filter': 3,
                'event_choice': 2,
            },
        },
    ]

    # TEXT_FMT = ['ps', 'pdf', 'html', 'odt', 'tex', 'rtf', 'txt']
    TEXT_FMT = ['html', 'pdf', 'txt']
    # TEXT_FMT = ['html', 'txt']
    TEXT_REP = [
        {
            'report': 'ancestor_report',
            'options': {
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'descend_report',
            'options': {
                'pid': 'I0104',
            },
        },
        {
            'report': 'det_ancestor_report',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'det_descendant_report',
            'options': {
                'pid': 'I0104',
            },
        },
        {
            'report': 'family_group',
            'options': {
                'family_id': 'F0017',
            },
        },
        {
            'report': 'birthday_report',
            'options': {},
        },
        {
            'report': 'endofline_report',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'indiv_complete',
            'options': {},
        },
        {
            'report': 'kinship_report',
            'options': {
                'pid': 'I0044',
            },
        },
        {
            'report': 'tag_report',
            'options': {
                'tag': 'ToDo',
            },
        },
        {
            'report': 'number_of_ancestors',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'place_report',
            'options': {
                'places': 'P1678 P1679 P1680',
            },
        },
        {
            'report': 'summary',
            'options': {},
        },
        {
            'report': 'records',
            'options': {},
        },
        {
            'report': 'notelinkreport',
            'options': {},
        },
    ]


    # Single run with all native reports (except web) in all formats
    for (rep_list, formats) in [
        (TEXT_REP, TEXT_FMT),
        (GRPH_REP, GRPH_FMT),
    ]:
        for rep_info in TEXT_REP:
            report = rep_info['report']
            options = rep_info['options']
            plugin = gpr.get_plugin(report)
            if not plugin:
                print('Unknown plugin: %s' % report)
                continue
            for fmt in TEXT_FMT:
                of = os.path.join(GRAMPS_REP_DIR, report + '.' + fmt)
                new_options = {
                    'name': report,
                    'off': fmt,
                    'of': of,
                    # 'show': 'all',
                }
                new_options.update(options)
                reports.append({
                    'title': '"%s" in format "%s"' % (plugin.name, fmt),
                    'name': plugin.name,
                    'result': of,
                    'type': 'Native',
                    'category': plugin.category,
                    'version': plugin.version,
                    'options': new_options,
                })

    ##################################################################
    # GRAMPS native web reports
    ##################################################################

    full_options = {
        'linkhome': True,
        'showdeath': True,
        'showpartner': True,
        'showparents': True,
        'showhalfsiblings': True,
        'inc_families': True,
        'inc_repository': True,
        'inc_gendex': True,
        'inc_addressbook': True,
        'placemappages': True,
        'familymappages': True,
    }

    for (i, (css, full)) in enumerate([
        ['default', False],
        ['Mainz', True],
    ]):
        report = 'navwebpage'
        plugin = gpr.get_plugin(report)
        opts = {
            'name': report,
            'target': os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i),
            'css':  CSS[css]['id'],
            'living': _INCLUDE_LIVING_VALUE,
        }
        if (full): opts.update(full_options)
        reports.append({
            'title': '"%s" report example %i' % (plugin.name, i),
            'name': report,
            'result': os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i, 'index.html'),
            'type': 'Native',
            'category': plugin.category,
            'version': VERSION,
            'options': opts,
        })


    full_options = {
        'alive': False,
        'fullyear': True,
        'makeoneday': True,
        'link_to_narweb': True,
    }

    for (i, (css, full)) in enumerate([
        ['default', False],
        ['Mainz', True],
    ]):
        report = 'WebCal'
        plugin = gpr.get_plugin(report)
        opts = {
            'name': report,
            'target': os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i),
            'css':  CSS[css]['id'],
            'home_link': '../../example_NAVWEB%i/index.html' % i,
            'prefix': '../../example_NAVWEB%i/' % i,
        }
        page = 'January.html'
        if (full):
            opts.update(full_options)
            page = 'fullyearlinked.html'
        reports.append({
            'title': '"%s" report example %i' % (plugin.name, i),
            'name': report,
            'result': os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i, str(Today().get_year()), page),
            'type': 'Native',
            'category': plugin.category,
            'version': VERSION,
            'options': opts,
        })


    ##################################################################
    # GRAMPS addons reports
    ##################################################################


    addons=[]


    ########## AncestorFill

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'AncestorFill.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'AncestorFill',
            'options': {
                'off': fmt,
                'of': of,
            },
        })


    ########## d3-ancestralcollapsibletree

    addons.append({
        'title': '"%s" report example',
        'result': os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree', 'index.html'),
        'i': 'd3-ancestralcollapsibletree',
        'options': {
            'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree'),
            'dest_file': 'index.html',
            'pid': 'I0006',
            'maxgen': 6,
        },
    })


    ########## d3-ancestralfanchart

    addons.append({
        'title': '"%s" report example',
        'result': os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart', 'index.html'),
        'i': 'd3-ancestralfanchart',
        'options': {
            'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart'),
            'dest_file': 'index.html',
            'pid': 'I0006',
            'maxgen': 6,
        },
    })


    ########## d3-descendantindentedtree

    addons.append({
        'title': '"%s" report example',
        'result': os.path.join(ADDONS_REP_DIR, 'd3-descendantindentedtree', 'index.html'),
        'i': 'd3-descendantindentedtree',
        'options': {
            'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-descendantindentedtree'),
            'dest_file': 'index.html',
            'pid': 'I0104',
            'max_gen': 6,
            'inc_private': True,
            'inc_living': _INCLUDE_LIVING_VALUE,
        },
    })


    ########## denominoviso

    for (i, (mode, type, dir, pid, full)) in enumerate([
        [0, 0, 0, 'I0001', True],
        [0, 3, 2, 'I0001', False],
        [0, 4, 2, 'I0001', False],
        [1, 0, 0, 'I0044', True],
        [1, 1, 0, 'I0044', False],
    ]):
        addons.append({
            'title': '"%%s" report example %i' % i,
            'result': os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i),
            'i': 'denominoviso',
            'options': {
                'DNMfilename': os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i),
                'DNMchart_mode': mode,
                'DNMpid': pid,
                'DNMchart_type': type,
                'DNMinc_attributes_m': '"True, "',
                'DNMinc_addresses': full,
                'DNMinc_notes': full,
                'DNMinc_url': full,
                'DNMinc_url_desc': full,
                'DNMinc_sources': full,
                'DNMinc_img': full,
                'DNMcopy_img_m': '"%s, %s%i"' % (str(full), os.path.join(ADDONS_REP_DIR, 'DenominoViso'), i),
            },
        })


    ########## DescendantBook

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DescendantBook.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'DescendantBook',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DetailedDescendantBook.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'DetailedDescendantBook',
            'options': {
                'off': fmt,
                'of': of,
            },
        })


    ########## Descendants Lines

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DescendantsLines.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Descendants Lines',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
            },
        })


    ########## database-differences-report

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'database-differences-report.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'database-differences-report',
            'options': {
                'off': fmt,
                'of': of,
                'filename': os.path.join(os.environ['GRAMPS_RESOURCES'], 'example', 'gramps', 'example.gramps'),
            },
        })


    ########## DynamicWeb

    addons.extend(report_set_DynamicWeb.addon_set())


    ########## FamilyTree

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'FamilyTree.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'FamilyTree',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
                'max_ancestor_generations': 3,
                'max_descendant_generations': 3,
                'papero': 1,
                'protect_private': False,
                'color': 1,
            },
        })


    ########## LastChangeReport

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'LastChangeReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'LastChangeReport',
            'options': {
                'off': fmt,
                'of': of,
                'what_types': '"True,True,True,True,True,True"'
            },
        })


    ########## LinesOfDescendency

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'LinesOfDescendency.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'LinesOfDescendency',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
                'ancestor': 'I0104',
            },
        })


    ########## ListeEclair

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'ListeEclair.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'ListeEclair',
            'options': {
                'off': fmt,
                'of': of,
            },
        })


    ########## PedigreeChart

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'PedigreeChart.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'PedigreeChart',
            'options': {
                'off': fmt,
                'of': of,
                'maxgen': 6,
                'pid': 'I0006',
            },
        })


    ########## PersonEverythingReport

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'PersonEverythingReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'PersonEverythingReport',
            'options': {
                'off': fmt,
                'of': of,
            },
        })


    ########## Repositories Report

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReportOptions.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Repositories Report Options',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Repositories Report',
            'options': {
                'off': fmt,
                'of': of,
            },
        })


    ########## TodoReport

    reports=[]
    addons=[]
    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'TodoReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'TodoReport',
            'options': {
                'off': fmt,
                'of': of,
                'tag': 'ToDo',
            },
        })


    ########## Check if addon exists in the addons listings

    for addon in addons:
        plugin = gpr.get_plugin(addon['i'])
        if not plugin:
            print('Unknown plugin: %s' % addon['i'])
            continue
        addon['options'].update({
            'name': addon['i'],
        })
        addon.update({
            'title': addon['title'] % plugin.name,
            'name': plugin.name,
            'type': 'Addon',
            'category': plugin.category,
            'version': plugin.version,
        })
        del addon['i']
        reports.append(addon)

    return reports
def build_report_set():

    reports = []

    ##################################################################
    # Load plugins
    ##################################################################

    dbstate = DbState()
    climanager = CLIManager(dbstate, setloader=True, user=None)
    climanager.do_reg_plugins(dbstate, uistate=None)
    gpr = PluginRegister.get_instance()

    PLUGMAN = BasePluginManager.get_instance()
    CSS = PLUGMAN.process_plugin_data('WEBSTUFF')

    ##################################################################
    # GRAMPS native plugins
    ##################################################################

    # GRPH_FMT = ['odt', 'ps', 'pdf', 'svg']
    GRPH_FMT = ['pdf', 'svg']
    # GRPH_FMT = ['svg']
    GRPH_REP = [
        {
            'report': 'ancestor_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'descend_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0104',
            },
        },
        {
            'report': 'family_descend_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0104',
            },
        },
        {
            'report': 'fan_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'statistics_chart',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
            },
        },
        {
            'report': 'timeline',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
            },
        },
        {
            'report': 'calendar',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
            },
        },
        {
            'report': 'familylines_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'gidlist': 'I0104 I0045',
                'limitchildren': True,
                'maxchildren': 20,
            },
        },
        {
            'report': 'hourglass_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0044',
                'maxascend': 2,
                'maxdescend': 2,
            },
        },
        {
            'report': 'rel_graph',
            'options': {
                'scale_tree': 2,
                'maxgen': 6,
                'pid': 'I0044',
                'filter': 3,
                'event_choice': 2,
            },
        },
    ]

    # TEXT_FMT = ['ps', 'pdf', 'html', 'odt', 'tex', 'rtf', 'txt']
    TEXT_FMT = ['html', 'pdf', 'txt']
    # TEXT_FMT = ['html', 'txt']
    TEXT_REP = [
        {
            'report': 'ancestor_report',
            'options': {
                'maxgen': 6,
                'pid': 'I0006',
            },
        },
        {
            'report': 'descend_report',
            'options': {
                'pid': 'I0104',
            },
        },
        {
            'report': 'det_ancestor_report',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'det_descendant_report',
            'options': {
                'pid': 'I0104',
            },
        },
        {
            'report': 'family_group',
            'options': {
                'family_id': 'F0017',
            },
        },
        {
            'report': 'birthday_report',
            'options': {},
        },
        {
            'report': 'endofline_report',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'indiv_complete',
            'options': {},
        },
        {
            'report': 'kinship_report',
            'options': {
                'pid': 'I0044',
            },
        },
        {
            'report': 'tag_report',
            'options': {
                'tag': 'ToDo',
            },
        },
        {
            'report': 'number_of_ancestors',
            'options': {
                'pid': 'I0006',
            },
        },
        {
            'report': 'place_report',
            'options': {
                'places': 'P1678 P1679 P1680',
            },
        },
        {
            'report': 'summary',
            'options': {},
        },
        {
            'report': 'records',
            'options': {},
        },
        {
            'report': 'notelinkreport',
            'options': {},
        },
    ]

    # Single run with all native reports (except web) in all formats
    for (rep_list, formats) in [
        (TEXT_REP, TEXT_FMT),
        (GRPH_REP, GRPH_FMT),
    ]:
        for rep_info in TEXT_REP:
            report = rep_info['report']
            options = rep_info['options']
            plugin = gpr.get_plugin(report)
            if not plugin:
                print('Unknown plugin: %s' % report)
                continue
            for fmt in TEXT_FMT:
                of = os.path.join(GRAMPS_REP_DIR, report + '.' + fmt)
                new_options = {
                    'name': report,
                    'off': fmt,
                    'of': of,
                    # 'show': 'all',
                }
                new_options.update(options)
                reports.append({
                    'title':
                    '"%s" in format "%s"' % (plugin.name, fmt),
                    'name':
                    plugin.name,
                    'result':
                    of,
                    'type':
                    'Native',
                    'category':
                    plugin.category,
                    'version':
                    plugin.version,
                    'options':
                    new_options,
                })

    ##################################################################
    # GRAMPS native web reports
    ##################################################################

    full_options = {
        'linkhome': True,
        'showdeath': True,
        'showpartner': True,
        'showparents': True,
        'showhalfsiblings': True,
        'inc_families': True,
        'inc_repository': True,
        'inc_gendex': True,
        'inc_addressbook': True,
        'placemappages': True,
        'familymappages': True,
    }

    for (i, (css, full)) in enumerate([
        ['default', False],
        ['Mainz', True],
    ]):
        report = 'navwebpage'
        plugin = gpr.get_plugin(report)
        opts = {
            'name': report,
            'target': os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i),
            'css': CSS[css]['id'],
            'living': _INCLUDE_LIVING_VALUE,
        }
        if (full): opts.update(full_options)
        reports.append({
            'title':
            '"%s" report example %i' % (plugin.name, i),
            'name':
            report,
            'result':
            os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i, 'index.html'),
            'type':
            'Native',
            'category':
            plugin.category,
            'version':
            VERSION,
            'options':
            opts,
        })

    full_options = {
        'alive': False,
        'fullyear': True,
        'makeoneday': True,
        'link_to_narweb': True,
    }

    for (i, (css, full)) in enumerate([
        ['default', False],
        ['Mainz', True],
    ]):
        report = 'WebCal'
        plugin = gpr.get_plugin(report)
        opts = {
            'name': report,
            'target': os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i),
            'css': CSS[css]['id'],
            'home_link': '../../example_NAVWEB%i/index.html' % i,
            'prefix': '../../example_NAVWEB%i/' % i,
        }
        page = 'January.html'
        if (full):
            opts.update(full_options)
            page = 'fullyearlinked.html'
        reports.append({
            'title':
            '"%s" report example %i' % (plugin.name, i),
            'name':
            report,
            'result':
            os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i,
                         str(Today().get_year()), page),
            'type':
            'Native',
            'category':
            plugin.category,
            'version':
            VERSION,
            'options':
            opts,
        })

    ##################################################################
    # GRAMPS addons reports
    ##################################################################

    addons = []

    ########## AncestorFill

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'AncestorFill.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'AncestorFill',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    ########## d3-ancestralcollapsibletree

    addons.append({
        'title':
        '"%s" report example',
        'result':
        os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree',
                     'index.html'),
        'i':
        'd3-ancestralcollapsibletree',
        'options': {
            'dest_path':
            os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree'),
            'dest_file':
            'index.html',
            'pid':
            'I0006',
            'maxgen':
            6,
        },
    })

    ########## d3-ancestralfanchart

    addons.append({
        'title':
        '"%s" report example',
        'result':
        os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart', 'index.html'),
        'i':
        'd3-ancestralfanchart',
        'options': {
            'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart'),
            'dest_file': 'index.html',
            'pid': 'I0006',
            'maxgen': 6,
        },
    })

    ########## d3-descendantindentedtree

    addons.append({
        'title':
        '"%s" report example',
        'result':
        os.path.join(ADDONS_REP_DIR, 'd3-descendantindentedtree',
                     'index.html'),
        'i':
        'd3-descendantindentedtree',
        'options': {
            'dest_path': os.path.join(ADDONS_REP_DIR,
                                      'd3-descendantindentedtree'),
            'dest_file': 'index.html',
            'pid': 'I0104',
            'max_gen': 6,
            'inc_private': True,
            'inc_living': _INCLUDE_LIVING_VALUE,
        },
    })

    ########## denominoviso

    for (i, (mode, type, dir, pid, full)) in enumerate([
        [0, 0, 0, 'I0001', True],
        [0, 3, 2, 'I0001', False],
        [0, 4, 2, 'I0001', False],
        [1, 0, 0, 'I0044', True],
        [1, 1, 0, 'I0044', False],
    ]):
        addons.append({
            'title':
            '"%%s" report example %i' % i,
            'result':
            os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i),
            'i':
            'denominoviso',
            'options': {
                'DNMfilename':
                os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i),
                'DNMchart_mode':
                mode,
                'DNMpid':
                pid,
                'DNMchart_type':
                type,
                'DNMinc_attributes_m':
                '"True, "',
                'DNMinc_addresses':
                full,
                'DNMinc_notes':
                full,
                'DNMinc_url':
                full,
                'DNMinc_url_desc':
                full,
                'DNMinc_sources':
                full,
                'DNMinc_img':
                full,
                'DNMcopy_img_m':
                '"%s, %s%i"' %
                (str(full), os.path.join(ADDONS_REP_DIR, 'DenominoViso'), i),
            },
        })

    ########## DescendantBook

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DescendantBook.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'DescendantBook',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DetailedDescendantBook.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'DetailedDescendantBook',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    ########## Descendants Lines

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'DescendantsLines.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Descendants Lines',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
            },
        })

    ########## database-differences-report

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'database-differences-report.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'database-differences-report',
            'options': {
                'off':
                fmt,
                'of':
                of,
                'filename':
                os.path.join(os.environ['GRAMPS_RESOURCES'], 'example',
                             'gramps', 'example.gramps'),
            },
        })

    ########## DynamicWeb

    addons.extend(report_set_DynamicWeb.addon_set())

    ########## FamilyTree

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'FamilyTree.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'FamilyTree',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
                'max_ancestor_generations': 3,
                'max_descendant_generations': 3,
                'papero': 1,
                'protect_private': False,
                'color': 1,
            },
        })

    ########## LastChangeReport

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'LastChangeReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'LastChangeReport',
            'options': {
                'off': fmt,
                'of': of,
                'what_types': '"True,True,True,True,True,True"'
            },
        })

    ########## LinesOfDescendency

    for fmt in ['html']:
        of = os.path.join(ADDONS_REP_DIR, 'LinesOfDescendency.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'LinesOfDescendency',
            'options': {
                'off': fmt,
                'of': of,
                'pid': 'I0006',
                'ancestor': 'I0104',
            },
        })

    ########## ListeEclair

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'ListeEclair.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'ListeEclair',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    ########## PedigreeChart

    for fmt in GRPH_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'PedigreeChart.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'PedigreeChart',
            'options': {
                'off': fmt,
                'of': of,
                'maxgen': 6,
                'pid': 'I0006',
            },
        })

    ########## PersonEverythingReport

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'PersonEverythingReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'PersonEverythingReport',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    ########## Repositories Report

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReportOptions.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Repositories Report Options',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'Repositories Report',
            'options': {
                'off': fmt,
                'of': of,
            },
        })

    ########## TodoReport

    reports = []
    addons = []
    for fmt in TEXT_FMT:
        of = os.path.join(ADDONS_REP_DIR, 'TodoReport.' + fmt)
        addons.append({
            'title': '"%%s" in format "%s"' % fmt,
            'result': of,
            'i': 'TodoReport',
            'options': {
                'off': fmt,
                'of': of,
                'tag': 'ToDo',
            },
        })

    ########## Check if addon exists in the addons listings

    for addon in addons:
        plugin = gpr.get_plugin(addon['i'])
        if not plugin:
            print('Unknown plugin: %s' % addon['i'])
            continue
        addon['options'].update({
            'name': addon['i'],
        })
        addon.update({
            'title': addon['title'] % plugin.name,
            'name': plugin.name,
            'type': 'Addon',
            'category': plugin.category,
            'version': plugin.version,
        })
        del addon['i']
        reports.append(addon)

    return reports