From 4a27544538c8bf341f7f8e2325efde59eb365c5b Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sat, 2 Mar 2024 10:04:49 +0100 Subject: Populate release fields when renaming with the common part of the directories names in destination directory --- mageiaSync/mageiasync.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mageiaSync/mageiasync.py b/mageiaSync/mageiasync.py index c5dbb57..e634e4c 100644 --- a/mageiaSync/mageiasync.py +++ b/mageiaSync/mageiasync.py @@ -17,6 +17,8 @@ from PyQt6.QtGui import ( from PyQt6.QtCore import QLibraryInfo, QUrl, QItemSelectionModel, QFileInfo from PyQt6 import QtCore, uic # , Qt, QThread, QObject, pyqtSignal) import sys +import glob +import os try: from . import mageiaSyncExt @@ -470,9 +472,9 @@ class IsosViewer(QMainWindow): def rename(self): # rename old isos and directories to a new release self.rd = renameDialog() - loc = [] - loc = self.location.split("/") - self.rd.oldRelease.setText(loc[-1]) + prefix = os.path.commonprefix([x for x in glob.glob("*", root_dir=self.destination) if os.path.isdir(os.path.join(self.destination,x))]) + self.rd.oldRelease.setText(prefix) + self.rd.newRelease.setText(prefix) self.rd.chooseDir.setText(self.destination) answer = self.rd.exec() if answer: @@ -487,7 +489,7 @@ class IsosViewer(QMainWindow): nbf, nbr ) self.lvMessage(returnMsg) - self.updateList() + self.updateList() self.rd.close() def prefs(self): -- cgit v1.2.1