def get_stdio_name(self, location: Location) -> str: if not location.has_payload(): return location.get_path() else: if location._payloads[-1].path: parent = location.parent() outdir = self._archive_manager.get_extractor_content_dir(parent) return os.path.join(outdir, location._payloads[-1].path) else: outdir = self._archive_manager.get_extractor_content_dir(location) return outdir
def get_fileinfo(self, location: Location) -> FileInfo: if not location.has_payload(): fi = FileInfo.from_path(location.get_path()) fi._location = location return fi else: parent = location.parent() assert parent.has_payload() outdir = self._archive_manager.get_extractor_content_dir(parent) path = os.path.join(outdir, location._payloads[-1].path) fi = FileInfo.from_path(path) fi._location = location return fi
def on_edit_paste_into(self, location: Location): logger.debug("pasting data into folder from clipboard") if location is None: logger.error("trying to paste into None") return clipboard = self.app.qapp.clipboard() mime_data = clipboard.mimeData(QClipboard.Clipboard) if False: for fmt in mime_data.formats(): print("Format:", fmt) print(mime_data.data(fmt)) print() print() destination_path = location.get_path() if mime_data.hasFormat("x-special/gnome-copied-files"): try: action, urls = parse_gnome_copied_files( mime_data.data("x-special/gnome-copied-files")) except Exception as err: logger.error("failed to parse clipboard data: %s", err) else: sources = [url.toLocalFile() for url in urls] if action == Qt.MoveAction: self.app.fs_operations.move_files(sources, destination_path) elif action == Qt.CopyAction: self.app.fs_operations.copy_files(sources, destination_path) elif action == Qt.LinkAction: self.app.fs_operations.link_files(sources, destination_path) elif mime_data.hasUrls(): urls = mime_data.urls() sources = [url.toLocalFile() for url in urls] self.app.fs_operations.copy_files(sources, destination_path) else: logger.debug("unhandled format on paste")