示例#1
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
示例#2
0
def _validate_dirs(config_dir, cache_dir, data_dir):
    for directory in [config_dir, cache_dir, data_dir]:
        if os.path.isfile(directory):
            msg = "Provided directory '{}' is actually a file!".format(directory)
            raise Error.MalformedConfigError(msg)

        Util.ensure_dir(directory)
示例#3
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