Exemplo n.º 1
0
def _process_directory(directory):
    """Assign directory if none was given, and create directory if necessary."""
    directory = Util.expand(directory)
    if directory is None:
        LOG.debug("No directory provided, defaulting to %s.", directory)
        return Util.expand(CONSTANTS.APPDIRS.user_data_dir)

    LOG.debug("Provided directory %s.", directory)

    Util.ensure_dir(directory)

    return directory
Exemplo n.º 2
0
def _process_directory(directory):
    """Assign directory if none was given, and create directory if necessary."""
    directory = Util.expand(directory)
    if directory is None:
        LOG.debug("No directory provided, defaulting to %s.", directory)
        return Util.expand(CONSTANTS.APPDIRS.user_data_dir)

    LOG.debug("Provided directory %s.", directory)

    if not os.path.isdir(directory):
        LOG.debug("Directory %s does not exist, creating it.", directory)
        os.makedirs(directory)

    return directory
Exemplo n.º 3
0
    def update(self, directory=None, config_dir=None, url=None, set_original=False, name=None):
        """Update values for this subscription."""
        if directory == "":
            raise ERROR.InvalidConfigError(desc=textwrap.dedent(
                """\
                Provided invalid sub directory '{}' for '{}'.\
                """.format(directory, self.name)))

        if directory is not None:
            directory = Util.expand(directory)

            if self.directory != directory:
                if os.path.isabs(directory):
                    self.directory = directory

                else:
                    self.directory = os.path.join(config_dir, directory)

                if not os.path.isdir(self.directory):
                    LOG.debug("Directory %s does not exist, creating it.", directory)
                    os.makedirs(self.directory)

        if url is not None:
            self.url = url

            if set_original:
                self.original_url = url

        if name is not None:
            self.name = name
Exemplo n.º 4
0
    def update(self, directory=None, config_dir=None, url=None, set_original=False, name=None):
        """Update values for this subscription."""
        if directory == "":
            LOG.debug("Provided invalid sub directory '%s' for '%s'- ignoring update.",
                      directory, self.name)
            return

        if directory is not None:
            directory = Util.expand(directory)

            if self.directory != directory:
                if os.path.isabs(directory):
                    self.directory = directory

                else:
                    self.directory = os.path.join(config_dir, directory)

                Util.ensure_dir(self.directory)

        if url is not None:
            self.url = url

            if set_original:
                self.original_url = url

        if name is not None:
            self.name = name