Beispiel #1
0
    def init_config(self):
        """
        If you need a view with a config, then call this method in the
        build_widget or __init__ method. It will set up a config file for the
        view, and use CONFIGSETTINGS to set the config defaults.
        The config is later accessbile via self._config
        So you can do
        self._config.get("section.variable1")
        self._config.set("section.variable1", value)
        self._config.save()

        CONFIGSETTINGS should be a list with tuples like
        ("section.variable1", value)
        """
        if self._config:
            return
        self._config = config.register_manager(self.ident,
                                               use_config_path=True)
        for section, value in self.CONFIGSETTINGS:
            self._config.register(section, value)
        self._config.init()
        self.config_connect()
#-------------------------------------------------------------------------
#
# face detection module
#
#-------------------------------------------------------------------------
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
import facedetection

#-------------------------------------------------------------------------
#
# configuration
#
#-------------------------------------------------------------------------

GRAMPLET_CONFIG_NAME = "phototagginggramplet"
CONFIG = config.register_manager(GRAMPLET_CONFIG_NAME)
CONFIG.register("detection.box_size", (50,50))
CONFIG.register("detection.inside_existing_boxes", False)
CONFIG.register("selection.replace_without_asking", False)
CONFIG.load()
CONFIG.save()

MIN_FACE_SIZE = CONFIG.get("detection.box_size")
REPLACE_WITHOUT_ASKING = CONFIG.get("selection.replace_without_asking")
DETECT_INSIDE_EXISTING_BOXES = CONFIG.get("detection.inside_existing_boxes")

def save_config():
    CONFIG.set("detection.box_size", MIN_FACE_SIZE)
    CONFIG.set("detection.inside_existing_boxes", DETECT_INSIDE_EXISTING_BOXES)
    CONFIG.set("selection.replace_without_asking", REPLACE_WITHOUT_ASKING)
    CONFIG.save()
             version = '1.0.5',
             gramps_target_version='5.0',
             status=STABLE,
             fname='postgresql.py',
             databaseclass='PostgreSQL',
             authors=['Doug Blank'],
             authors_email=['[email protected]']
    )
elif locals().get('uistate'):  # don't start GUI if in CLI mode, just ignore
    from gramps.gen.config import config
    from gramps.gui.dialog import QuestionDialog2
    from gramps.gen.config import logging
    if not module1:
        warn_msg = _("PostgreSQL Warning:  Python psycopg2 module not found.")
        logging.log(logging.WARNING, warn_msg)
    inifile = config.register_manager("postgresqlwarn")
    inifile.load()
    sects = inifile.get_sections()
    if 'postgresqlwarn' not in sects:
        yes_no = QuestionDialog2(_("PostgreSQL Failed to Load"),
            _("\n\nPostgreSQL is missing the psycopg2 python module.\n"
              "For now, it may be possible to install the files manually. See\n\n"
              "https://gramps-project.org/wiki/index.php?title=PostgreSQL \n\n"
              "To dismiss all future PostgreSQL warnings click Dismiss."),
            _(" Dismiss "),
            _("Continue"), parent=uistate.window)
        prompt = yes_no.run()
        if prompt is True:
            inifile.register('postgresqlwarn.MissingModules', "")
            inifile.set('postgresqlwarn.MissingModules', "True")
            inifile.save()
#---------------------------------------------------------------
from gramps.gui.display import display_url
from gramps.gen.const import GRAMPS_LOCALE as glocale
try:
    _trans = glocale.get_addon_translator(__file__)
except ValueError:
    _trans = glocale.translation
_ = _trans.gettext
from gramps.gen.config import config as configman

#---------------------------------------------------------------
#
# Local config and functions
#
#---------------------------------------------------------------
config = configman.register_manager("libwebconnect")
# "leave alone", "separate", or "remove":
config.register("behavior.middle-name", "remove") 
config.load()
config.save()

def escape(text):
    """
    Turn spaces into + symbols.
    """
    text = str(text).replace(" ", "+")
    return text

def make_callback(key, name):
    """
    Decorator for web connect callbacks. Adds the key and name for the
        gramps_target_version = '5.1',
        include_in_listing = True,
    )
elif locals().get('uistate'):  # don't start GUI if in CLI mode, just ignore
    from gramps.gen.config import config
    from gramps.gui.dialog import QuestionDialog2
    from gramps.gen.config import logging
    if not module1:
        warn_msg = _("NetworkChart Warning:  Python networkx module not found.")
        logging.log(logging.WARNING, warn_msg)
    if not (module2 or module3):
        warn_msg = _("NetworkChart Warning:  NetworkChart needs one of the following to work: \n"
                     "     Python module  pydotplus            OR\n"
                     "     Python module  pygraphviz           OR\n")
        logging.log(logging.WARNING, warn_msg)
    inifile = config.register_manager("networkchartwarn")
    inifile.load()
    sects = inifile.get_sections()
    if 'networkchartwarn' not in sects:
        yes_no = QuestionDialog2(_("NetworkChart Failed to Load"),
            _("\n\nNetworkChart is missing python modules or programs.  Networkx AND at\n"
              "least one of (pydotplus OR pygraphviz) must be\n"
              "installed.  For now, it may be possible to install the files manually. See\n\n"
              "https://gramps-project.org/wiki/index.php?title=NetworkChart \n\n"
              "To dismiss all future NetworkChart warnings click Dismiss."),
            _(" Dismiss "),
            _("Continue"), parent=uistate.window)
        prompt = yes_no.run()
        if prompt is True:
            inifile.register('networkchartwarn.MissingModules', "")
            inifile.set('networkchartwarn.MissingModules', "True")
Beispiel #6
0
# The attribute used to store the order of people on the census.
ORDER_ATTR = _("Order")

# The key of the data item in a source to define it as a census source.
CENSUS_TAG = _("Census")

# Files which may contain census definitions
definition_files = ["census.xml", "test.xml", "custom.xml"]

# ------------------------------------------------------------------------
#
# Configuration file
#
# ------------------------------------------------------------------------
CONFIG = config.register_manager("census")
CONFIG.register("interface.census-width", 600)
CONFIG.register("interface.census-height", 400)
CONFIG.init()

# ------------------------------------------------------------------------
#
# Census class
#
# ------------------------------------------------------------------------
class Census:
    """
    A class to read census definitions from an XML file.
    """

    def __init__(self):