def post_process(self, paths, *args, **kwargs): """ Delete files in ``LOR_FILES_URLS`` and launch meth:`DefaultStorage.post_process`. :param paths: List of tuple with Storage class and file path :type paths: ``list`` of ``(:class:`Storage`, str) :returns: List of files to post process :rtype: ``list`` """ lor_files_paths = [v[0] for v in FILES_URLS.values()] for file_path, value in paths.copy().items(): if file_path in lor_files_paths: paths.pop(file_path) full_path = os.path.join(self.location, file_path) if not kwargs.get("dry_run"): os.remove(full_path) print("Deleting '%s'" % full_path) print("Copied and deleted %s files" % len(lor_files_paths)) files = ( [] if not hasattr(DefaultStorage, "post_process") else super(LorStorage, self).post_process(paths, *args, **kwargs) ) return files
def handle(self, *args, **opts): noinput = opts.get('noinput', False) self._create_static_directory(noinput) if not FILES_URLS: self.stdout.write("No file defined.") for static in FILES_URLS.keys(): url = FILES_URLS[static][1] file_path = os.path.join(STATIC_DIR + FILES_URLS[static][0]) if not self._check_destination(noinput, file_path): continue response = self._get_remote_file(url) if response is None: continue self._create_local_file(response, file_path)