From 22c3e0e9e0efb4445720b951c8f22ae1324c5dbd Mon Sep 17 00:00:00 2001 From: Jeix Date: Fri, 1 Oct 2010 17:28:48 +0200 Subject: issue #139 fixed, thanks for the diff! --- pyLoadGui.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'pyLoadGui.py') diff --git a/pyLoadGui.py b/pyLoadGui.py index e03843054..85acc0682 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -33,6 +33,7 @@ from xmlrpclib import Binary from os.path import abspath from os.path import join from os.path import basename +from os.path import commonprefix from module import InitHomeDir from module.gui.ConnectionManager import * @@ -580,8 +581,19 @@ class main(QObject): text = self.clipboard.text() pattern = re.compile(r"(http|https|ftp)://[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?/.*)?") matches = pattern.finditer(text) - for match in matches: - self.slotAddLinks([str(match.group(0))]) + + # thanks to: jmansour //#139 + links = [str(match.group(0)) for match in matches] + if len(links) == 0: + return + + filenames = [link.rpartition("/")[2] for link in links] + + packagename = commonprefix(filenames) + if len(packagename) == 0: + packagename = filenames[0] + + self.slotAddPackage(packagename, links) def slotSetClipboardStatus(self, status): """ -- cgit v1.2.3