diff options
| author | Ben Finney <ben@benfinney.id.au> | 2008-05-16 20:12:36 +1000 |
|---|---|---|
| committer | Ben Finney <ben@benfinney.id.au> | 2008-05-16 20:12:36 +1000 |
| commit | f264f62b7602f960bc35f3f68b1ed14c61bbfdd5 (patch) | |
| tree | 1ee94164129169dda7273fb6553bef2a670d3d62 /apt | |
| parent | 97c3c24b3060e8280fffed68ed60a68e04f382ca (diff) | |
| download | python-apt-f264f62b7602f960bc35f3f68b1ed14c61bbfdd5.tar.gz | |
Limit code lines to maximum 79 characters, to conform with PEP 8.
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/__init__.py | 3 | ||||
| -rw-r--r-- | apt/cache.py | 6 | ||||
| -rw-r--r-- | apt/debfile.py | 18 | ||||
| -rw-r--r-- | apt/package.py | 16 | ||||
| -rw-r--r-- | apt/progress.py | 71 |
5 files changed, 69 insertions, 45 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index c6a2ff39..05407aff 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -6,7 +6,8 @@ import os # import some fancy classes from apt.package import Package from apt.cache import Cache -from apt.progress import OpProgress, FetchProgress, InstallProgress, CdromProgress +from apt.progress import ( + OpProgress, FetchProgress, InstallProgress, CdromProgress) from apt.cdrom import Cdrom from apt_pkg import SizeToStr, TimeToStr, VersionCompare diff --git a/apt/cache.py b/apt/cache.py index 3c3a25e5..a43bd5d7 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -51,7 +51,8 @@ class Cache(object): self._callbacks = {} if rootdir: apt_pkg.Config.Set("Dir", rootdir) - apt_pkg.Config.Set("Dir::State::status", rootdir + "/var/lib/dpkg/status") + apt_pkg.Config.Set( + "Dir::State::status", rootdir + "/var/lib/dpkg/status") self.open(progress) def _runCallbacks(self, name): @@ -153,7 +154,8 @@ class Cache(object): if item.StatIdle: transient = True continue - errMsg += "Failed to fetch %s %s\n" % (item.DescURI, item.ErrorText) + errMsg += "Failed to fetch %s %s\n" % ( + item.DescURI, item.ErrorText) failed = True # we raise a exception if the download failed or it was cancelt diff --git a/apt/debfile.py b/apt/debfile.py index 1a64b833..ca82bbdb 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -22,7 +22,9 @@ class DebPackage(object): " open given debfile " self.filename = filename if not arCheckMember(open(self.filename), "debian-binary"): - raise NoDebArchiveException, _("This is not a valid DEB archive, missing '%s' member" % "debian-binary") + raise NoDebArchiveException, _( + "This is not a valid DEB archive, missing '%s' member" + % "debian-binary") control = apt_inst.debExtractControl(open(self.filename)) self._sections = apt_pkg.ParseSection(control) self.pkgname = self._sections["Package"] @@ -34,18 +36,22 @@ class DebPackage(object): """ return the list of files in the deb """ files = [] - def extract_cb(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): - #print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\ - # % (What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) + def extract_cb( + What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): + #print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( + # What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) files.append(Name) for member in self._supported_data_members: if arCheckMember(open(self.filename), member): try: - apt_inst.debExtract(open(self.filename), extract_cb, member) + apt_inst.debExtract( + open(self.filename), extract_cb, member) break except SystemError, e: - return [_("List of files for '%s'could not be read" % self.filename)] + return [_( + "List of files for '%s'could not be read" + % self.filename)] return files filelist = property(filelist) diff --git a/apt/package.py b/apt/package.py index 51986874..e51ab98f 100644 --- a/apt/package.py +++ b/apt/package.py @@ -96,7 +96,8 @@ class Package(object): # check if we found a version if ver == None: - #print "No version for: %s (Candidate: %s)" % (self._pkg.Name, UseCandidate) + #print "No version for: %s (Candidate: %s)" % ( + # self._pkg.Name, UseCandidate) return False if ver.FileList == None: @@ -150,7 +151,10 @@ class Package(object): for depVerList in depends[t]: base_deps = [] for depOr in depVerList: - base_deps.append(BaseDependency(depOr.TargetPkg.Name, depOr.CompType, depOr.TargetVer, (t == "PreDepends"))) + base_deps.append( + BaseDependency( + depOr.TargetPkg.Name, depOr.CompType, + depOr.TargetVer, (t == "PreDepends"))) depends_list.append(Dependency(base_deps)) return depends_list @@ -441,7 +445,9 @@ class Package(object): self.markInstall() else: # FIXME: we may want to throw a exception here - sys.stderr.write("MarkUpgrade() called on a non-upgrable pkg: '%s'\n" % self._pkg.Name) + sys.stderr.write( + "MarkUpgrade() called on a non-upgrable pkg: '%s'\n" + % self._pkg.Name) def commit(self, fprogress, iprogress): """ commit the changes, need a FetchProgress and InstallProgress @@ -478,7 +484,9 @@ if __name__ == "__main__": print "PackageSize: %s " % pkg.packageSize print "Dependencies: %s" % pkg.installedDependencies for dep in pkg.candidateDependencies: - print ",".join(["%s (%s) (%s) (%s)" % (o.name, o.version, o.relation, o.preDepend) for o in dep.or_dependencies]) + print ",".join( + ["%s (%s) (%s) (%s)" % (o.name, o.version, o.relation, o.preDepend) + for o in dep.or_dependencies]) print "arch: %s" % pkg.architecture print "homepage: %s" % pkg.homepage print "rec: ", pkg.candidateRecord diff --git a/apt/progress.py b/apt/progress.py index 1f2d4e7c..96112d73 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -95,9 +95,13 @@ class FetchProgress(object): """ called periodically (to update the gui), importend to return True to continue or False to cancel """ - self.percent = ((self.currentBytes + self.currentItems)*100.0)/float(self.totalBytes+self.totalItems) + self.percent = ( + ((self.currentBytes + self.currentItems) * 100.0) + / float(self.totalBytes+self.totalItems)) if self.currentCPS > 0: - self.eta = (self.totalBytes-self.currentBytes)/float(self.currentCPS) + self.eta = ( + (self.totalBytes - self.currentBytes) + / float(self.currentCPS)) return True def mediaChange(self, medium, drive): @@ -193,38 +197,41 @@ class InstallProgress(DumbInstallProgress): def updateInterface(self): if self.statusfd != None: + try: + while not self.read.endswith("\n"): + self.read += os.read(self.statusfd.fileno(), 1) + except OSError, (errno, errstr): + # resource temporarly unavailable is ignored + if errno != EAGAIN and errnor != EWOULDBLOCK: + print errstr + if self.read.endswith("\n"): + s = self.read + #print s try: - while not self.read.endswith("\n"): - self.read += os.read(self.statusfd.fileno(), 1) - except OSError, (errno, errstr): - # resource temporarly unavailable is ignored - if errno != EAGAIN and errnor != EWOULDBLOCK: - print errstr - if self.read.endswith("\n"): - s = self.read - #print s - try: - (status, pkg, percent, status_str) = string.split(s, ":", 3) - except ValueError, e: - # silently ignore lines that can't be parsed - self.read = "" - return - #print "percent: %s %s" % (pkg, float(percent)/100.0) - if status == "pmerror": - self.error(pkg, status_str) - elif status == "pmconffile": - # we get a string like this: - # 'current-conffile' 'new-conffile' useredited distedited - match = re.compile("\s*\'(.*)\'\s*\'(.*)\'.*").match(status_str) - if match: - self.conffile(match.group(1), match.group(2)) - elif status == "pmstatus": - if float(percent) != self.percent or \ - status_str != self.status: - self.statusChange(pkg, float(percent), status_str.strip()) - self.percent = float(percent) - self.status = string.strip(status_str) + (status, pkg, percent, status_str) = string.split( + s, ":", 3) + except ValueError, e: + # silently ignore lines that can't be parsed self.read = "" + return + #print "percent: %s %s" % (pkg, float(percent)/100.0) + if status == "pmerror": + self.error(pkg, status_str) + elif status == "pmconffile": + # we get a string like this: + # 'current-conffile' 'new-conffile' useredited distedited + match = re.compile( + "\s*\'(.*)\'\s*\'(.*)\'.*").match(status_str) + if match: + self.conffile(match.group(1), match.group(2)) + elif status == "pmstatus": + if float(percent) != self.percent or \ + status_str != self.status: + self.statusChange( + pkg, float(percent), status_str.strip()) + self.percent = float(percent) + self.status = string.strip(status_str) + self.read = "" def fork(self): return os.fork() |
