From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hoster/Ftp.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index af9191a4d..c6ae75530 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -13,9 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: jeix - @author: mkaay """ from urlparse import urlparse from urllib import quote, unquote -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hoster/Ftp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index c6ae75530..725126d17 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -50,7 +50,7 @@ class Ftp(Hoster): if netloc in servers: self.logDebug("Logging on to %s" % netloc) - self.req.addAuth(self.account.accounts[netloc]["password"]) + self.req.addAuth(self.account.accounts[netloc]['password']) else: for pwd in pyfile.package().password.splitlines(): if ":" in pwd: -- cgit v1.2.3 From a1e78f33dc2b0b6777fdcbc415673f3965b25542 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 16 Jul 2014 00:46:26 +0200 Subject: Prefer self.urls and self.packages for adding links --- module/plugins/hoster/Ftp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 725126d17..f448b99d1 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -75,13 +75,12 @@ class Ftp(Hoster): #Naive ftp directory listing if re.search(r'^25\d.*?"', self.req.http.header, re.M): pyfile.url = pyfile.url.rstrip('/') - pkgname = "/".join((pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2])) + pkgname = "/".join(pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2]) pyfile.url += '/' self.req.http.c.setopt(48, 1) # CURLOPT_DIRLISTONLY response = self.load(pyfile.url, decode=False) links = [pyfile.url + quote(x) for x in response.splitlines()] self.logDebug("LINKS", links) - self.core.api.addPackage(pkgname, links, 1) - #self.core.files.addLinks(links, pyfile.package().id) + self.core.api.addPackage(pkgname, links) else: self.fail("Unexpected server response") -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/hoster/Ftp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index f448b99d1..07169ff2e 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -67,9 +67,9 @@ class Ftp(Hoster): self.req.http.c.setopt(pycurl.NOBODY, 0) self.logDebug(self.req.http.header) - found = re.search(r"Content-Length:\s*(\d+)", response) - if found: - pyfile.size = int(found.group(1)) + m = re.search(r"Content-Length:\s*(\d+)", response) + if m: + pyfile.size = int(m.group(1)) self.download(pyfile.url) else: #Naive ftp directory listing -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/Ftp.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 07169ff2e..8de3f4f47 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -1,36 +1,24 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" -from urlparse import urlparse -from urllib import quote, unquote import pycurl import re +from urllib import quote, unquote +from urlparse import urlparse + from module.plugins.Hoster import Hoster class Ftp(Hoster): __name__ = "Ftp" - __version__ = "0.41" - __pattern__ = r'(ftps?|sftp)://(.*?:.*?@)?.*?/.*' # ftp://user:password@ftp.server.org/path/to/file __type__ = "hoster" + __version__ = "0.41" + __description__ = """Download from ftp directory""" __author_name__ = ("jeix", "mkaay", "zoidberg") __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de", "zoidberg@mujmail.cz") + def setup(self): self.chunkLimit = -1 self.resumeDownload = True @@ -72,7 +60,7 @@ class Ftp(Hoster): pyfile.size = int(m.group(1)) self.download(pyfile.url) else: - #Naive ftp directory listing + #Naive ftp directory listing if re.search(r'^25\d.*?"', self.req.http.header, re.M): pyfile.url = pyfile.url.rstrip('/') pkgname = "/".join(pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2]) -- cgit v1.2.3