How to use the pympress.util.get_portable_config function in pympress

To help you get started, we’ve selected a few pympress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cimbali / pympress / pympress / config.py View on Github external
def toggle_portable_config(*args):
        """ Create or remove a configuration file for portable installs.

        The portable install file will be used by default, and deleting it causes the config
        to fall back to the user profile location.

        No need to populate the new config file, this will be done on pympress exit.
        """
        if Config.using_portable_config():
            os.remove(util.get_portable_config())
        else:
            with open(util.get_portable_config(), 'w'):
                pass
github Cimbali / pympress / pympress / config.py View on Github external
def path_to_config(search_legacy_locations = False):
        """ Return the path to the currently used configuration file.

        Args:
            search_legacy_locations (`bool`): whether to look in previously used locations
        """
        portable_config = util.get_portable_config()
        if os.path.exists(portable_config):
            return portable_config

        user_config = util.get_user_config()

        # migrate old configuration files from previously-used erroneous locations
        if search_legacy_locations and (util.IS_POSIX or util.IS_MAC_OS) and not os.path.exists(user_config):
            for legacy_location in [os.path.expanduser('~/.pympress'), os.path.expanduser('~/.config/pympress')]:
                if os.path.exists(legacy_location):
                    shutil.move(legacy_location, user_config)

        return user_config
github Cimbali / pympress / pympress / config.py View on Github external
def toggle_portable_config(*args):
        """ Create or remove a configuration file for portable installs.

        The portable install file will be used by default, and deleting it causes the config
        to fall back to the user profile location.

        No need to populate the new config file, this will be done on pympress exit.
        """
        if Config.using_portable_config():
            os.remove(util.get_portable_config())
        else:
            with open(util.get_portable_config(), 'w'):
                pass