def clean_cache_dir():
    if os.path.isdir(self.options.cachedir):
        if cachedir_valid(self.options.cachedir):
            powcachedir = os.path.join(self.options.cachedir, 'pow')
            self.log.info(('Found old cachedir. Migrating to %s' % str(powcachedir)))
            copy_cachedir(self.options.cachedir, powcachedir)
        for entry in os.listdir(self.options.cachedir):
            if (entry != 'pow'):
                entry_path = os.path.join(self.options.cachedir, entry)
                if os.path.isfile(entry_path):
                    os.remove(entry_path)
                elif os.path.isdir(entry_path):
                    shutil.rmtree(entry_path)
    else:
        os.makedirs(self.options.cachedir)
def clean_cache_dir():
    if os.path.isdir(self.options.cachedir):
        if cachedir_valid(self.options.cachedir):
            powcachedir = os.path.join(self.options.cachedir, 'pow')
            self.log.info(('Found old cachedir. Migrating to %s' % str(powcachedir)))
            copy_cachedir(self.options.cachedir, powcachedir)
        for entry in os.listdir(self.options.cachedir):
            if (entry != 'pow'):
                entry_path = os.path.join(self.options.cachedir, entry)
                if os.path.isfile(entry_path):
                    os.remove(entry_path)
                elif os.path.isdir(entry_path):
                    shutil.rmtree(entry_path)
    else:
        os.makedirs(self.options.cachedir)