From 339c5f5ba8e42b3514f6e3de7a757b5c6d2adace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Fri, 1 Jul 2005 13:50:22 +0000 Subject: [PATCH] Removed unused imports, file -> fileURI [ keyword ] --- cat-db.py | 4 +--- pisi/fetcher.py | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/cat-db.py b/cat-db.py index ad4a08a5..e6941dd8 100755 --- a/cat-db.py +++ b/cat-db.py @@ -3,14 +3,12 @@ # avoiding multiple invocations of the same instance import sys -import string import bsddb.dbshelve as shelve -import os d = shelve.open( sys.argv[1] ) #print 'list serial time, db size ', len(d) -for (k,data) in d.iteritems(): +for (k, data) in d.iteritems(): print k, data d.close() diff --git a/pisi/fetcher.py b/pisi/fetcher.py index dfaad20f..4469d4fd 100644 --- a/pisi/fetcher.py +++ b/pisi/fetcher.py @@ -11,7 +11,6 @@ import os # pisi modules import util -from config import config from purl import PUrl from ui import ui @@ -64,7 +63,7 @@ class Fetcher: return os.path.join(self.filedest, self.url.filename()) - def doGrab(self, file, dest, totalsize): + def doGrab(self, fileURI, dest, totalsize): symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s'] from time import time tt, oldsize = int(time()), 0 @@ -72,12 +71,12 @@ class Fetcher: bs, size = 1024, 0 symbol, depth = "B/s", 0 st = time() - chunk = file.read(bs) + chunk = fileURI.read(bs) size = size + len(chunk) self.percent = p.update(size) while chunk: dest.write(chunk) - chunk = file.read(bs) + chunk = fileURI.read(bs) size = size + len(chunk) ct = time() if int(tt) != int(ct): @@ -98,9 +97,7 @@ class Fetcher: dest.close() - def fetchLocalFile (self): - from shutil import copyfile url = self.url if os.access(url.path(), os.F_OK) == False: @@ -108,16 +105,15 @@ class Fetcher: dest = open(os.path.join(self.filedest, url.filename()) , "w") totalsize = os.path.getsize(url.path()) - file = open(url.path()) - self.doGrab(file, dest, totalsize) - + fileURI = open(url.path()) + self.doGrab(fileURI, dest, totalsize) def fetchRemoteFile (self): from httplib import HTTPException try: - file = urllib2.urlopen(self.url.uri) - headers = file.info() + fileURI = urllib2.urlopen(self.url.uri) + headers = fileURI.info() except ValueError, e: self.err('%s' % (e, )) @@ -133,7 +129,7 @@ class Fetcher: else: totalsize = int(headers['Content-Length']) dest = open(os.path.join(self.filedest, self.url.filename()) , "w") - self.doGrab(file, dest, totalsize) + self.doGrab(fileURI, dest, totalsize) def err (self, error): @@ -150,7 +146,7 @@ class Progress: percent = (size * 100) / self.totalsize if percent and self.percent is not percent: - self.percent = percent - return percent + self.percent = percent + return percent else: - return 0 + return 0