def _write_config_to_file(self, configparser_instance):
        """
        Write a configparser instance to a config file.

        Args:
            cp_instance (SafeConfigParser): Instance to be written to file.
        """
        config_helpers.write_config_file(configparser_instance, 'hamster-gtk', 'hamster-gtk.conf')
Example #2
0
    def _write_config_to_file(self, configparser_instance):
        """
        Write a configparser instance to a config file.

        Args:
            cp_instance (SafeConfigParser): Instance to be written to file.
        """
        config_helpers.write_config_file(configparser_instance, 'hamster-gtk',
                                         'hamster-gtk.conf')
    def test_file_is_written(self, config_instance, appdirs):
        """
        Make sure the file is written.

        Note: Content is not checked, this is ConfigParsers job.
        """
        config_helpers.write_config_file(config_instance)
        expected_location = config_helpers.get_config_path()
        assert os.path.lexists(expected_location)
    def test_file_is_written(self, config_instance, appdirs):
        """
        Make sure the file is written.

        Note: Content is not checked, this is ConfigParsers job.
        """
        config_helpers.write_config_file(config_instance)
        expected_location = config_helpers.get_config_path()
        assert os.path.lexists(expected_location)
    def save_config(self, config):
        """
        Save a potentially new/modified config instance to config backend.

        Args:
            config (dict): Dictionary of config keys and values.

        Returns:
            dict: Dictionary of config keys and values.
        """
        cp_instance = self._config_to_configparser(config)
        config_helpers.write_config_file(cp_instance, 'hamster-gtk', 'hamster-gtk.conf')
        self.controler.signal_handler.emit('config-changed')
Example #6
0
    def save_config(self, config):
        """
        Save a potentially new/modified config instance to config backend.

        Args:
            config (dict): Dictionary of config keys and values.

        Returns:
            dict: Dictionary of config keys and values.
        """
        cp_instance = self._config_to_configparser(config)
        config_helpers.write_config_file(cp_instance, 'hamster-gtk',
                                         'hamster-gtk.conf')
        self.controler.signal_handler.emit('config-changed')
Example #7
0
def get_config_instance(fallback_config_instance, app_name, file_name):
    """Patched version of ``hamster-lib`` helper function until it get fixed upstream."""
    from hamster_lib.helpers import config_helpers
    from backports.configparser import SafeConfigParser
    config = SafeConfigParser()
    path = config_helpers.get_config_path(app_name, file_name)
    existing_config = config.read(path)
    if not existing_config:
        config = config_helpers.write_config_file(fallback_config_instance, app_name,
                                                  file_name=file_name)
    return config
 def test_return_config_instance(self, config_instance, appdirs):
     """Make sure we return a ``SafeConfigParser`` instance."""
     result = config_helpers.write_config_file(config_instance)
     assert isinstance(result, SafeConfigParser)
 def test_return_config_instance(self, config_instance, appdirs):
     """Make sure we return a ``SafeConfigParser`` instance."""
     result = config_helpers.write_config_file(config_instance)
     assert isinstance(result, SafeConfigParser)