From b147f1846cd26ab25ad925105f52421992395918 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Fri, 16 May 2008 14:58:00 +1000 Subject: Remove trailing whitespace. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index b8819b31..72fada77 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ for template in glob.glob('data/templates/*.info.in'): source.close() build.close() -setup(name="python-apt", +setup(name="python-apt", version="0.6.17", description="Python bindings for APT", author="APT Development Team", -- cgit v1.2.3 From 0d12af28d4de2745f8831abf0224ceabec693b76 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Fri, 16 May 2008 18:04:01 +1000 Subject: Fix spaces adjacent to commas and operators, to conform with PEP 8. --- apt/cache.py | 4 ++-- apt/cdrom.py | 2 +- apt/debfile.py | 4 ++-- apt/package.py | 24 ++++++++++++------------ apt/progress.py | 30 +++++++++++++++--------------- aptsources/distinfo.py | 16 ++++++++-------- aptsources/distro.py | 2 +- aptsources/sourceslist.py | 28 ++++++++++++++-------------- doc/examples/acquire.py | 8 ++++---- doc/examples/all_deps.py | 4 ++-- doc/examples/cdrom.py | 2 +- doc/examples/config.py | 32 ++++++++++++++++---------------- doc/examples/configisc.py | 14 +++++++------- doc/examples/deb_inspect.py | 8 ++++---- doc/examples/desc.py | 6 +++--- doc/examples/gui-inst.py | 8 ++++---- doc/examples/indexfile.py | 2 +- doc/examples/inst.py | 4 ++-- doc/examples/metaindex.py | 6 +++--- doc/examples/print_uris.py | 2 +- doc/examples/progress.py | 4 ++-- doc/examples/tagfile.py | 6 +++--- doc/examples/update.py | 2 +- doc/examples/versiontest.py | 24 ++++++++++++------------ setup.py | 35 ++++++++++++++++++----------------- tests/apt-test.py | 2 +- tests/cache.py | 2 +- tests/depcache.py | 4 ++-- tests/lock.py | 6 +++--- tests/memleak.py | 4 ++-- tests/pkgproblemresolver.py | 2 +- tests/pkgrecords.py | 4 ++-- tests/pkgsrcrecords.py | 2 +- tests/refcount.py | 2 +- tests/test_aptsources.py | 18 +++++++++--------- 35 files changed, 162 insertions(+), 161 deletions(-) (limited to 'setup.py') diff --git a/apt/cache.py b/apt/cache.py index 35da7970..3c3a25e5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -153,7 +153,7 @@ 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 @@ -371,7 +371,7 @@ if __name__ == "__main__": for d in ["/tmp/pytest", "/tmp/pytest/partial"]: if not os.path.exists(d): os.mkdir(d) - apt_pkg.Config.Set("Dir::Cache::Archives","/tmp/pytest") + apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.GetPackageManager(c._depcache) fetcher = apt_pkg.GetAcquire(apt.progress.TextFetchProgress()) c._fetchArchives(fetcher, pm) diff --git a/apt/cdrom.py b/apt/cdrom.py index 7f9b4776..d6f098db 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -18,7 +18,7 @@ class Cdrom(object): self._progress = progress # see if we have a alternative mountpoint if mountpoint is not None: - apt_pkg.Config.Set("Acquire::cdrom::mount",mountpoint) + apt_pkg.Config.Set("Acquire::cdrom::mount", mountpoint) # do not mess with mount points by default if nomount is True: apt_pkg.Config.Set("APT::CDROM::NoMount", "true") diff --git a/apt/debfile.py b/apt/debfile.py index 365847d7..1a64b833 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -34,9 +34,9 @@ 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): + 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) + # % (What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) files.append(Name) for member in self._supported_data_members: diff --git a/apt/package.py b/apt/package.py index b771c677..eef598af 100644 --- a/apt/package.py +++ b/apt/package.py @@ -102,7 +102,7 @@ class Package(object): print "No FileList for: %s " % self._pkg.Name() return False f, index = ver.FileList.pop(0) - self._records.Lookup((f,index)) + self._records.Lookup((f, index)) return True @@ -259,11 +259,11 @@ class Package(object): self._records.Lookup(desc_iter.FileList.pop(0)) desc = "" try: - s = unicode(self._records.LongDesc,"utf-8") - except UnicodeDecodeError,e: + s = unicode(self._records.LongDesc, "utf-8") + except UnicodeDecodeError, e: s = _("Invalid unicode in description for '%s' (%s). " - "Please report.") % (self.name,e) - for line in string.split(s,"\n"): + "Please report.") % (self.name, e) + for line in string.split(s, "\n"): tmp = string.strip(line) if tmp == ".": desc += "\n" @@ -380,7 +380,7 @@ class Package(object): def __repr__(self): return "component: '%s' archive: '%s' origin: '%s' label: '%s' " \ - "site '%s' isTrusted: '%s'"% (self.component, self.archive, + "site '%s' isTrusted: '%s'" % (self.component, self.archive, self.origin, self.label, self.site, self.trusted) @@ -389,7 +389,7 @@ class Package(object): if not ver: return None origins = [] - for (verFileIter,index) in ver.FileList: + for (verFileIter, index) in ver.FileList: origins.append(self.Origin(self, verFileIter)) return origins candidateOrigin = property(candidateOrigin) @@ -440,7 +440,7 @@ 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 @@ -477,10 +477,10 @@ 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 + print "rec: ", pkg.candidateRecord # now test install/remove import apt @@ -491,7 +491,7 @@ if __name__ == "__main__": for name in cache.keys(): pkg = cache[name] if pkg.isUpgradable: - if random.randint(0,1) == 1: + if random.randint(0, 1) == 1: pkg.markInstall(i) print "Broken: %s " % cache._depcache.BrokenCount print "InstCount: %s " % cache._depcache.InstCount @@ -502,7 +502,7 @@ if __name__ == "__main__": print "Randomly remove some packages with AutoFix: %s" % i cache = apt.Cache(progress) for name in cache.keys(): - if random.randint(0,1) == 1: + if random.randint(0, 1) == 1: try: cache[name].markDelete(i) except SystemError: diff --git a/apt/progress.py b/apt/progress.py index 6f72197e..dbad8050 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -53,7 +53,7 @@ class OpTextProgress(OpProgress): OpProgress.__init__(self) def update(self, percent): - sys.stdout.write("\r%s: %.2i " % (self.subOp,percent)) + sys.stdout.write("\r%s: %.2i " % (self.subOp, percent)) sys.stdout.flush() def done(self): @@ -71,11 +71,11 @@ class FetchProgress(object): dlFailed = 2 dlHit = 3 dlIgnored = 4 - dlStatusStr = {dlDone : "Done", - dlQueued : "Queued", - dlFailed : "Failed", - dlHit : "Hit", - dlIgnored : "Ignored"} + dlStatusStr = {dlDone: "Done", + dlQueued: "Queued", + dlFailed: "Failed", + dlHit: "Hit", + dlIgnored: "Ignored"} def __init__(self): self.eta = 0.0 @@ -134,7 +134,7 @@ class TextFetchProgress(FetchProgress): """ react to media change events """ res = True; print "Media change: please insert the disc labeled \ - '%s' in the drive '%s' and press enter" % (medium,drive) + '%s' in the drive '%s' and press enter" % (medium, drive) s = sys.stdin.readline() if(s == 'c' or s == 'C'): res = false; @@ -174,7 +174,7 @@ class InstallProgress(DumbInstallProgress): (read, write) = os.pipe() self.writefd=write self.statusfd = os.fdopen(read, "r") - fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL,os.O_NONBLOCK) + fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) self.read = "" self.percent = 0.0 self.status = "" @@ -183,7 +183,7 @@ class InstallProgress(DumbInstallProgress): " called when a error is detected during the install " pass - def conffile(self,current,new): + def conffile(self, current, new): " called when a conffile question from dpkg is detected " pass @@ -195,8 +195,8 @@ class InstallProgress(DumbInstallProgress): if self.statusfd != None: try: while not self.read.endswith("\n"): - self.read += os.read(self.statusfd.fileno(),1) - except OSError, (errno,errstr): + 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 @@ -204,14 +204,14 @@ class InstallProgress(DumbInstallProgress): s = self.read #print s try: - (status, pkg, percent, status_str) = string.split(s, ":",3) + (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) + self.error(pkg, status_str) elif status == "pmconffile": # we get a string like this: # 'current-conffile' 'new-conffile' useredited distedited @@ -231,9 +231,9 @@ class InstallProgress(DumbInstallProgress): def waitChild(self): while True: - select.select([self.statusfd],[],[], self.selectTimeout) + select.select([self.statusfd], [], [], self.selectTimeout) self.updateInterface() - (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) + (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) if pid == self.child_pid: break return os.WEXITSTATUS(res) diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 4a601be3..57266a49 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -139,8 +139,8 @@ class Repository: def split_url(url): ''' split a given URL into the protocoll, the hostname and the dir part ''' - return map(lambda a,b: a, re.split(":*\/+", url, maxsplit=2), - [None, None, None]) + return map(lambda a, b: a, re.split(":*\/+", url, maxsplit=2), + [None, None, None]) class DistInfo: @@ -167,17 +167,17 @@ class DistInfo: map_mirror_sets = {} dist_fname = "%s/%s.info" % (base_dir, dist) - dist_file = open (dist_fname) + dist_file = open(dist_fname) if not dist_file: return template = None component = None for line in dist_file: - tokens = line.split (':', 1) - if len (tokens) < 2: + tokens = line.split(':', 1) + if len(tokens) < 2: continue - field = tokens[0].strip () - value = tokens[1].strip () + field = tokens[0].strip() + value = tokens[1].strip() if field == 'ChangelogURI': self.changelogs_uri = _(value) elif field == 'MetaReleaseURI': @@ -251,7 +251,7 @@ class DistInfo: template = None if __name__ == "__main__": - d = DistInfo ("Ubuntu", "/usr/share/python-apt/templates") + d = DistInfo("Ubuntu", "/usr/share/python-apt/templates") print d.changelogs_uri for template in d.templates: print "\nSuite: %s" % template.name diff --git a/aptsources/distro.py b/aptsources/distro.py index 962c57bc..f39f6748 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -108,7 +108,7 @@ class Distribution: elif source.uri.startswith("cdrom:") and \ source.disabled == True: self.cdrom_sources.append(source) - elif source.type == self.binary_type and \ + elif source.type == self.binary_type and \ source.disabled == False: self.main_sources.append(source) comps.extend(source.comps) diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 57be2a68..dfc0ccb6 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -78,7 +78,7 @@ def uniq(s): class SourceEntry: """ single sources.list entry """ - def __init__(self, line,file=None): + def __init__(self, line, file=None): self.invalid = False # is the source entry valid self.disabled = False # is it disabled ('#' in front) self.type = "" # what type (deb, deb-src) @@ -131,10 +131,10 @@ class SourceEntry: pieces.append(tmp) return pieces - def parse(self,line): + def parse(self, line): """ parse a given sources.list (textual) line and break it up into the field we have """ - line = string.strip(self.line) + line = string.strip(self.line) #print line # check if the source is enabled/disabled if line == "" or line == "#": # empty line @@ -295,11 +295,11 @@ class SourcesList: source.disabled = False return source # there isn't any matching source, so create a new line and parse it - line = "%s %s %s" % (type,uri,dist) + line = "%s %s %s" % (type, uri, dist) for c in comps: line = line + " " + c; if comment != "": - line = "%s #%s\n" %(line,comment) + line = "%s #%s\n" % (line, comment) line = line + "\n" new_entry = SourceEntry(line) if file != None: @@ -317,13 +317,13 @@ class SourcesList: dir = apt_pkg.Config.FindDir("Dir::Etc") file = apt_pkg.Config.Find("Dir::Etc::sourcelist") if os.path.exists(dir+file+backup_ext) and \ - os.path.exists(dir+file): - shutil.copy(dir+file+backup_ext,dir+file) + os.path.exists(dir+file): + shutil.copy(dir+file+backup_ext, dir+file) # now sources.list.d partsdir = apt_pkg.Config.FindDir("Dir::Etc::sourceparts") for file in glob.glob("%s/*.list" % partsdir): if os.path.exists(file+backup_ext): - shutil.copy(file+backup_ext,file) + shutil.copy(file+backup_ext, file) def backup(self, backup_ext=None): """ make a backup of the current source files, if no backup extension @@ -333,16 +333,16 @@ class SourcesList: backup_ext = time.strftime("%y%m%d.%H%M") for source in self.list: if not source.file in already_backuped and os.path.exists(source.file): - shutil.copy(source.file,"%s%s" % (source.file,backup_ext)) + shutil.copy(source.file, "%s%s" % (source.file, backup_ext)) return backup_ext - def load(self,file): + def load(self, file): """ (re)load the current sources """ try: f = open(file, "r") lines = f.readlines() for line in lines: - source = SourceEntry(line,file) + source = SourceEntry(line, file) self.list.append(source) except: print "could not open file '%s'" % file @@ -359,11 +359,11 @@ class SourcesList: header = ("## See sources.list(5) for more information, especialy\n" "# Remember that you can only use http, ftp or file URIs\n" "# CDROMs are managed through the apt-cdrom tool.\n") - open(path,"w").write(header) + open(path, "w").write(header) return for source in self.list: if not files.has_key(source.file): - files[source.file]=open(source.file,"w") + files[source.file] = open(source.file, "w") files[source.file].write(source.str()) for f in files: files[f].close() @@ -406,7 +406,7 @@ class SourceEntryMatcher: f = os.path.basename(f) i = f.find(".info") f = f[0:i] - dist = DistInfo(f,base_dir=matcherPath) + dist = DistInfo(f, base_dir=matcherPath) for template in dist.templates: if template.match_uri != None: self.templates.append(template) diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 7bf7d646..e42a9401 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -20,7 +20,7 @@ def get_file(fetcher, uri, destFile): os.chdir(cwd) return False filename = os.path.basename(uri) - os.rename(dir+"/"+filename,destFile) + os.rename(dir+"/"+filename, destFile) # cleanup os.rmdir(dir) os.chdir(cwd) @@ -44,7 +44,7 @@ depcache.Upgrade(True) progress = apt.progress.TextFetchProgress() fetcher = apt_pkg.GetAcquire(progress) pm = apt_pkg.GetPackageManager(depcache) -pm.GetArchives(fetcher,list,recs) +pm.GetArchives(fetcher, list, recs) print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded) actiongroup = apt_pkg.GetPkgActionGroup(depcache) for pkg in cache.Packages: @@ -55,7 +55,7 @@ try: os.mkdir("/tmp/pyapt-test/partial") except OSError: pass -apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test") +apt_pkg.Config.Set("Dir::Cache::archives", "/tmp/pyapt-test") pkg = cache["3ddesktop"] depcache.MarkInstall(pkg) @@ -70,7 +70,7 @@ print fetcher get_file(fetcher, "ftp://ftp.debian.org/debian/dists/README", "/tmp/lala") -pm.GetArchives(fetcher,list,recs) +pm.GetArchives(fetcher, list, recs) for item in fetcher.Items: print item diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py index f4f1741c..37222463 100644 --- a/doc/examples/all_deps.py +++ b/doc/examples/all_deps.py @@ -26,9 +26,9 @@ pkg = c[pkgname] deps = set() -deps = dependencies(c,pkg, deps, "Depends") +deps = dependencies(c, pkg, deps, "Depends") print " ".join(deps) preDeps = set() -preDeps = dependencies(c,pkg, preDeps, "PreDepends") +preDeps = dependencies(c, pkg, preDeps, "PreDepends") print " ".join(preDeps) diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py index e54eb763..289b10f1 100644 --- a/doc/examples/cdrom.py +++ b/doc/examples/cdrom.py @@ -16,7 +16,7 @@ print cdrom progress = CdromProgress() -(res,ident) = cdrom.Ident(progress) +(res, ident) = cdrom.Ident(progress) print "ident result is: %s (%s) " % (res, ident) apt_pkg.Config.Set("APT::CDROM::Rename", "True") diff --git a/doc/examples/config.py b/doc/examples/config.py index 337899f0..cd7bcae0 100755 --- a/doc/examples/config.py +++ b/doc/examples/config.py @@ -12,7 +12,7 @@ # This shows how to use the system for configuration and option control. # The other varient is for ISC object config files. See configisc.py. -import apt_pkg,sys,posixpath; +import apt_pkg, sys, posixpath # Create a new empty Configuration object - there is also the system global # configuration object apt_pkg.Config which is used interally by apt-pkg @@ -20,30 +20,30 @@ import apt_pkg,sys,posixpath; # whenever possible.. Cnf = apt_pkg.newConfiguration(); -print "Command line is",sys.argv +print "Command line is", sys.argv # Load the default configuration file, InitConfig() does this better.. -Cnf.Set("config-file","/etc/apt/apt.conf"); # or Cnf["config-file"] = ".."; +Cnf.Set("config-file", "/etc/apt/apt.conf") # or Cnf["config-file"] = ".." if posixpath.exists(Cnf.FindFile("config-file")): - apt_pkg.ReadConfigFile(Cnf,"/etc/apt/apt.conf"); + apt_pkg.ReadConfigFile(Cnf, "/etc/apt/apt.conf") # Merge the command line arguments into the configuration space -Arguments = [('h',"help","help"), - ('v',"version","version"), - ('q',"quiet","quiet","IntLevel"), - ('c',"config-file","","ConfigFile"), - ('o',"option","","ArbItem")] -print "FileNames",apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); +Arguments = [('h', "help", "help"), + ('v', "version", "version"), + ('q', "quiet", "quiet", "IntLevel"), + ('c', "config-file", "", "ConfigFile"), + ('o', "option", "", "ArbItem")] +print "FileNames", apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) -print "Quiet level selected is",Cnf.FindI("quiet",0); +print "Quiet level selected is", Cnf.FindI("quiet", 0) # Do some stuff with it -if Cnf.FindB("version",0) == 1: +if Cnf.FindB("version", 0) == 1: print "Version selected - 1.1"; -if Cnf.FindB("help",0) == 1: - print apt_pkg.Package,apt_pkg.Version,"for",apt_pkg.Architecture, \ - "compiled on",apt_pkg.Date,apt_pkg.Time; +if Cnf.FindB("help", 0) == 1: + print apt_pkg.Package, apt_pkg.Version, "for", apt_pkg.Architecture, \ + "compiled on", apt_pkg.Date, apt_pkg.Time print "Hi, I am the help text for this program"; sys.exit(0); @@ -52,4 +52,4 @@ print "No help for you, try -h"; # Print the configuration space print "The Configuration space looks like:"; for I in Cnf.keys(): - print "%s \"%s\";"%(I,Cnf[I]); + print "%s \"%s\";" % (I, Cnf[I]) diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py index 45a9c7f6..4d0d33d4 100755 --- a/doc/examples/configisc.py +++ b/doc/examples/configisc.py @@ -8,32 +8,32 @@ # doc/examples/ftp-archive.conf # or a bind8 config file.. -import apt_pkg,sys,posixpath; +import apt_pkg, sys, posixpath -ConfigFile = apt_pkg.ParseCommandLine(apt_pkg.Config,[],sys.argv); +ConfigFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) if len(ConfigFile) != 1: print "Must have exactly 1 file name"; sys.exit(0); Cnf = apt_pkg.newConfiguration(); -apt_pkg.ReadConfigFileISC(Cnf,ConfigFile[0]); +apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0]) # Print the configuration space #print "The Configuration space looks like:"; #for I in Cnf.keys(): -# print "%s \"%s\";"%(I,Cnf[I]); +# print "%s \"%s\";" % (I, Cnf[I]) # bind8 config file.. if Cnf.has_key("Zone"): - print "Zones: ",Cnf.SubTree("zone").List(); + print "Zones: ", Cnf.SubTree("zone").List() for I in Cnf.List("zone"): SubCnf = Cnf.SubTree(I); if SubCnf.Find("type") == "slave": - print "Masters for %s: %s"%(SubCnf.MyTag(),SubCnf.ValueList("masters")); + print "Masters for %s: %s" % (SubCnf.MyTag(), SubCnf.ValueList("masters")) else: print "Tree definitions:"; for I in Cnf.List("tree"): SubCnf = Cnf.SubTree(I); # This could use Find which would eliminate the possibility of exceptions. - print "Subtree %s with sections '%s' and architectures '%s'"%(SubCnf.MyTag(),SubCnf["Sections"],SubCnf["Architectures"]); + print "Subtree %s with sections '%s' and architectures '%s'" % (SubCnf.MyTag(), SubCnf["Sections"], SubCnf["Architectures"]) diff --git a/doc/examples/deb_inspect.py b/doc/examples/deb_inspect.py index 68219d6d..f3e5ae2b 100755 --- a/doc/examples/deb_inspect.py +++ b/doc/examples/deb_inspect.py @@ -7,11 +7,11 @@ import sys import os.path -def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): +def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): """ callback for debExtract """ - print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\ - % (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) if __name__ == "__main__": @@ -40,7 +40,7 @@ if __name__ == "__main__": print "extracting archive" dir = "/tmp/deb" os.mkdir(dir) - apt_inst.debExtractArchive(open(file),dir) + apt_inst.debExtractArchive(open(file), dir) def visit(arg, dirname, names): print "%s/" % dirname diff --git a/doc/examples/desc.py b/doc/examples/desc.py index 1d43f2f9..f47517cf 100644 --- a/doc/examples/desc.py +++ b/doc/examples/desc.py @@ -3,7 +3,7 @@ import apt_pkg apt_pkg.init() -apt_pkg.Config.Set("APT::Acquire::Translation","de") +apt_pkg.Config.Set("APT::Acquire::Translation", "de") cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) @@ -15,10 +15,10 @@ print cand desc = cand.TranslatedDescription print desc print desc.FileList -(f,index) = desc.FileList.pop(0) +(f, index) = desc.FileList.pop(0) records = apt_pkg.GetPkgRecords(cache) -records.Lookup((f,index)) +records.Lookup((f, index)) desc = records.LongDesc print len(desc) print desc diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index edaec455..61db63f8 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -32,7 +32,7 @@ class GuiFetchProgress(gtk.Window, FetchProgress): self.label.show() self.vbox.pack_start(self.progress) self.vbox.pack_start(self.label) - self.resize(300,100) + self.resize(300, 100) def start(self): print "start" @@ -64,15 +64,15 @@ class TermInstallProgress(InstallProgress, gtk.Window): self.term.show() # check for the child self.reaper = vte.reaper_get() - self.reaper.connect("child-exited",self.child_exited) + self.reaper.connect("child-exited", self.child_exited) self.finished = False box.pack_start(self.term) self.progressbar = gtk.ProgressBar() self.progressbar.show() box.pack_start(self.progressbar) - def child_exited(self,term, pid, status): - print "child_exited: %s %s %s %s" % (self,term,pid,status) + def child_exited(self, term, pid, status): + print "child_exited: %s %s %s %s" % (self, term, pid, status) self.apt_status = posix.WEXITSTATUS(status) self.finished = True diff --git a/doc/examples/indexfile.py b/doc/examples/indexfile.py index d383fd61..22d0b635 100644 --- a/doc/examples/indexfile.py +++ b/doc/examples/indexfile.py @@ -10,7 +10,7 @@ cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) pkg = cache["libimlib2"] cand = depcache.GetCandidateVer(pkg) -for (f,i) in cand.FileList: +for (f, i) in cand.FileList: index = sources.FindIndex(f) print index if index: diff --git a/doc/examples/inst.py b/doc/examples/inst.py index b37ab4cd..723038c1 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -23,8 +23,8 @@ class TextInstallProgress(InstallProgress): sys.stdout.flush() self.last = self.percent - def conffile(self,current,new): - print "conffile prompt: %s %s" % (current,new) + def conffile(self, current, new): + print "conffile prompt: %s %s" % (current, new) def error(self, errorstr): print "got dpkg error: '%s'" % errorstr diff --git a/doc/examples/metaindex.py b/doc/examples/metaindex.py index 1bce0dba..f00a7e01 100644 --- a/doc/examples/metaindex.py +++ b/doc/examples/metaindex.py @@ -9,7 +9,7 @@ sources.ReadMainList() for metaindex in sources.List: print metaindex - print "URI: ",metaindex.URI - print "Dist: ",metaindex.Dist - print "IndexFiles: ","\n".join([str(i) for i in metaindex.IndexFiles]) + print "URI: ", metaindex.URI + print "Dist: ", metaindex.Dist + print "IndexFiles: ", "\n".join([str(i) for i in metaindex.IndexFiles]) print diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py index 3c93a668..3b678e83 100755 --- a/doc/examples/print_uris.py +++ b/doc/examples/print_uris.py @@ -15,7 +15,7 @@ for pkg in upgradable: pkg._lookupRecord(True) path = apt_pkg.ParseSection(pkg._records.Record)["Filename"] cand = pkg._depcache.GetCandidateVer(pkg._pkg) - for (packagefile,i) in cand.FileList: + for (packagefile, i) in cand.FileList: indexfile = cache._list.FindIndex(packagefile) if indexfile: uri = indexfile.ArchiveURI(path) diff --git a/doc/examples/progress.py b/doc/examples/progress.py index d8f00a52..70fc92f3 100644 --- a/doc/examples/progress.py +++ b/doc/examples/progress.py @@ -34,7 +34,7 @@ class TextFetchProgress(apt.FetchProgress): pass def updateStatus(self, uri, descr, shortDescr, status): - print "UpdateStatus: '%s' '%s' '%s' '%i'" % (uri,descr,shortDescr, status) + print "UpdateStatus: '%s' '%s' '%s' '%i'" % (uri, descr, shortDescr, status) def pulse(self): print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (SizeToStr(self.currentCPS), SizeToStr(self.currentBytes), SizeToStr(self.totalBytes), self.currentItems, self.totalItems) @@ -86,7 +86,7 @@ class TextCdromProgress(apt.CdromProgress): def changeCdrom(self): print "Please insert cdrom and press " - answer = sys.stdin.readline() + answer = sys.stdin.readline() return True diff --git a/doc/examples/tagfile.py b/doc/examples/tagfile.py index aeba34d2..4faf08ac 100755 --- a/doc/examples/tagfile.py +++ b/doc/examples/tagfile.py @@ -1,8 +1,8 @@ #!/usr/bin/env python import apt_pkg -Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/status","r")); +Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/status", "r")) while Parse.Step() == 1: - print Parse.Section.get("Package"); - print apt_pkg.ParseDepends(Parse.Section.get("Depends","")); + print Parse.Section.get("Package") + print apt_pkg.ParseDepends(Parse.Section.get("Depends", "")) diff --git a/doc/examples/update.py b/doc/examples/update.py index be7bb679..364fa1c9 100755 --- a/doc/examples/update.py +++ b/doc/examples/update.py @@ -9,5 +9,5 @@ if __name__ == "__main__": "touch /tmp/update-was-run") c = apt.Cache() res = c.update(apt.progress.TextFetchProgress()) - print "res: ",res + print "res: ", res assert(os.path.exists("/tmp/update-about-to-run")) diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py index 8f18f6c8..29da3b8f 100755 --- a/doc/examples/versiontest.py +++ b/doc/examples/versiontest.py @@ -1,17 +1,17 @@ #!/usr/bin/python # This is a simple clone of tests/versiontest.cc -import apt_pkg,sys,re,string; +import apt_pkg, sys, re, string apt_pkg.InitConfig(); apt_pkg.InitSystem(); -TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config,[],sys.argv); +TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) if len(TestFile) != 1: print "Must have exactly 1 file name"; sys.exit(0); # Go over the file.. -List = open(TestFile[0],"r"); +List = open(TestFile[0], "r") CurLine = 0; while(1): Line = List.readline(); @@ -22,15 +22,15 @@ while(1): if len(Line) == 0 or Line[0] == '#': continue; - Split = re.split("[ \n]",Line); + Split = re.split("[ \n]", Line) # Check forward - if apt_pkg.VersionCompare(Split[0],Split[1]) != int(Split[2]): - print "Comparision failed on line %u. '%s' ? '%s' %i != %i"%(CurLine, - Split[0],Split[1],apt_pkg.VersionCompare(Split[0],Split[1]), - int(Split[2])); + if apt_pkg.VersionCompare(Split[0], Split[1]) != int(Split[2]): + print "Comparision failed on line %u. '%s' ? '%s' %i != %i" % (CurLine, + Split[0], Split[1], apt_pkg.VersionCompare(Split[0], Split[1]), + int(Split[2])) # Check reverse - if apt_pkg.VersionCompare(Split[1],Split[0]) != -1*int(Split[2]): - print "Comparision failed on line %u. '%s' ? '%s' %i != %i"%(CurLine, - Split[1],Split[0],apt_pkg.VersionCompare(Split[1],Split[0]), - -1*int(Split[2])); + if apt_pkg.VersionCompare(Split[1], Split[0]) != -1 * int(Split[2]): + print "Comparision failed on line %u. '%s' ? '%s' %i != %i" % (CurLine, + Split[1], Split[0], apt_pkg.VersionCompare(Split[1], Split[0]), + -1 * int(Split[2])) diff --git a/setup.py b/setup.py index 72fada77..2c11d9d3 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]); # The apt_inst module files = map(lambda source: "python/"+source, string.split(parse_makefile("python/makefile")["APT_INST_SRC"])) -apt_inst = Extension("apt_inst", files, libraries=["apt-pkg","apt-inst"]); +apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]); # Replace the leading _ that is used in the templates for translation templates = [] @@ -29,19 +29,20 @@ for template in glob.glob('data/templates/*.info.in'): source.close() build.close() -setup(name="python-apt", - version="0.6.17", - description="Python bindings for APT", - author="APT Development Team", - author_email="deity@lists.debian.org", - ext_modules=[apt_pkg,apt_inst], - packages=['apt', 'aptsources'], - data_files = [('share/python-apt/templates', - glob.glob('build/data/templates/*.info')), - ('share/python-apt/templates', - glob.glob('data/templates/*.mirrors'))], - cmdclass = { "build" : build_extra.build_extra, - "build_i18n" : build_i18n.build_i18n }, - license = 'GNU GPL', - platforms = 'posix' - ) +setup( + name="python-apt", + version="0.6.17", + description="Python bindings for APT", + author="APT Development Team", + author_email="deity@lists.debian.org", + ext_modules=[apt_pkg, apt_inst], + packages=['apt', 'aptsources'], + data_files=[('share/python-apt/templates', + glob.glob('build/data/templates/*.info')), + ('share/python-apt/templates', + glob.glob('data/templates/*.mirrors'))], + cmdclass={"build": build_extra.build_extra, + "build_i18n": build_i18n.build_i18n}, + license='GNU GPL', + platforms='posix', + ) diff --git a/tests/apt-test.py b/tests/apt-test.py index 6205cf60..fac2ff43 100644 --- a/tests/apt-test.py +++ b/tests/apt-test.py @@ -20,7 +20,7 @@ if __name__ == "__main__": cache = apt.Cache(progress) for name in cache.keys(): import random - if random.randint(0,1) == 1: + if random.randint(0, 1) == 1: cache[name].markDelete() print "Broken: %s " % cache._depcache.BrokenCount print "DelCount: %s " % cache._depcache.DelCount diff --git a/tests/cache.py b/tests/cache.py index 24732578..4e79eb3e 100644 --- a/tests/cache.py +++ b/tests/cache.py @@ -43,7 +43,7 @@ def main(): j = ver.DependsList pass - print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)), + print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), if __name__ == "__main__": diff --git a/tests/depcache.py b/tests/depcache.py index 32c510f0..5ed54895 100644 --- a/tests/depcache.py +++ b/tests/depcache.py @@ -31,8 +31,8 @@ def main(): if depcache.MarkedInstall(p): depcache.MarkKeep(p) if depcache.InstCount != 0: - print "Error undoing the selection for %s (InstCount: %s)" % (x,depcache.InstCount) - print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)), + print "Error undoing the selection for %s (InstCount: %s)" % (x, depcache.InstCount) + print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), print print "Trying Upgrade:" diff --git a/tests/lock.py b/tests/lock.py index aeab804b..8bd5619f 100644 --- a/tests/lock.py +++ b/tests/lock.py @@ -26,14 +26,14 @@ if __name__ == "__main__": apt_pkg.PkgSystemUnLock() # low-level lock - fd = apt_pkg.GetLock(lock,True) + fd = apt_pkg.GetLock(lock, True) print "Lockfile fd: %s" % fd # try to get lock without error flag pid = os.fork() if pid == 0: # child - fd = apt_pkg.GetLock(lock,False) + fd = apt_pkg.GetLock(lock, False) print "Lockfile fd (child): %s" % fd sys.exit(0) @@ -41,6 +41,6 @@ if __name__ == "__main__": pid = os.fork() if pid == 0: # child - fd = apt_pkg.GetLock(lock,True) + fd = apt_pkg.GetLock(lock, True) print "Lockfile fd (child): %s" % fd sys.exit(0) diff --git a/tests/memleak.py b/tests/memleak.py index 6eece9d4..659091fc 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -15,7 +15,7 @@ for i in range(100): print cache["apt"].name time.sleep(1) gc.collect() - f = open("%s" % i,"w") + f = open("%s" % i, "w") for obj in gc.get_objects(): f.write("%s\n" % str(obj)) f.close() @@ -37,7 +37,7 @@ for i in range(100): dict = {} for pkg in cache.Packages: if len(pkg.VersionList) > 0: - dict[pkg.Name] = apt.Package(cache,depcache, + dict[pkg.Name] = apt.Package(cache, depcache, records, list, None, pkg) print cache["apt"] diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py index 82186d40..7d5ae682 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/pkgproblemresolver.py @@ -49,7 +49,7 @@ def main(): depcache.MarkKeep(p) if depcache.InstCount != 0: print "Error undoing the selection for %s" % x - print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)), + print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), print print "Trying Upgrade:" diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py index 72096463..e128237b 100644 --- a/tests/pkgrecords.py +++ b/tests/pkgrecords.py @@ -25,12 +25,12 @@ def main(): if not version: continue file, index = version.FileList.pop(0) - if records.Lookup((file,index)): + if records.Lookup((file, index)): #print records.FileName x = records.FileName y = records.LongDesc pass - print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)), + print "\r%i/%i=%.3f%% " % (i, cache.PackageCount, (float(i) / float(cache.PackageCount) * 100)), if __name__ == "__main__": diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py index 3eb0fcab..6e78858b 100644 --- a/tests/pkgsrcrecords.py +++ b/tests/pkgsrcrecords.py @@ -19,7 +19,7 @@ def main(): if src.Lookup(x.Name): #print src.Package pass - print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)), + print "\r%i/%i=%.3f%% " % (i, cache.PackageCount, (float(i) / float(cache.PackageCount) * 100)), if __name__ == "__main__": diff --git a/tests/refcount.py b/tests/refcount.py index f3230bd3..a29744ae 100755 --- a/tests/refcount.py +++ b/tests/refcount.py @@ -1,6 +1,6 @@ #!/usr/bin/python-dbg -from pprint import pprint,pformat +from pprint import pprint, pformat import apt import sys import gc diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 08c8194a..9019aa2d 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -13,7 +13,7 @@ class TestAptSources(unittest.TestCase): unittest.TestCase.__init__(self, methodName) apt_pkg.init() apt_pkg.Config.Set("Dir::Etc", os.getcwd()) - apt_pkg.Config.Set("Dir::Etc::sourceparts",".") + apt_pkg.Config.Set("Dir::Etc::sourceparts", ".") def testIsMirror(self): self.assertTrue(aptsources.is_mirror("http://archive.ubuntu.com", @@ -22,7 +22,7 @@ class TestAptSources(unittest.TestCase): "http://ftp.debian.org")) def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list") + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") sources = aptsources.SourcesList() self.assertEqual(len(sources.list), 6) # test load @@ -31,22 +31,22 @@ class TestAptSources(unittest.TestCase): self.assertEqual(len(sources.list), 6) def testSourcesListAdding(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list") + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") sources = aptsources.SourcesList() # test to add something that is already there (main) before = copy.deepcopy(sources) - sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", "edgy", ["main"]) self.assertTrue(sources.list == before.list) # test to add something that is already there (restricted) before = copy.deepcopy(sources) - sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", "edgy", ["restricted"]) self.assertTrue(sources.list == before.list) # test to add something new: multiverse - sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", "edgy", ["multiverse"]) found = False @@ -60,7 +60,7 @@ class TestAptSources(unittest.TestCase): # test to add something new: multiverse *and* # something that is already there before = copy.deepcopy(sources) - sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", "edgy", ["universe", "something"]) found_universe = 0 @@ -79,7 +79,7 @@ class TestAptSources(unittest.TestCase): self.assertEqual(found_universe, 1) def testDistribution(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution") + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.testDistribution") sources = aptsources.SourcesList() distro = aptsources.Distribution() distro.get_sources(sources) @@ -89,7 +89,7 @@ class TestAptSources(unittest.TestCase): if s.template: dist_templates.add(s.template.name) #print dist_templates - for d in ["edgy","edgy-security","edgy-updates","hoary","breezy", "breezy-backports"]: + for d in ["edgy", "edgy-security", "edgy-updates", "hoary", "breezy", "breezy-backports"]: self.assertTrue(d in dist_templates) # test enable comp = "restricted" -- cgit v1.2.3 From 04dfb70356fc46a1b4e75f3370a4d64b5cc2d9b4 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Fri, 16 May 2008 19:27:02 +1000 Subject: Remove redundant semicolons from statements. --- apt/progress.py | 4 ++-- aptsources/sourceslist.py | 2 +- doc/examples/config.py | 12 ++++++------ doc/examples/configisc.py | 14 +++++++------- doc/examples/versiontest.py | 20 ++++++++++---------- setup.py | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) (limited to 'setup.py') diff --git a/apt/progress.py b/apt/progress.py index dbad8050..1f2d4e7c 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -132,12 +132,12 @@ class TextFetchProgress(FetchProgress): def mediaChange(self, medium, drive): """ react to media change events """ - res = True; + res = True print "Media change: please insert the disc labeled \ '%s' in the drive '%s' and press enter" % (medium, drive) s = sys.stdin.readline() if(s == 'c' or s == 'C'): - res = false; + res = false return res diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index dfc0ccb6..6eb69f6e 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -297,7 +297,7 @@ class SourcesList: # there isn't any matching source, so create a new line and parse it line = "%s %s %s" % (type, uri, dist) for c in comps: - line = line + " " + c; + line = line + " " + c if comment != "": line = "%s #%s\n" % (line, comment) line = line + "\n" diff --git a/doc/examples/config.py b/doc/examples/config.py index cd7bcae0..3a77301b 100755 --- a/doc/examples/config.py +++ b/doc/examples/config.py @@ -18,7 +18,7 @@ import apt_pkg, sys, posixpath # configuration object apt_pkg.Config which is used interally by apt-pkg # routines to control unusual situations. I recommend using the sytem global # whenever possible.. -Cnf = apt_pkg.newConfiguration(); +Cnf = apt_pkg.newConfiguration() print "Command line is", sys.argv @@ -39,17 +39,17 @@ print "Quiet level selected is", Cnf.FindI("quiet", 0) # Do some stuff with it if Cnf.FindB("version", 0) == 1: - print "Version selected - 1.1"; + print "Version selected - 1.1" if Cnf.FindB("help", 0) == 1: print apt_pkg.Package, apt_pkg.Version, "for", apt_pkg.Architecture, \ "compiled on", apt_pkg.Date, apt_pkg.Time - print "Hi, I am the help text for this program"; - sys.exit(0); + print "Hi, I am the help text for this program" + sys.exit(0) -print "No help for you, try -h"; +print "No help for you, try -h" # Print the configuration space -print "The Configuration space looks like:"; +print "The Configuration space looks like:" for I in Cnf.keys(): print "%s \"%s\";" % (I, Cnf[I]) diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py index 4d0d33d4..9a858657 100755 --- a/doc/examples/configisc.py +++ b/doc/examples/configisc.py @@ -13,14 +13,14 @@ import apt_pkg, sys, posixpath ConfigFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) if len(ConfigFile) != 1: - print "Must have exactly 1 file name"; - sys.exit(0); + print "Must have exactly 1 file name" + sys.exit(0) -Cnf = apt_pkg.newConfiguration(); +Cnf = apt_pkg.newConfiguration() apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0]) # Print the configuration space -#print "The Configuration space looks like:"; +#print "The Configuration space looks like:" #for I in Cnf.keys(): # print "%s \"%s\";" % (I, Cnf[I]) @@ -28,12 +28,12 @@ apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0]) if Cnf.has_key("Zone"): print "Zones: ", Cnf.SubTree("zone").List() for I in Cnf.List("zone"): - SubCnf = Cnf.SubTree(I); + SubCnf = Cnf.SubTree(I) if SubCnf.Find("type") == "slave": print "Masters for %s: %s" % (SubCnf.MyTag(), SubCnf.ValueList("masters")) else: - print "Tree definitions:"; + print "Tree definitions:" for I in Cnf.List("tree"): - SubCnf = Cnf.SubTree(I); + SubCnf = Cnf.SubTree(I) # This could use Find which would eliminate the possibility of exceptions. print "Subtree %s with sections '%s' and architectures '%s'" % (SubCnf.MyTag(), SubCnf["Sections"], SubCnf["Architectures"]) diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py index 29da3b8f..732eafac 100755 --- a/doc/examples/versiontest.py +++ b/doc/examples/versiontest.py @@ -2,25 +2,25 @@ # This is a simple clone of tests/versiontest.cc import apt_pkg, sys, re, string -apt_pkg.InitConfig(); -apt_pkg.InitSystem(); +apt_pkg.InitConfig() +apt_pkg.InitSystem() TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) if len(TestFile) != 1: - print "Must have exactly 1 file name"; - sys.exit(0); + print "Must have exactly 1 file name" + sys.exit(0) # Go over the file.. List = open(TestFile[0], "r") -CurLine = 0; +CurLine = 0 while(1): - Line = List.readline(); - CurLine = CurLine + 1; + Line = List.readline() + CurLine = CurLine + 1 if Line == "": - break; - Line = string.strip(Line); + break + Line = string.strip(Line) if len(Line) == 0 or Line[0] == '#': - continue; + continue Split = re.split("[ \n]", Line) diff --git a/setup.py b/setup.py index 2c11d9d3..eef54773 100755 --- a/setup.py +++ b/setup.py @@ -9,12 +9,12 @@ import glob, os, string # The apt_pkg module files = map(lambda source: "python/"+source, string.split(parse_makefile("python/makefile")["APT_PKG_SRC"])) -apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]); +apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module files = map(lambda source: "python/"+source, string.split(parse_makefile("python/makefile")["APT_INST_SRC"])) -apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]); +apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation templates = [] -- cgit v1.2.3 From 0432da5b015c8dfa30adb03c9fb9f5a83251acdd Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Fri, 16 May 2008 19:33:49 +1000 Subject: Imports on separate lines, to conform with PEP 8. --- doc/examples/cdrom.py | 3 ++- doc/examples/config.py | 4 +++- doc/examples/configisc.py | 4 +++- doc/examples/gui-inst.py | 4 +++- doc/examples/inst.py | 3 ++- doc/examples/versiontest.py | 6 +++++- setup.py | 4 +++- tests/lock.py | 3 ++- 8 files changed, 23 insertions(+), 8 deletions(-) (limited to 'setup.py') diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py index 289b10f1..743220a6 100644 --- a/doc/examples/cdrom.py +++ b/doc/examples/cdrom.py @@ -2,7 +2,8 @@ # example how to deal with the depcache import apt_pkg -import sys, os +import sys +import os import copy from progress import CdromProgress diff --git a/doc/examples/config.py b/doc/examples/config.py index 3a77301b..d0895690 100755 --- a/doc/examples/config.py +++ b/doc/examples/config.py @@ -12,7 +12,9 @@ # This shows how to use the system for configuration and option control. # The other varient is for ISC object config files. See configisc.py. -import apt_pkg, sys, posixpath +import apt_pkg +import sys +import posixpath # Create a new empty Configuration object - there is also the system global # configuration object apt_pkg.Config which is used interally by apt-pkg diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py index 9a858657..03fa2cad 100755 --- a/doc/examples/configisc.py +++ b/doc/examples/configisc.py @@ -8,7 +8,9 @@ # doc/examples/ftp-archive.conf # or a bind8 config file.. -import apt_pkg, sys, posixpath +import apt_pkg +import sys +import posixpath ConfigFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index 61db63f8..c14208ae 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -4,7 +4,9 @@ import apt import apt_pkg -import sys, os, fcntl +import sys +import os +import fcntl import copy import string import fcntl diff --git a/doc/examples/inst.py b/doc/examples/inst.py index 723038c1..a3a50356 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -2,7 +2,8 @@ # example how to deal with the depcache import apt -import sys, os +import sys +import os import copy import time diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py index 732eafac..dd881f6b 100755 --- a/doc/examples/versiontest.py +++ b/doc/examples/versiontest.py @@ -1,7 +1,11 @@ #!/usr/bin/python # This is a simple clone of tests/versiontest.cc -import apt_pkg, sys, re, string +import apt_pkg +import sys +import re +import string + apt_pkg.InitConfig() apt_pkg.InitSystem() diff --git a/setup.py b/setup.py index eef54773..ae1d46eb 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,9 @@ from distutils.core import setup, Extension from distutils.sysconfig import parse_makefile from DistUtilsExtra.command import * -import glob, os, string +import glob +import os +import string # The apt_pkg module files = map(lambda source: "python/"+source, diff --git a/tests/lock.py b/tests/lock.py index 8bd5619f..d45b3964 100644 --- a/tests/lock.py +++ b/tests/lock.py @@ -4,7 +4,8 @@ # import apt_pkg -import sys, os +import sys +import os if __name__ == "__main__": -- cgit v1.2.3 From 9358b351e8f1637ff87c9f9195a4b5e546ca2a79 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 9 Jan 2009 21:47:44 +0100 Subject: Cleanup: Remove whitespace at the end of line in all python codes. --- apt/cache.py | 42 +++++++++++++++--------------- apt/cdrom.py | 2 +- apt/debfile.py | 34 ++++++++++++------------ apt/gtk/widgets.py | 52 ++++++++++++++++++------------------- apt/package.py | 38 +++++++++++++-------------- apt/progress.py | 26 +++++++++---------- aptsources/__init__.py | 2 +- aptsources/distinfo.py | 22 ++++++++-------- aptsources/distro.py | 52 ++++++++++++++++++------------------- aptsources/sourceslist.py | 38 +++++++++++++-------------- doc/examples/acquire.py | 4 +-- doc/examples/build-deps.py | 2 +- doc/examples/deb_inspect.py | 2 +- doc/examples/gui-inst.py | 2 +- doc/examples/progress.py | 6 ++--- doc/examples/recommends.py | 2 +- doc/examples/versiontest.py | 6 ++--- setup.py | 2 +- tests/cache.py | 4 +-- tests/depcache.py | 2 +- tests/lock.py | 6 ++--- tests/pkgproblemresolver.py | 4 +-- tests/pkgrecords.py | 2 +- tests/pkgsrcrecords.py | 2 +- tests/test_aptsources.py | 4 +-- tests/test_debextract.py | 2 +- utils/get_debian_mirrors.py | 12 ++++----- utils/get_ubuntu_mirrors.py | 10 +++---- utils/get_ubuntu_mirrors_from_lp.py | 10 +++---- 29 files changed, 196 insertions(+), 196 deletions(-) (limited to 'setup.py') diff --git a/apt/cache.py b/apt/cache.py index 79e58282..530d56a0 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -1,19 +1,19 @@ # cache.py - apt cache abstraction -# +# # Copyright (c) 2005 Canonical -# +# # Author: Michael Vogt -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -36,7 +36,7 @@ class LockFailedException(IOError): pass class Cache(object): - """ Dictionary-like package cache + """ Dictionary-like package cache This class has all the packages that are available in it's dictionary """ @@ -56,7 +56,7 @@ class Cache(object): if self._callbacks.has_key(name): for callback in self._callbacks[name]: callback() - + def open(self, progress): """ Open the package cache, after that it can be used like a dictionary @@ -83,12 +83,12 @@ class Cache(object): self._dict[pkg.Name] = Package(self._cache, self._depcache, self._records, self._list, self, pkg) - + i += 1 if progress != None: progress.done() self._runCallbacks("cache_post_open") - + def __getitem__(self, key): """ look like a dictionary (get key) """ return self._dict[key] @@ -112,7 +112,7 @@ class Cache(object): def getChanges(self): """ Get the marked changes """ - changes = [] + changes = [] for name in self._dict.keys(): p = self._dict[name] if p.markedUpgrade or p.markedInstall or p.markedDelete or \ @@ -144,7 +144,7 @@ class Cache(object): " return the packages not downloadable packages in reqreinst state " reqreinst = set() for pkg in self: - if (not pkg.candidateDownloadable and + if (not pkg.candidateDownloadable and (pkg._pkg.InstState == apt_pkg.InstStateReInstReq or pkg._pkg.InstState == apt_pkg.InstStateHoldReInstReq)): reqreinst.add(pkg.name) @@ -153,7 +153,7 @@ class Cache(object): def _runFetcher(self, fetcher): # do the actual fetching res = fetcher.Run() - + # now check the result (this is the code from apt-get.cc) failed = False transient = False @@ -228,13 +228,13 @@ class Cache(object): return self._cache.Update(fetchProgress, self._list) finally: os.close(lock) - + def installArchives(self, pm, installProgress): installProgress.startUpdate() res = installProgress.run(pm) installProgress.finishUpdate() return res - + def commit(self, fetchProgress=None, installProgress=None): """ Apply the marked changes to the cache """ # FIXME: @@ -319,7 +319,7 @@ class FilteredCache(object): self._filters = [] def __len__(self): return len(self._filtered) - + def __getitem__(self, key): return self.cache._dict[key] @@ -337,7 +337,7 @@ class FilteredCache(object): if f.apply(self.cache._dict[pkg]): self._filtered[pkg] = 1 break - + def setFilter(self, filter): " set the current active filter " self._filters = [] @@ -361,7 +361,7 @@ class FilteredCache(object): return self.__dict__[key] else: return getattr(self.cache, key) - + def cache_pre_changed(): print "cache pre changed" @@ -413,7 +413,7 @@ if __name__ == "__main__": for pkg in f.keys(): #print c[pkg].name x = f[pkg].name - + print len(f) print "Testing filtered cache (no argument)" @@ -426,5 +426,5 @@ if __name__ == "__main__": for pkg in f.keys(): #print c[pkg].name x = f[pkg].name - + print len(f) diff --git a/apt/cdrom.py b/apt/cdrom.py index 9d4b62cb..c0e57094 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -44,4 +44,4 @@ class Cdrom(object): if not line.startswith("#") and cdid in line: return True return False - + diff --git a/apt/debfile.py b/apt/debfile.py index b1d436cd..33785ea0 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -32,7 +32,7 @@ from gettext import gettext as _ VERSION_OUTDATED, VERSION_SAME, VERSION_NEWER) = range(4) - + class NoDebArchiveException(IOError): pass @@ -63,7 +63,7 @@ class DebPackage(object): def __getitem__(self, key): return self._sections[key] - + def filelist(self): """ return the list of files in the deb """ files = [] @@ -105,7 +105,7 @@ class DebPackage(object): if instver != None and apt_pkg.CheckDep(instver,oper,ver) == True: return True return False - + def _satisfyOrGroup(self, or_group): """ try to satisfy the or_group """ @@ -128,7 +128,7 @@ class DebPackage(object): if len(providers) != 1: continue depname = providers[0].name - + # now check if we can satisfy the deps with the candidate(s) # in the cache cand = self._cache[depname] @@ -168,7 +168,7 @@ class DebPackage(object): #print "ver: %s" % ver #print "pkgver: %s " % pkgver #print "oper: %s " % oper - if (pkgver and apt_pkg.CheckDep(pkgver,oper,ver) and + if (pkgver and apt_pkg.CheckDep(pkgver,oper,ver) and not self.replacesRealPkg(pkgname, oper, ver)): self._failureString += _("Conflicts with the installed package '%s'" % cand.name) return True @@ -188,7 +188,7 @@ class DebPackage(object): # check conflicts with virtual pkgs if not self._cache.has_key(depname): - # FIXME: we have to check for virtual replaces here as + # FIXME: we have to check for virtual replaces here as # well (to pass tests/gdebi-test8.deb) if self._cache.isVirtualPackage(depname): for pkg in self._cache.getProvidingPackages(depname): @@ -208,7 +208,7 @@ class DebPackage(object): """ Return list of package names conflicting with this package. - WARNING: This method will is deprecated. Please use the + WARNING: This method will is deprecated. Please use the attribute DebPackage.depends instead. """ return self.conflicts @@ -228,7 +228,7 @@ class DebPackage(object): """ Return list of package names on which this package depends on. - WARNING: This method will is deprecated. Please use the + WARNING: This method will is deprecated. Please use the attribute DebPackage.depends instead. """ return self.depends @@ -249,7 +249,7 @@ class DebPackage(object): """ Return list of virtual packages which are provided by this package. - WARNING: This method will is deprecated. Please use the + WARNING: This method will is deprecated. Please use the attribute DebPackage.provides instead. """ return self.provides @@ -269,7 +269,7 @@ class DebPackage(object): """ Return list of packages which are replaced by this package. - WARNING: This method will is deprecated. Please use the + WARNING: This method will is deprecated. Please use the attribute DebPackage.replaces instead. """ return self.replaces @@ -286,9 +286,9 @@ class DebPackage(object): replaces = property(replaces) def replacesRealPkg(self, pkgname, oper, ver): - """ + """ return True if the deb packages replaces a real (not virtual) - packages named pkgname, oper, ver + packages named pkgname, oper, ver """ self._dbg(3, "replacesPkg() %s %s %s" % (pkgname,oper,ver)) pkgver = None @@ -299,7 +299,7 @@ class DebPackage(object): pkgver = cand.candidateVersion for or_group in self.getReplaces(): for (name, ver, oper) in or_group: - if (name == pkgname and + if (name == pkgname and apt_pkg.CheckDep(pkgver,oper,ver)): self._dbg(3, "we have a replaces in our package for the conflict against '%s'" % (pkgname)) return True @@ -316,7 +316,7 @@ class DebPackage(object): res = False return res - + def compareToVersionInCache(self, useInstalled=True): """ checks if the pkg is already installed or availabe in the cache and if so in what version, returns if the version of the deb @@ -485,14 +485,14 @@ class DscSrcPackage(DebPackage): self.binaries = [pkg.strip() for pkg in line[len("Binary:"):].split(",")] if line.startswith("Version:"): self._sections["Version"] = line[len("Version:"):].strip() - # we are at the end + # we are at the end if line.startswith("-----BEGIN PGP SIGNATURE-"): break s = _("Install Build-Dependencies for " "source package '%s' that builds %s\n" ) % (self.pkgName, " ".join(self.binaries)) self._sections["Description"] = s - + def checkDeb(self): if not self.checkConflicts(): for pkgname in self._installedConflicts: @@ -515,7 +515,7 @@ if __name__ == "__main__": print "Providers for %s :" % vp for pkg in providers: print " %s" % pkg.name - + d = DebPackage(sys.argv[1], cache) print "Deb: %s" % d.pkgname if not d.checkDeb(): diff --git a/apt/gtk/widgets.py b/apt/gtk/widgets.py index 3a15258f..968e2a77 100644 --- a/apt/gtk/widgets.py +++ b/apt/gtk/widgets.py @@ -8,8 +8,8 @@ Copyright (c) 2004,2005 Canonical Ltd. Authors: Michael Vogt Sebastian Heinlein -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as +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 2 of the License, or (at your option) any later version. @@ -17,7 +17,7 @@ his 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -44,9 +44,9 @@ class GOpProgress(gobject.GObject, apt.progress.OpProgress): __gsignals__ = {"status-changed":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_INT)), - "status-started":(gobject.SIGNAL_RUN_FIRST, + "status-started":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-finished":(gobject.SIGNAL_RUN_FIRST, + "status-finished":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())} def __init__(self): @@ -70,15 +70,15 @@ class GInstallProgress(gobject.GObject, apt.progress.InstallProgress): __gsignals__ = {"status-changed":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_INT)), - "status-started":(gobject.SIGNAL_RUN_FIRST, + "status-started":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-timeout":(gobject.SIGNAL_RUN_FIRST, + "status-timeout":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-error":(gobject.SIGNAL_RUN_FIRST, + "status-error":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-conffile":(gobject.SIGNAL_RUN_FIRST, + "status-conffile":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-finished":(gobject.SIGNAL_RUN_FIRST, + "status-finished":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())} def __init__(self, term): @@ -146,9 +146,9 @@ class GFetchProgress(gobject.GObject, apt.progress.FetchProgress): __gsignals__ = {"status-changed":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_INT)), - "status-started":(gobject.SIGNAL_RUN_FIRST, + "status-started":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()), - "status-finished":(gobject.SIGNAL_RUN_FIRST, + "status-finished":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())} def __init__(self): @@ -206,7 +206,7 @@ class GtkAptProgress(gtk.VBox): win.add(progress) progress.show() win.show() - + cache = apt.cache.Cache(progress.open)) cache["xterm"].markDelete() progress.show_terminal(expanded=True) @@ -243,33 +243,33 @@ class GtkAptProgress(gtk.VBox): self._progress_fetch = GFetchProgress() self._progress_fetch.connect("status-changed", self._on_status_changed) self._progress_fetch.connect("status-started", self._on_status_started) - self._progress_fetch.connect("status-finished", + self._progress_fetch.connect("status-finished", self._on_status_finished) self._progress_install = GInstallProgress(self._terminal) self._progress_install.connect("status-changed", self._on_status_changed) - self._progress_install.connect("status-started", + self._progress_install.connect("status-started", self._on_status_started) - self._progress_install.connect("status-finished", + self._progress_install.connect("status-finished", self._on_status_finished) - self._progress_install.connect("status-timeout", + self._progress_install.connect("status-timeout", self._on_status_timeout) - self._progress_install.connect("status-error", + self._progress_install.connect("status-error", self._on_status_timeout) - self._progress_install.connect("status-conffile", + self._progress_install.connect("status-conffile", self._on_status_timeout) self._progress_dpkg_install = GDpkgInstallProgress(self._terminal) self._progress_dpkg_install.connect("status-changed", self._on_status_changed) - self._progress_dpkg_install.connect("status-started", + self._progress_dpkg_install.connect("status-started", self._on_status_started) - self._progress_dpkg_install.connect("status-finished", + self._progress_dpkg_install.connect("status-finished", self._on_status_finished) - self._progress_dpkg_install.connect("status-timeout", + self._progress_dpkg_install.connect("status-timeout", self._on_status_timeout) - self._progress_dpkg_install.connect("status-error", + self._progress_dpkg_install.connect("status-error", self._on_status_timeout) - self._progress_dpkg_install.connect("status-conffile", + self._progress_dpkg_install.connect("status-conffile", self._on_status_timeout) def clear(self): @@ -300,7 +300,7 @@ class GtkAptProgress(gtk.VBox): Return the install progress handler for dpkg """ return self._dpkg_progress_install - + @property def fetch(self): """ @@ -382,7 +382,7 @@ if __name__ == "__main__": pkg.markInstall() apt_progress.show_terminal(True) try: - cache.commit(apt_progress.get_fetch_progress(), + cache.commit(apt_progress.get_fetch_progress(), apt_progress.get_install_progress()) except: pass diff --git a/apt/package.py b/apt/package.py index 70ddbb1a..9e69a6ec 100644 --- a/apt/package.py +++ b/apt/package.py @@ -1,19 +1,19 @@ # package.py - apt package abstraction -# +# # Copyright (c) 2005 Canonical -# +# # Author: Michael Vogt -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -92,7 +92,7 @@ class Package(object): if ver == None: #print "No version for: %s (Candidate: %s)" % (self._pkg.Name, UseCandidate) return False - + if ver.FileList == None: print "No FileList for: %s " % self._pkg.Name() return False @@ -147,7 +147,7 @@ class Package(object): base_deps.append(BaseDependency(depOr.TargetPkg.Name, depOr.CompType, depOr.TargetVer, (t == "PreDepends"))) depends_list.append(Dependency(base_deps)) return depends_list - + def candidateDependencies(self): """ return a list of candidate dependencies """ candver = self._depcache.GetCandidateVer(self._pkg) @@ -155,7 +155,7 @@ class Package(object): return [] return self._getDependencies(candver) candidateDependencies = property(candidateDependencies) - + def installedDependencies(self): """ return a list of installed dependencies """ ver = self._pkg.CurrentVer @@ -304,7 +304,7 @@ class Package(object): return "" return self._records.LongDesc rawDescription = property(rawDescription) - + def candidateRecord(self): " return the full pkgrecord as string of the candidate version " if not self._lookupRecord(True): @@ -333,7 +333,7 @@ class Package(object): def markedDelete(self): """ Package is marked for delete """ return self._depcache.MarkedDelete(self._pkg) - markedDelete = property(markedDelete) + markedDelete = property(markedDelete) def markedKeep(self): """ Package is marked for keep """ @@ -356,12 +356,12 @@ class Package(object): isInstalled = property(isInstalled) def isUpgradable(self): - """ Package is upgradable """ + """ Package is upgradable """ return self.isInstalled and self._depcache.IsUpgradable(self._pkg) isUpgradable = property(isUpgradable) def isAutoRemovable(self): - """ + """ Package is installed as a automatic dependency and is no longer required """ @@ -411,7 +411,7 @@ class Package(object): def getChangelog(self, uri=None, cancel_lock=None): """ - Download the changelog of the package and return it as unicode + Download the changelog of the package and return it as unicode string uri: Is the uri to the changelog file. The following named variables @@ -442,7 +442,7 @@ class Package(object): # get the src package name src_pkg = self.sourcePackageName - # assume "main" section + # assume "main" section src_section = "main" # use the section of the candidate as a starting point section = self._depcache.GetCandidateVer(self._pkg).Section @@ -454,7 +454,7 @@ class Package(object): try: # try to get the source version of the pkg, this differs # for some (e.g. libnspr4 on ubuntu) - # this feature only works if the correct deb-src are in the + # this feature only works if the correct deb-src are in the # sources.list # otherwise we fall back to the binary version number src_records = apt_pkg.GetPkgSrcRecords() @@ -563,7 +563,7 @@ class Package(object): "site '%s' isTrusted: '%s'"% (self.component, self.archive, self.origin, self.label, self.site, self.trusted) - + def candidateOrigin(self): ver = self._depcache.GetCandidateVer(self._pkg) if not ver: @@ -623,7 +623,7 @@ class Package(object): object as argument """ self._depcache.Commit(fprogress, iprogress) - + # self-test if __name__ == "__main__": diff --git a/apt/progress.py b/apt/progress.py index a8ab76b6..5a7d1a86 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -1,19 +1,19 @@ # Progress.py - progress reporting classes -# +# # Copyright (c) 2005 Canonical -# +# # Author: Michael Vogt -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -69,18 +69,18 @@ class FetchProgress(object): dlFailed : "Failed", dlHit : "Hit", dlIgnored : "Ignored"} - + def __init__(self): self.eta = 0.0 self.percent = 0.0 pass - + def start(self): pass - + def stop(self): pass - + def updateStatus(self, uri, descr, shortDescr, status): pass @@ -115,7 +115,7 @@ class TextFetchProgress(FetchProgress): sys.stdout.flush() return True def stop(self): - print "\rDone downloading " + print "\rDone downloading " def mediaChange(self, medium, drive): """ react to media change events """ res = True; @@ -144,7 +144,7 @@ class DumbInstallProgress(object): class InstallProgress(DumbInstallProgress): """ A InstallProgress that is pretty useful. It supports the attributes 'percent' 'status' and callbacks - for the dpkg errors and conffiles and status changes + for the dpkg errors and conffiles and status changes """ def __init__(self): DumbInstallProgress.__init__(self) diff --git a/aptsources/__init__.py b/aptsources/__init__.py index d6b3605c..ddec2bd9 100644 --- a/aptsources/__init__.py +++ b/aptsources/__init__.py @@ -1,5 +1,5 @@ import apt_pkg - + # init the package system apt_pkg.init() diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index a6c0faf8..42395bc5 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# +# # distinfo.py - provide meta information for distro repositories # # Copyright (c) 2005 Gustavo Noronha Silva @@ -7,17 +7,17 @@ # # Author: Gustavo Noronha Silva # Sebastian Heinlein -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -55,7 +55,7 @@ class Template: def has_component(self, comp): ''' Check if the distribution provides the given component ''' return comp in map(lambda c: c.name, self.components) - + def is_mirror(self, url): ''' Check if a given url of a repository is a valid mirror ''' proto, hostname, dir = split_url(url) @@ -190,7 +190,7 @@ class DistInfo: template.match_uri = value elif field == 'MatchURI-%s' % self.arch: template.match_uri = value - elif (field == 'MirrorsFile' or + elif (field == 'MirrorsFile' or field == 'MirrorsFile-%s' % self.arch): if not map_mirror_sets.has_key(value): mirror_set = {} @@ -243,7 +243,7 @@ class DistInfo: if component and not template.has_component(component.name): template.components.append(component) component = None - self.templates.append(template) + self.templates.append(template) if __name__ == "__main__": @@ -257,8 +257,8 @@ if __name__ == "__main__": if template.mirror_set != {}: print "Mirrors: %s" % template.mirror_set.keys() for comp in template.components: - print " %s -%s -%s" % (comp.name, - comp.description, + print " %s -%s -%s" % (comp.name, + comp.description, comp.description_long) for child in template.children: print " %s" % child.description diff --git a/aptsources/distro.py b/aptsources/distro.py index f271bbc4..a94d88ef 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -2,20 +2,20 @@ # # Copyright (c) 2004-2007 Canonical Ltd. # 2006-2007 Sebastian Heinlein -# +# # Authors: Sebastian Heinlein # Michael Vogt -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -48,8 +48,8 @@ class Distribution: def get_sources(self, sourceslist): """ - Find the corresponding template, main and child sources - for the distribution + Find the corresponding template, main and child sources + for the distribution """ self.sourceslist = sourceslist @@ -132,7 +132,7 @@ class Distribution: self.used_media = set(media) self.get_mirrors() - + def get_mirrors(self, mirror_template=None): """ Provide a set of mirrors where you can get the distribution from @@ -203,34 +203,34 @@ class Distribution: '''Helper function that handles comaprision of mirror urls that could contain trailing slashes''' return re.match(mir1.strip("/ "), mir2.rstrip("/ ")) - + # Store all available servers: # Name, URI, active mirrors = [] if len(self.used_servers) < 1 or \ (len(self.used_servers) == 1 and \ compare_mirrors(self.used_servers[0], self.main_server)): - mirrors.append([_("Main server"), self.main_server, True]) - mirrors.append([self._get_mirror_name(self.nearest_server), + mirrors.append([_("Main server"), self.main_server, True]) + mirrors.append([self._get_mirror_name(self.nearest_server), self.nearest_server, False]) elif len(self.used_servers) == 1 and not \ compare_mirrors(self.used_servers[0], self.main_server): - mirrors.append([_("Main server"), self.main_server, False]) + mirrors.append([_("Main server"), self.main_server, False]) # Only one server is used server = self.used_servers[0] - # Append the nearest server if it's not already used + # Append the nearest server if it's not already used if not compare_mirrors(server, self.nearest_server): - mirrors.append([self._get_mirror_name(self.nearest_server), + mirrors.append([self._get_mirror_name(self.nearest_server), self.nearest_server, False]) mirrors.append([self._get_mirror_name(server), server, True]) elif len(self.used_servers) > 1: # More than one server is used. Since we don't handle this case - # in the user interface we set "custom servers" to true and - # append a list of all used servers + # in the user interface we set "custom servers" to true and + # append a list of all used servers mirrors.append([_("Main server"), self.main_server, False]) - mirrors.append([self._get_mirror_name(self.nearest_server), + mirrors.append([self._get_mirror_name(self.nearest_server), self.nearest_server, False]) mirrors.append([_("Custom servers"), None, True]) for server in self.used_servers: @@ -242,7 +242,7 @@ class Distribution: return mirrors - def add_source(self, type=None, + def add_source(self, type=None, uri=None, dist=None, comps=None, comment=""): """ Add distribution specific sources @@ -297,7 +297,7 @@ class Distribution: comps_per_dist = {} comps_per_sdist = {} for s in sources: - if s.type == self.binary_type: + if s.type == self.binary_type: if not comps_per_dist.has_key(s.dist): comps_per_dist[s.dist] = set() map(comps_per_dist[s.dist].add, s.comps) @@ -339,9 +339,9 @@ class Distribution: sources = [] sources.extend(self.main_sources) for source in sources: - if comp in source.comps: + if comp in source.comps: source.comps.remove(comp) - if len(source.comps) < 1: + if len(source.comps) < 1: self.sourceslist.remove(source) def change_server(self, uri): @@ -415,10 +415,10 @@ class UbuntuDistribution(Distribution): mirror_template="http://%s.archive.ubuntu.com/ubuntu/") def get_distro(id=None,codename=None,description=None,release=None): - """ + """ Check the currently used distribution and return the corresponding - distriubtion class that supports distro specific features. - + distriubtion class that supports distro specific features. + If no paramter are given the distro will be auto detected via a call to lsb-release """ @@ -431,7 +431,7 @@ def get_distro(id=None,codename=None,description=None,release=None): del pipe (id, codename, description, release) = lsb_info if id == "Ubuntu": - return UbuntuDistribution(id, codename, description, + return UbuntuDistribution(id, codename, description, release) elif id == "Debian": return DebianDistribution(id, codename, description, release) diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index e0f32f8d..4067920a 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -1,28 +1,28 @@ # aptsource.py - Provide an abstraction of the sources.list -# +# # Copyright (c) 2004-2007 Canonical Ltd. # 2004 Michiel Sikkes # 2006-2007 Sebastian Heinlein -# +# # Author: Michiel Sikkes # Michael Vogt # Sebastian Heinlein -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA - + import string import gettext import re @@ -81,14 +81,14 @@ class SourceEntry: self.comps = [] # list of available componetns (may empty) self.comment = "" # (optional) comment self.line = line # the original sources.list line - if file == None: + if file == None: file = apt_pkg.Config.FindDir("Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist") self.file = file # the file that the entry is located in self.parse(line) self.template = None # type DistInfo.Suite self.children = [] - def __eq__(self, other): + def __eq__(self, other): """ equal operator for two sources.list entries """ return (self.disabled == other.disabled and self.type == other.type and @@ -138,7 +138,7 @@ class SourceEntry: if line[0] == "#": self.disabled = True pieces = string.split(line[1:]) - # if it looks not like a disabled deb line return + # if it looks not like a disabled deb line return if not pieces[0] in ("rpm", "rpm-src", "deb", "deb-src"): self.invalid = True return @@ -185,7 +185,7 @@ class SourceEntry: i += 1 self.line = self.line[i:] else: - # disabled, add a "#" + # disabled, add a "#" if string.strip(self.line)[0] != "#": self.line = "#" + self.line @@ -207,7 +207,7 @@ class SourceEntry: line += " #"+self.comment line += "\n" return line - + class NullMatcher(object): """ a Matcher that does nothing """ def match(self, s): @@ -218,7 +218,7 @@ class SourcesList: def __init__(self, withMatcher=True, matcherPath="/usr/share/python-apt/templates/"): - self.list = [] # the actual SourceEntries Type + self.list = [] # the actual SourceEntries Type if withMatcher: self.matcher = SourceEntryMatcher(matcherPath) else: @@ -251,7 +251,7 @@ class SourcesList: def add(self, type, uri, dist, orig_comps, comment="", pos=-1, file=None): """ Add a new source to the sources.list. - The method will search for existing matching repos and will try to + The method will search for existing matching repos and will try to reuse them as far as possible """ # create a working copy of the component list so that @@ -367,7 +367,7 @@ class SourcesList: # try to avoid checking uninterressting sources if source.template == None: continue - # set up a dict with all used child templates and corresponding + # set up a dict with all used child templates and corresponding # source entries if source.template.child == True: key = source.template @@ -405,12 +405,12 @@ class SourceEntryMatcher: _ = gettext.gettext found = False for template in self.templates: - if (re.search(template.match_uri, source.uri) and + if (re.search(template.match_uri, source.uri) and re.match(template.match_name, source.dist)): found = True source.template = template break - elif (template.is_mirror(source.uri) and + elif (template.is_mirror(source.uri) and re.match(template.match_name, source.dist)): found = True source.template = template @@ -430,7 +430,7 @@ if __name__ == "__main__": mirror = is_mirror("http://archive.ubuntu.com/ubuntu/", "http://de.archive.ubuntu.com/ubuntu/") print "is_mirror(): %s" % mirror - + print is_mirror("http://archive.ubuntu.com/ubuntu", "http://de.archive.ubuntu.com/ubuntu/") print is_mirror("http://archive.ubuntu.com/ubuntu/", diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index eef6c1f7..939c33a2 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -27,7 +27,7 @@ recs = apt_pkg.GetPkgRecords(cache) list = apt_pkg.GetPkgSourceList() list.ReadMainList() -# show the amount fetch needed for a dist-upgrade +# show the amount fetch needed for a dist-upgrade depcache.Upgrade(True) progress = apt.progress.TextFetchProgress() fetcher = apt_pkg.GetAcquire(progress) @@ -67,7 +67,7 @@ for item in fetcher.Items: if item.Complete == False: print "No error, still nothing downloaded (%s)" % item.ErrorText print - + res = fetcher.Run() print "fetcher.Run() returned: %s" % res diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index 65e35f3d..81a8b408 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -3,7 +3,7 @@ import apt_pkg import sys -import sets # only needed for python2.3, python2.4 supports this naively +import sets # only needed for python2.3, python2.4 supports this naively def get_source_pkg(pkg, records, depcache): """ get the source package name of a given package """ diff --git a/doc/examples/deb_inspect.py b/doc/examples/deb_inspect.py index 0befd2bb..b57526c6 100755 --- a/doc/examples/deb_inspect.py +++ b/doc/examples/deb_inspect.py @@ -8,7 +8,7 @@ import os.path def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): """ callback for debExtract """ - + print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\ % (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor); diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index feefd6ed..9a3b007f 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -23,7 +23,7 @@ if __name__ == "__main__": win.add(progress) progress.show() win.show() - + cache = apt.cache.Cache(progress.open) if cache["2vcard"].isInstalled: cache["2vcard"].markDelete() diff --git a/doc/examples/progress.py b/doc/examples/progress.py index 2723c382..b90253cb 100644 --- a/doc/examples/progress.py +++ b/doc/examples/progress.py @@ -23,13 +23,13 @@ class TextProgress(apt.OpProgress): class TextFetchProgress(apt.FetchProgress): def __init__(self): pass - + def start(self): pass - + def stop(self): pass - + def updateStatus(self, uri, descr, shortDescr, status): print "UpdateStatus: '%s' '%s' '%s' '%i'" % (uri,descr,shortDescr, status) def pulse(self): diff --git a/doc/examples/recommends.py b/doc/examples/recommends.py index b1094aee..c1a7eb2e 100755 --- a/doc/examples/recommends.py +++ b/doc/examples/recommends.py @@ -19,7 +19,7 @@ for package in cache.Packages: if not current: continue depends = current.DependsList - for (key, attr) in (('Suggests', 'suggested'), + for (key, attr) in (('Suggests', 'suggested'), ('Recommends', 'recommended')): list = depends.get(key, []) for dependency in list: diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py index 95f887f2..c4e5f44d 100755 --- a/doc/examples/versiontest.py +++ b/doc/examples/versiontest.py @@ -10,7 +10,7 @@ if len(TestFile) != 1: print "Must have exactly 1 file name"; sys.exit(0); -# Go over the file.. +# Go over the file.. List = open(TestFile[0],"r"); CurLine = 0; while(1): @@ -21,10 +21,10 @@ while(1): Line = string.strip(Line); if len(Line) == 0 or Line[0] == '#': continue; - + Split = re.split("[ \n]",Line); - # Check forward + # Check forward if apt_pkg.VersionCompare(Split[0],Split[1]) != int(Split[2]): print "Comparision failed on line %u. '%s' ? '%s' %i != %i"%(CurLine, Split[0],Split[1],apt_pkg.VersionCompare(Split[0],Split[1]), diff --git a/setup.py b/setup.py index 7024f81e..bdb59ff2 100755 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ for template in glob.glob('data/templates/*.info.in'): if sys.argv[1] == "build": build_docs() -setup(name="python-apt", +setup(name="python-apt", version="0.6.17", description="Python bindings for APT", author="APT Development Team", diff --git a/tests/cache.py b/tests/cache.py index 47d9a3b4..afcad00d 100644 --- a/tests/cache.py +++ b/tests/cache.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2.4 # # Test for the pkgCache code -# +# import apt_pkg import sys @@ -26,7 +26,7 @@ def main(): c = ver.Arch d = ver.DependsListStr dl = ver.DependsList - # get all dependencies (a dict of string->list, + # get all dependencies (a dict of string->list, # e.g. "depends:" -> [ver1,ver2,..] for dep in dl.keys(): # get the list of each dependency object diff --git a/tests/depcache.py b/tests/depcache.py index f4821b4f..5c78c3a1 100644 --- a/tests/depcache.py +++ b/tests/depcache.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2.4 # # Test for the DepCache code -# +# import apt_pkg import sys diff --git a/tests/lock.py b/tests/lock.py index 5d2697f1..86d704ea 100644 --- a/tests/lock.py +++ b/tests/lock.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2.4 # # Test for the pkgCache code -# +# import apt_pkg import sys, os @@ -9,7 +9,7 @@ import sys, os if __name__ == "__main__": lock = "/tmp/test.lck" - + apt_pkg.init() # system-lock @@ -44,4 +44,4 @@ if __name__ == "__main__": fd = apt_pkg.GetLock(lock,True) print "Lockfile fd (child): %s" % fd sys.exit(0) - + diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py index 27747e43..0ed32ea6 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/pkgproblemresolver.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2.4 # # Test for the DepCache code -# +# import apt_pkg import sys @@ -29,7 +29,7 @@ def main(): fixer.Protect(pkg) # we first try to resolve the problem # with the package that should be installed - # protected + # protected try: fixer.Resolve(True) except SystemError: diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py index d0616d29..43723569 100644 --- a/tests/pkgrecords.py +++ b/tests/pkgrecords.py @@ -2,7 +2,7 @@ # # Test for the PkgSrcRecords code # it segfaults for python-apt < 0.5.37 -# +# import apt_pkg import sys diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py index 28df3f7c..06c4a1ef 100644 --- a/tests/pkgsrcrecords.py +++ b/tests/pkgsrcrecords.py @@ -2,7 +2,7 @@ # # Test for the PkgSrcRecords code # it segfaults for python-apt < 0.5.37 -# +# import apt_pkg import sys diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 49fe6afa..c8d84395 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -60,7 +60,7 @@ class TestAptSources(unittest.TestCase): "multiverse" in entry.comps): found = True self.assertTrue(found) - # test to add something new: multiverse *and* + # test to add something new: multiverse *and* # something that is already there before = copy.deepcopy(sources) sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", @@ -105,7 +105,7 @@ class TestAptSources(unittest.TestCase): #print dist_templates for d in ["hardy","hardy-security","hardy-updates","intrepid","hardy-backports"]: self.assertTrue(d in dist_templates) - # test enable + # test enable comp = "restricted" distro.enable_component(comp) found = {} diff --git a/tests/test_debextract.py b/tests/test_debextract.py index 53241e92..c080b26e 100755 --- a/tests/test_debextract.py +++ b/tests/test_debextract.py @@ -7,7 +7,7 @@ def Callback(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) -member = "data.tar.lzma" +member = "data.tar.lzma" if len(sys.argv) > 2: member = sys.argv[2] apt_inst.debExtract(open(sys.argv[1]), Callback, member) diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py index ccddf8ed..512731ed 100755 --- a/utils/get_debian_mirrors.py +++ b/utils/get_debian_mirrors.py @@ -2,23 +2,23 @@ # # get_debian_mirrors.py # -# Download the latest list with available mirrors from the Debian +# Download the latest list with available mirrors from the Debian # website and extract the hosts from the raw page # # Copyright (c) 2006 Free Software Foundation Europe # # Author: Sebastian Heinlein -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/utils/get_ubuntu_mirrors.py b/utils/get_ubuntu_mirrors.py index 62b18ba6..605edcf5 100755 --- a/utils/get_ubuntu_mirrors.py +++ b/utils/get_ubuntu_mirrors.py @@ -8,17 +8,17 @@ # Copyright (c) 2006 Free Software Foundation Europe # # Author: Sebastian Heinlein -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index 7d9116f2..1f41e34b 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -8,17 +8,17 @@ # Copyright (c) 2006 Free Software Foundation Europe # # Author: Sebastian Heinlein -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as +# +# 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -- cgit v1.2.3 From 6a806f0570599e8f5e9438c9623d496df75571d4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 9 Jan 2009 21:52:07 +0100 Subject: * Introduce the new documentation and add 0.7.9~exp2 to changelog. The new documentation is built using sphinx (>= 0.5) [other versions may work too, but let's be safe]. --- debian/changelog | 26 ++++ debian/control | 4 +- debian/examples | 1 + debian/python-apt.docs | 2 +- doc/Makefile | 75 +++++++++++ doc/makefile | 13 -- doc/source/apt/cache.rst | 70 ++++++++++ doc/source/apt/cdrom.rst | 7 + doc/source/apt/debfile.rst | 37 ++++++ doc/source/apt/gtk.widgets.rst | 29 +++++ doc/source/apt/index.rst | 58 +++++++++ doc/source/apt/package.rst | 101 ++++++++++++++ doc/source/apt/progress.rst | 37 ++++++ doc/source/apt_inst.rst | 100 ++++++++++++++ doc/source/apt_pkg/cache.rst | 95 ++++++++++++++ doc/source/apt_pkg/index.rst | 239 ++++++++++++++++++++++++++++++++++ doc/source/aptsources/distinfo.rst | 10 ++ doc/source/aptsources/distro.rst | 10 ++ doc/source/aptsources/index.rst | 10 ++ doc/source/aptsources/sourceslist.rst | 10 ++ doc/source/coding.rst | 149 +++++++++++++++++++++ doc/source/conf.py | 192 +++++++++++++++++++++++++++ doc/source/examples/apt-gtk.py | 29 +++++ doc/source/examples/dpkg-contents.py | 55 ++++++++ doc/source/examples/dpkg-extract.py | 25 ++++ doc/source/examples/dpkg-info.py | 20 +++ doc/source/index.rst | 38 ++++++ po/python-apt.pot | 12 +- setup.py | 51 ++++---- 29 files changed, 1453 insertions(+), 52 deletions(-) create mode 100644 doc/Makefile delete mode 100644 doc/makefile create mode 100644 doc/source/apt/cache.rst create mode 100644 doc/source/apt/cdrom.rst create mode 100644 doc/source/apt/debfile.rst create mode 100644 doc/source/apt/gtk.widgets.rst create mode 100644 doc/source/apt/index.rst create mode 100644 doc/source/apt/package.rst create mode 100644 doc/source/apt/progress.rst create mode 100644 doc/source/apt_inst.rst create mode 100644 doc/source/apt_pkg/cache.rst create mode 100644 doc/source/apt_pkg/index.rst create mode 100644 doc/source/aptsources/distinfo.rst create mode 100644 doc/source/aptsources/distro.rst create mode 100644 doc/source/aptsources/index.rst create mode 100644 doc/source/aptsources/sourceslist.rst create mode 100644 doc/source/coding.rst create mode 100644 doc/source/conf.py create mode 100644 doc/source/examples/apt-gtk.py create mode 100644 doc/source/examples/dpkg-contents.py create mode 100644 doc/source/examples/dpkg-extract.py create mode 100644 doc/source/examples/dpkg-info.py create mode 100644 doc/source/index.rst (limited to 'setup.py') diff --git a/debian/changelog b/debian/changelog index a80a9b64..1002bead 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,29 @@ +python-apt (0.7.9~exp2) experimental; urgency=low + + * apt/*.py: + - Almost complete cleanup of the code + - Improved documentation + * apt/debfile.py: + - Drop get*() methods, as they are deprecated and were + never in a stable release + - Make DscSrcPackage working + * apt/gtk/widgets.py: + - Fix the code and document the signals + * Introduce new documentation build with Sphinx + - debian/rules: Build the documentation here + - setup.py: Remove pydoc building and add new docs. + - debian/examples: Include examples from documentation + - debian/python-apt.docs: Change html/ to doc/build/html. + * setup.py: + - Only create build/data when building, not all the time + - Remove build/mo and build/data on clean -a + * debian/control: + - Remove the Conflicts on python2.3-apt, python2.4-apt, as + they are only needed for oldstable (sarge) + - Build-Depend on python-sphinx (>= 0.5) + + -- Julian Andres Klode Fri, 09 Jan 2009 17:20:41 +0100 + python-apt (0.7.9~exp1) experimental; urgency=low * Merged python-apt consolidation branch by Sebastian diff --git a/debian/control b/debian/control index b738231f..8a10091d 100644 --- a/debian/control +++ b/debian/control @@ -5,15 +5,13 @@ Maintainer: APT Development Team Uploaders: Matt Zimmerman , Michael Vogt Standards-Version: 3.7.2.2 XS-Python-Version: all -Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.7.10), apt-utils, python-all-dev, python-distutils-extra (>= 1.9.0), cdbs, python-central (>= 0.5), python-all-dbg +Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.7.10), apt-utils, python-all-dev, python-distutils-extra (>= 1.9.0), cdbs, python-central (>= 0.5), python-all-dbg, python-sphinx (>= 0.5) Vcs-Bzr: http://bzr.debian.org/apt/python-apt/debian-sid Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release Priority: optional -Replaces: python2.3-apt (<< 0.6.18), python2.4-apt (<< 0.6.18) -Conflicts: python2.3-apt (<< 0.6.18), python2.4-apt (<< 0.6.18) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte XB-Python-Version: ${python:Versions} diff --git a/debian/examples b/debian/examples index 80a386c8..e4a93ea1 100644 --- a/debian/examples +++ b/debian/examples @@ -1 +1,2 @@ doc/examples/*.py +doc/source/examples/*.py diff --git a/debian/python-apt.docs b/debian/python-apt.docs index f3c87fdc..ff53abec 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -1,4 +1,4 @@ README apt/README.apt data/templates/README.templates -html/ +doc/build/html/ diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..39fe377f --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,75 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html web pickle htmlhelp latex changes linkcheck + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview over all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + +clean: + -rm -rf build/* + +html: + mkdir -p build/html build/doctrees + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html + @echo + @echo "Build finished. The HTML pages are in build/html." + +pickle: + mkdir -p build/pickle build/doctrees + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +web: pickle + +json: + mkdir -p build/json build/doctrees + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + mkdir -p build/htmlhelp build/doctrees + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in build/htmlhelp." + +latex: + mkdir -p build/latex build/doctrees + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex + @echo + @echo "Build finished; the LaTeX files are in build/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + mkdir -p build/changes build/doctrees + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes + @echo + @echo "The overview file is in build/changes." + +linkcheck: + mkdir -p build/linkcheck build/doctrees + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in build/linkcheck/output.txt." diff --git a/doc/makefile b/doc/makefile deleted file mode 100644 index 7f9dff2b..00000000 --- a/doc/makefile +++ /dev/null @@ -1,13 +0,0 @@ -# -*- make -*- -BASE=.. -SUBDIR=doc - -# Bring in the default rules -include ../buildlib/defaults.mak - -# Examples -SOURCE = examples/config.py examples/configisc.py examples/tagfile.py \ - examples/versiontest.py examples/checkstate.py \ - examples/recommends.py -TO = $(DOC) -include $(COPY_H) diff --git a/doc/source/apt/cache.rst b/doc/source/apt/cache.rst new file mode 100644 index 00000000..f3ba7d52 --- /dev/null +++ b/doc/source/apt/cache.rst @@ -0,0 +1,70 @@ +:mod:`apt.cache` --- The Cache class +===================================== +.. automodule:: apt.cache + +The Cache class +--------------- + +.. autoclass:: Cache + :members: + +Example +^^^^^^^ + +The following example shows how to load the cache, update it, and upgrade +all the packages on the system. + +.. code-block:: python + + import apt + import apt.progress + + # First of all, open the cache + cache = apt.Cache() + # Now, lets update the package list + cache.update() + # We need to re-open the cache because it needs to read the package list + cache.open(None) + # Now we can do the same as 'apt-get upgrade' does + cache.upgrade() + # or we can play 'apt-get dist-upgrade' + cache.upgrade(True) + # Q: Why does nothing happen? + # A: You forgot to call commit()! + cache.commit(apt.progress.TextFetchProgress(), + apt.progress.InstallProgress()) + + + +Working with Filters +-------------------- +.. autoclass:: Filter + :members: + +.. autoclass:: MarkedChangesFilter + :members: + +.. autoclass:: FilteredCache + :members: + + +Example +^^^^^^^ + +This is an example for a filtered cache, which only allows access to the +packages whose state has been changed, eg. packages marked for installation:: + + >>> from apt.cache import FilteredCache, Cache, MarkedChangesFilter + >>> cache = apt.Cache() + >>> changed = apt.FilteredCache(cache) + >>> changed.setFilter(MarkedChangesFilter()) + >>> print len(changed) == len(cache.GetChanges()) # Both need to have same length + True + + +Exceptions +---------- +.. autoexception:: FetchCancelledException + :members: +.. autoexception:: FetchFailedException +.. autoexception:: LockFailedException diff --git a/doc/source/apt/cdrom.rst b/doc/source/apt/cdrom.rst new file mode 100644 index 00000000..56381f14 --- /dev/null +++ b/doc/source/apt/cdrom.rst @@ -0,0 +1,7 @@ +:mod:`apt.cdrom` - Functionality like in apt-cdrom +==================================================== +.. automodule:: apt.cdrom + :members: + + + diff --git a/doc/source/apt/debfile.rst b/doc/source/apt/debfile.rst new file mode 100644 index 00000000..70c39087 --- /dev/null +++ b/doc/source/apt/debfile.rst @@ -0,0 +1,37 @@ +:mod:`apt.debfile` --- Classes related to debian package files +============================================================== +The :mod:`apt.debfile` provides classes to work with locally available +debian packages, or source packages. + +.. module:: apt.debfile + +Binary packages +---------------- +.. autoclass:: DebPackage + :members: + :inherited-members: + :undoc-members: + + The :class:`DebPackage` class is a class for working with '.deb' files, + also known as Debian packages. + + It provides methods and attributes to get a list of the files in the + package, to install the package and much more. + + If you specify ``cache`` it has to point to an :class:`apt.cache.Cache()` + object. + + All methods except for :meth:`open()` and the attribute :attr:`filelist` have been + introduced in version 0.7.9. + +Source packages +---------------- +.. autoclass:: DscSrcPackage + :members: + :inherited-members: + :undoc-members: + + Provide functionality to work with locally available source packages, + especially with their '.dsc' file. + + .. versionadded:: 0.7.9 diff --git a/doc/source/apt/gtk.widgets.rst b/doc/source/apt/gtk.widgets.rst new file mode 100644 index 00000000..9fa84ead --- /dev/null +++ b/doc/source/apt/gtk.widgets.rst @@ -0,0 +1,29 @@ +:mod:`apt.gtk.widgets` --- GTK widgets +====================================== +.. automodule:: apt.gtk.widgets + + +GObject progress classes +------------------------- + +.. autoclass:: GDpkgInstallProgress + :members: + +.. autoclass:: GFetchProgress + :members: + +.. autoclass:: GInstallProgress + :members: + +.. autoclass:: GOpProgress + :members: + +GTK+ Class +---------- +.. autoclass:: GtkAptProgress + :members: + + +Example +------- +.. literalinclude:: ../examples/apt-gtk.py diff --git a/doc/source/apt/index.rst b/doc/source/apt/index.rst new file mode 100644 index 00000000..5047a0fd --- /dev/null +++ b/doc/source/apt/index.rst @@ -0,0 +1,58 @@ +:mod:`apt` --- Highlevel apt package +===================================== +The highlevel apt package provides a lot of functionality, all +with an easy-to-use interface. + +.. warning:: + The API of this package is not considered stable. Evenmore, it is considered + to change the naming conventions in future to lowercase_with_underscores. + + In case this happens, the API will still be kept compatible, with the old + functions provided as deprecated ones. + +.. automodule:: apt + :members: + + + + +.. toctree:: + :maxdepth: 2 + :glob: + + * + + +Classes exported in apt +------------------------ +These classes are defined in the submodules, but are also exported directly +in the package. + +.. class:: Cache + + Please see :class:`apt.cache.Cache` for documentation. + +.. class:: Cdrom + + Please see :class:`apt.cdrom.Cdrom` for documentation. + +.. class:: CdromProgress + + Please see :class:`apt.progress.CdromProgress` for documentation. + +.. class:: FetchProgress + + Please see :class:`apt.progress.FetchProgress` for documentation. + +.. class:: InstallProgress + + Please see :class:`apt.progress.InstallProgress` for documentation. + +.. class:: OpProgress + + Please see :class:`apt.progress.OpProgress` for documentation. + +.. class:: Package + + Please see :class:`apt.package.Package` for documentation. + diff --git a/doc/source/apt/package.rst b/doc/source/apt/package.rst new file mode 100644 index 00000000..1bd032ab --- /dev/null +++ b/doc/source/apt/package.rst @@ -0,0 +1,101 @@ +:mod:`apt.package` --- Classes for package handling +==================================================== + + +.. automodule:: apt.package + + +The Package class +----------------- +.. autoclass:: Package + :members: + + +Dependency Information +---------------------- +.. class:: BaseDependency + + The :class:`BaseDependency` class defines various attributes for accessing + the parts of a dependency. The attributes are as follows: + + .. attribute:: name + + The name of the dependency + + .. attribute:: relation + + The relation (>>,>=,==,<<,<=,) + + .. attribute:: version + + The version or None. + + .. attribute:: preDepend + + Boolean value whether this is a pre-dependency. + +.. class:: Dependency + + The dependency class represents a Or-Group of dependencies. It provides + an attribute to access the :class:`BaseDependency` object for the available + choices. + + .. attribute:: or_dependencies + + A list of :class:`BaseDependency` objects which could satisfy the + requirement of the Or-Group. + + +Origin Information +------------------- +.. class:: Origin + + The :class:`Origin` class provides access to the origin of the package. + It allows you to check the component, archive, the hostname, and even if + this package can be trusted. + + .. attribute:: archive + + The archive (eg. unstable) + + .. attribute:: component + + The component (eg. main) + + .. attribute:: label + + The Label, as set in the Release file + + .. attribute:: origin + + The Origin, as set in the Release file + + .. attribute:: site + + The hostname of the site. + + .. attribute:: trusted + + Boolean value whether this is trustworthy. An origin can be trusted, if + it provides a GPG-signed Release file and the GPG-key used is in the + keyring used by apt (see apt-key). + +Examples +--------- +.. code-block:: python + + import apt + + cache = apt.Cache() + pkg = cache['python-apt'] # Access the Package object for python-apt + print 'python-apt is trusted:', pkg.candidateOrigin.trusted + + # Mark python-apt for install + pkg.markInstall() + + print 'python-apt is marked for install:', pkg.markedInstall + + print 'python-apt is', pkg.summary #Python interface to libapt-pkg + + # Now, really install it + cache.commit() diff --git a/doc/source/apt/progress.rst b/doc/source/apt/progress.rst new file mode 100644 index 00000000..8989aa27 --- /dev/null +++ b/doc/source/apt/progress.rst @@ -0,0 +1,37 @@ +:mod:`apt.progress` --- Classes for progress reporting +====================================================== +.. automodule:: apt.progress + +.. warning:: + + This class is currently under re-organisation. Therefore, the API may + change soon. The old names will still be kept until it is safe to remove + them. + + + +Classes without output +---------------------- +.. autoclass:: FetchProgress + :members: +.. autoclass:: OpProgress + :members: +.. autoclass:: CdromProgress + :members: +.. autoclass:: DumbInstallProgress + :members: + +Implementing classes for text output +------------------------------------ +.. autoclass:: TextFetchProgress + :members: +.. autoclass:: OpTextProgress + :members: +.. autoclass:: InstallProgress + :members: +.. autoclass:: DpkgInstallProgress + :members: + + + + diff --git a/doc/source/apt_inst.rst b/doc/source/apt_inst.rst new file mode 100644 index 00000000..b405b9f4 --- /dev/null +++ b/doc/source/apt_inst.rst @@ -0,0 +1,100 @@ +:mod:`apt_inst` - Working with local Debian packages +==================================================== +.. module:: apt_inst + +The :mod:`apt_inst` extension provides access to functions for working with +locally available Debian packages (.deb files) and tar files. + + +Checking packages +------------------ +.. function:: arCheckMember(file, membername) + + Check if the member specified by the parameter ``membername`` exists in + the AR file referenced by the :class:`file` object ``file``. + + +Listing contents +----------------- +.. function:: debExtract(file, func, chunk) + + Call the function referenced by ``func`` for each member of the tar file + ``chunk`` which is contained in the AR file referenced by the file object + ``file``. + + An example would be: + + .. code-block:: python + + debExtract(open("package.deb"), my_callback, "data.tar.gz") + + See :ref:`emulating-dpkg-contents` for a more detailed example. + +.. function:: tarExtract(file,func,comp) + + Call the function ``func`` for each member of the tar file ``file``. + + ``Comp`` is a string determining the compressor used. Possible options are + "lzma", "bzip2" and "gzip". + + +Callback +^^^^^^^^^ +Both of these functions expect a callback with the signature +``(what, name, link, mode, uid, gid, size, mtime, major, minor)``. + +The parameter ``what`` describes the type of the member. It can be ``FILE``, +``DIR``, or ``HARDLINK``. + +The parameter ``name`` refers to the name of the member. In case of links, +``link`` refers to the target of the link. + + +Extracting contents +------------------- + +.. function:: debExtractArchive(file, rootdir) + + Extract the archive referenced by the :class:`file` object ``file`` + into the directory specified by ``rootdir``. + + See :ref:`emulating-dpkg-extract` for an example. + + .. warning:: + + If the directory given by ``rootdir`` does not exist, the package is + extracted into the current directory. + +.. function:: debExtractControl(file[, member='control']) + + Return the indicated file from the control tar. The default is 'control'. + + If you want to print the control file of a given package, you could do + something like: + + .. code-block:: python + + print debExtractControl(open("package.deb")) + + :return: The contents of the file, as :class:`str`. + + +.. _emulating-dpkg-extract: + +Example: Emulating :program:`dpkg` :option:`--extract` +------------------------------------------------------- +Here is a code snippet which emulates dpkg -x. It can be run as +``tool pkg.deb outdir``. + +.. literalinclude:: examples/dpkg-extract.py + + +.. _emulating-dpkg-contents: + +Example: Emulating :program:`dpkg` :option:`--contents` +------------------------------------------------------- +.. literalinclude:: examples/dpkg-contents.py + +Example: Emulating :program:`dpkg` :option:`--info` +---------------------------------------------------- +.. literalinclude:: examples/dpkg-info.py diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst new file mode 100644 index 00000000..abb0fab2 --- /dev/null +++ b/doc/source/apt_pkg/cache.rst @@ -0,0 +1,95 @@ +Low-Level Cache Handling +=========================== + +.. class:: Acquire + + .. method:: Run() + + Fetch all the items which have been added by + :func:`apt_pkg.GetPkgAcqFile`. + + .. method:: Shutdown + + Shut the fetcher down. + +.. class:: pkgCache + + The :class:`pkgCache` class prov + + .. method:: Close() + + Close the package cache. + + .. method:: Open([progress]) + + Open the package cache again. The parameter ``progress`` may be set to + an :class:`apt.progress.OpProgress()` object or `None`. + + .. method:: Update(progress, list) + + Update the package cache. + + The parameter ``progress`` points to an :class:`apt.progress.FetchProgress()` + object. + + The parameter ``list`` refers to an object as returned by + :func:`apt_pkg.GetPkgSourceList`. + + .. method:: __getitem__(item) + + Return an :class:`pkgCachePackage` object for the package with the given + name. + +.. class:: pkgCachePackage + + The pkgCache::Package objects are an interface to package specific + features. + + + Attributes: + + .. attribute:: Name + + This is the name of the package. + + .. attribute:: Section + + The section of the package, as specified in the record. The list of + possible sections is defined in the Policy. + + .. attribute:: ID + + The ID of the package. This can be used to store information about + the package. The ID is an int value. + + +Working with dependencies +------------------------- +.. class:: pkgDepCache + + The pkgDepCache object contains various methods to manipulate the cache, + to install packages, to remove them, and much more. + + .. method:: Commit(fprogress, iprogress) + + Apply all the changes made. + + The parameter ``fprogress`` has to be set to an instance of + apt.progress.FetchProgress or one of its subclasses. + + The parameter ``iprogress`` has to be set to an instance of + apt.progress.InstallProgress or one of its subclasses. + + .. method:: FixBroken() + + Try to fix all broken packages in the cache. + + .. method:: GetCandidateVer(pkg) + + Return the candidate version of the package, ie. the version that + would be installed normally. + + The parameter ``pkg`` refers to an :class:`pkgCachePackage` object, + available using the :class:`pkgCache`. + + This method returns a :class:`pkgCacheVersion` object. diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst new file mode 100644 index 00000000..5f23df31 --- /dev/null +++ b/doc/source/apt_pkg/index.rst @@ -0,0 +1,239 @@ +:mod:`apt_pkg` --- The low-level bindings for apt-pkg +===================================================== +.. module:: apt_pkg + +The apt_pkg extensions provides a more low-level way to work with apt. It can +do everything apt can, and is written in C++. It has been in python-apt since +the beginning. + + +.. toctree:: + :maxdepth: 2 + :glob: + + * + + +Module Initialization +--------------------- + + +.. function:: initConfig + + Initialize the configuration of apt. This is needed for most operations. + +.. function:: initSystem + + Initialize the system. + +.. function:: init + + Deprecated function. Use initConfig() and initSystem() instead. + +Object initialization +---------------------- +.. function:: GetCache([progress]) + + Return a :class:`pkgCache` object. The optional parameter ``progress`` + specifies an instance of :class:`apt.progress.OpProgress()` which will + display the open progress. + +.. function:: GetCdrom() + + Return a Cdrom object with the following methods: + + .. method:: Cdrom.Ident(progress) + + Identify the cdrom. The parameter ``progress`` refers to an + :class:`apt.progress.CdromProgress()` object. + + .. method:: Cdrom.Add(progress) + + Add the cdrom to the sources.list file. The parameter ``progress`` + refers to an :class:`apt.progress.CdromProgress()` object. + + + +.. function:: GetDepCache(cache) + + Return a :class:`pkgDepCache` object. The parameter ``cache`` specifies an + instance of :class:`pkgCache` (see :func:`GetCache()`). + + +.. function:: GetPkgSourceList() + + Return a :class:`pkgSourceList` object. + + +The Acquire interface +---------------------- +.. function:: GetAcquire([progress]) + + Return an :class:`Acquire` object. This is a class which allows you + to fetch files, or archive contents. The parameter ``progress`` refers to + an :class:`apt.progress.FetchProgress()` object. + + Acquire items have multiple methods: + + .. method:: Acquire.Run() + + Fetch all the items which have been added by :func:`GetPkgAcqFile`. + + .. method:: Acquire.Shutdown() + + Shut the fetcher down. + +.. function:: GetPkgAcqFile(aquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) + + The parameter ``acquire`` refers to an :class:`Acquire()` object as returned + by :func:`GetAcquire`. The file will be added to the Acquire queue + automatically. + + The parameter ``uri`` refers to the location of the file, any protocol + of apt is supported. + + The parameter ``md5`` refers to the md5sum of the file. This can be used + for checking the file. + + The parameter ``size`` can be used to specify the size of the package, + which can then be used to calculate the progress and validate the download. + + The parameter ``descr`` is a descripition of the download. It may be + used to describe the item in the progress class. ``shortDescr`` is the + short form of it. + + You can use ``destDir`` to manipulate the directory where the file will + be saved in. Together with ``destFile`` you can specify the complete target + path. + + + +Hash functions +-------------- +The apt_pkg module also provides several hash functions. If you develop +applications with python-apt it is often easier to use these functions instead +of the ones provides in Python's :mod:`hashlib` module. + +.. function:: md5sum(object) + + Return the md5sum of the object. ``object`` may either be a string, in + which case the md5sum of the string is returned, or a :class:`file()` + object, in which case the md5sum of its contents is returned. + +.. function:: sha1sum(object) + + Return the sha1sum of the object. ``object`` may either be a string, in + which case the sha1sum of the string is returned, or a :class:`file()` + object, in which case the sha1sum of its contents is returned. + +.. function:: sha256sum(object) + + Return the sha256sum of the object. ``object`` may either be a string, in + which case the sha256sum of the string is returned, or a :class:`file()` + object, in which case the sha256sum of its contents is returned. + +Other functions +---------------- + +.. note:: + + This documentation is created automatically and should be rewritten. + +.. autofunction:: Base64Encode +.. autofunction:: CheckDep +.. autofunction:: CheckDomainList +.. autofunction:: DeQuoteString +.. autofunction:: GetLock +.. autofunction:: GetPackageManager +.. autofunction:: GetPkgActionGroup +.. autofunction:: GetPkgProblemResolver +.. autofunction:: GetPkgRecords +.. autofunction:: GetPkgSrcRecords +.. autofunction:: newConfiguration +.. autofunction:: ParseCommandLine +.. autofunction:: ParseDepends +.. autofunction:: ParseSection +.. autofunction:: ParseSrcDepends +.. autofunction:: ParseTagFile +.. autofunction:: PkgSystemLock +.. autofunction:: PkgSystemUnLock +.. autofunction:: QuoteString +.. autofunction:: ReadConfigFile +.. autofunction:: ReadConfigFileISC +.. autofunction:: RewriteSection +.. autofunction:: SizeToStr +.. autofunction:: StringToBool +.. autofunction:: StrToTime +.. autofunction:: TimeRFC1123 +.. autofunction:: TimeToStr +.. autofunction:: UpstreamVersion +.. autofunction:: URItoFileName +.. autofunction:: VersionCompare + + +Data +----- + +.. data:: Config + + An :class:`Configuration()` object with the default configuration. Actually, + this is a bit different object, but it is compatible. + +.. data:: RewritePackageOrder + +.. data:: RewriteSourceOrder + + +Package States +^^^^^^^^^^^^^^^ +.. data:: CurStateConfigFiles +.. data:: CurStateHalfConfigured +.. data:: CurStateHalfInstalled +.. data:: CurStateInstalled +.. data:: CurStateNotInstalled +.. data:: CurStateUnPacked + + + + +Dependency types +^^^^^^^^^^^^^^^^ +.. data:: DepConflicts +.. data:: DepDepends +.. data:: DepObsoletes +.. data:: DepPreDepends +.. data:: DepRecommends +.. data:: DepReplaces +.. data:: DepSuggests + +Installed states +^^^^^^^^^^^^^^^^^ +.. data:: InstStateHold +.. data:: InstStateHoldReInstReq +.. data:: InstStateOk +.. data:: InstStateReInstReq + + +Priorities +^^^^^^^^^^ +.. data:: PriExtra +.. data:: PriImportant +.. data:: PriOptional +.. data:: PriRequired +.. data:: PriStandard + +Dselect states +^^^^^^^^^^^^^^ +.. data:: SelStateDeInstall +.. data:: SelStateHold +.. data:: SelStateInstall +.. data:: SelStatePurge +.. data:: SelStateUnknown + + +Build information +^^^^^^^^^^^^^^^^^ +.. data:: Date +.. data:: LibVersion +.. data:: Time +.. data:: Version diff --git a/doc/source/aptsources/distinfo.rst b/doc/source/aptsources/distinfo.rst new file mode 100644 index 00000000..96f9445d --- /dev/null +++ b/doc/source/aptsources/distinfo.rst @@ -0,0 +1,10 @@ +:mod:`aptsources.distinfo` --- provide meta information for distro repositories +=============================================================================== + +.. automodule:: aptsources.distinfo + :members: + :undoc-members: + + .. note:: + + This part of the documentation is created automatically. diff --git a/doc/source/aptsources/distro.rst b/doc/source/aptsources/distro.rst new file mode 100644 index 00000000..06ca0fda --- /dev/null +++ b/doc/source/aptsources/distro.rst @@ -0,0 +1,10 @@ +:mod:`aptsources.distro` --- Distribution abstraction of the sources.list +=============================================================================== + +.. automodule:: aptsources.distro + :members: + :undoc-members: + + .. note:: + + This part of the documentation is created automatically. diff --git a/doc/source/aptsources/index.rst b/doc/source/aptsources/index.rst new file mode 100644 index 00000000..898fbf74 --- /dev/null +++ b/doc/source/aptsources/index.rst @@ -0,0 +1,10 @@ +:mod:`aptsources` --- Working with sources.list +===================================================== +.. automodule:: aptsources + +.. toctree:: + :maxdepth: 2 + :glob: + + * + diff --git a/doc/source/aptsources/sourceslist.rst b/doc/source/aptsources/sourceslist.rst new file mode 100644 index 00000000..509db3ce --- /dev/null +++ b/doc/source/aptsources/sourceslist.rst @@ -0,0 +1,10 @@ +:mod:`aptsources.sourceslist` --- Provide an abstraction of the sources.list +============================================================================ + +.. automodule:: aptsources.sourceslist + :members: + :undoc-members: + + .. note:: + + This part of the documentation is created automatically. diff --git a/doc/source/coding.rst b/doc/source/coding.rst new file mode 100644 index 00000000..0a57bd74 --- /dev/null +++ b/doc/source/coding.rst @@ -0,0 +1,149 @@ +Coding for python-apt +====================== +Let's say you need a new feature, you can develop it, and you want to get it +included in python-apt. Then be sure to follow the following guidelines + + +Available branches +------------------- +First of all, let's talk a bit about the bzr branches of python-apt. In the +following parts, we will assume that you use bzr to create your changes and +submit them. + +**mvo:** http://people.ubuntu.com/~mvo/bzr/python-apt/mvo + This is Michael Vogt's branch. Most of the development of apt happens here, + as he is the lead maintainer of python-apt. + + This branch is also available from Launchpads super mirror, via + ``lp:python-apt``. Checkouts from Launchpad are generally faster and can + use the bzr protocoll. + + VCS-Browser: https://code.launchpad.net/~mvo/python-apt/python-apt--mvo + +**debian-sid:** http://bzr.debian.org/apt/python-apt/debian-sid + This is the official Debian branch of python-apt. All code which will be + uploaded to Debian is here. It is not as up-to-date as the mvo branch, + because this branch often gets updated just right before the release + happens. + + VCS-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes + +**ubuntu:** ``lp:~ubuntu-core-dev/python-apt/ubuntu`` + This is the official Ubuntu development branch. The same notes apply as + for the debian-sid branch above. + + VCS-Browser: https://code.launchpad.net/~ubuntu-core-dev/python-apt/ubuntu + + +C++ Coding style +---------------- +When you work on the C++ code in the python/ directory, you should follow some +basic rules. + +The indentation of the code is a bit non-standard. We currently use 3 spaces +indentation for the C++ code. + +When you create new functions, you should follow some naming conventions. All +C++ functions are named according to the ``CamelCase`` convention. + +The resulting Python functions should be ``CamelCase`` as well in apt_pkg, or +``mixedCase`` in apt_inst. The same applies for variables, parameters, +attributes, etc. + +.. note:: + + This coding style guidelines are incomplete. If you have any questions + send an email to deity@lists.debian.org. + +.. note:: + + The coding style may be changed completely during the port to Python 3.0. + But this will not happen very soon. + + +Python Coding Style +------------------- +The coding style for the rest of the code is basically :PEP:`8`, with some exceptions: + +The naming convention is mixedCase for functions, methods, attributes, and +variables. This is considered bad and will be changed in future versions to +lowercase_with_underscores, as stated in :PEP:`8`. + +.. note:: + + You can use the tool pep8.py from http://svn.browsershots.org/trunk/devtools/pep8/ + to validate your code. Please also run pylint, pychecker, and pyflakes and + fix all new errors they report (unresolved names, etc.). + + +Submitting your patch +--------------------- +First of all, the patch you create should be based against the debian-sid +branch of python-apt. + +Once you have made your change, check that it: + + * conforms to :PEP:`8` (checked with pep8.py). It should, at least not + introduce new errors. (and never have whitespace at end of line) + * produces no new errors in pychecker, pyflakes and pylint (unless you + can't fix them, but please tell so when requesting the merge, so it can + be fixed before hitting one of the main branches). + * does not change the behaviour of existing code in a non-compatible way. + +If your change follows all points of the checklist, you can commit it to your +repository. (You could commit it first, and check later, and then commit the +fixes, but commits should be logical and it makes no sense to have to commits +for one logical unit). + +Once you have made all your changes, you can run ``bzr send -o patch-name`` +to create a so called *merge-directive*, which contains your changes and +allows us to preserve the history of your changes. (But please replace patch-name +with something useful). + +Now report a bug against the python-apt package, attach the merge directive +you created in the previous step, and tag it with 'patch'. It might also be +a good idea to prefix the bug report with '[PATCH]'. + +If your patch introduces new functions, parameters, etc. , but does not update +the content of this documentation, please CC. jak@debian.org, and add a short +notice to the bug report. Also see `Documentation updates` + +Once your patch got merged, you can *pull* the branch into which it has been +merged into your local one. If you have made changes since you submitted your +patch, you may need to *merge* the branch instead. + +.. note:: + + If you plan to work on python-apt for a longer time, it may be a good + idea to publish your branch somewhere. Alioth (http://alioth.debian.org) + and Launchpad (https://launchpad.net) provide bzr hosting. You can also + use any webspace with ftp or sftp connection (for the upload). + + +Documentation updates +--------------------- +If you want to update the documentation, please follow the procedure as written +above. But please CC: jak@debian.org in the bug report. + +You can send your content in plain text, but reStructuredText is the preferred +format. I (Julian Andres Klode) will review your patch and will forward them to +Michael Vogt, for inclusion in his branch. On release, this will be merged into +the debian-sid branch. + + +Example patch session +---------------------- +In the following example, we edit a file, create a merge directive (an enhanced +patch), and report a wishlist bug with this patch against the python-apt +package:: + + user@pc:~$ bzr clone http://bzr.debian.org/apt/python-apt/debian-sid/ + user@pc:~$ cd debian-sid + user@pc:~/debian-sid$ editor FILES + user@pc:~/debian-sid$ pep8.py FILES # PEP 8 check, see above. + user@pc:~/debian-sid$ pylint -e FILES # Check with pylint + user@pc:~/debian-sid$ pyflakes FILES # Check with pyflakes + user@pc:~/debian-sid$ pychecker FILES # Check with pychecker + user@pc:~/debian-sid$ bzr commit + user@pc:~/debian-sid$ bzr send -o my-patch + user@pc:~/debian-sid$ reportbug --severity=wishlist --tag=patch --attach=my-patch python-apt diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..4cd444f1 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,192 @@ +# -*- coding: utf-8 -*- +# +# python-apt documentation build configuration file, created by +# sphinx-quickstart on Wed Jan 7 17:04:36 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# The contents of this file are pickled, so don't put values in the namespace +# that aren't pickleable (module imports are okay, they're removed automatically). +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +sys.path.insert(0,os.path.abspath('..')) +sys.path.insert(0,os.path.abspath('../..')) + +# General configuration +# --------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] +intersphinx_mapping = {'http://docs.python.org/': None} + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['.templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'python-apt' +copyright = u'2009, Julian Andres Klode ' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.7' +# The full version, including alpha/beta/rc tags. +release = '0.7.9~exp2' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# Options for HTML output +# ----------------------- + +# The style sheet to use for HTML and HTML Help pages. A file of that name +# must exist either in Sphinx' static/ path, or in one of the custom paths +# given in html_static_path. +html_style = 'default.css' + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['.static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, the reST sources are included in the HTML build as _sources/. +#html_copy_source = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'python-aptdoc' + + +# Options for LaTeX output +# ------------------------ + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +latex_documents = [ + ('index', 'python-apt.tex', ur'python-apt Documentation', + ur'Julian Andres Klode ', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/doc/source/examples/apt-gtk.py b/doc/source/examples/apt-gtk.py new file mode 100644 index 00000000..c3bb09d5 --- /dev/null +++ b/doc/source/examples/apt-gtk.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +"""Example for gtk widgets""" +import pygtk +pygtk.require("2.0") +import gtk + +import apt.gtk.widgets + + +def main(): + """Main function.""" + win = gtk.Window() + win.connect("destroy", gtk.main_quit) + progress = apt.gtk.widgets.GtkAptProgress() + win.set_title("GtkAptProgress Demo") + win.add(progress) + progress.show() + win.show() + cache = apt.cache.Cache(progress.open) + if cache["xterm"].isInstalled: + cache["xterm"].markDelete() + else: + cache["xterm"].markInstall() + progress.show_terminal(expanded=True) + cache.commit(progress.fetch, progress.install) + gtk.main() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-contents.py b/doc/source/examples/dpkg-contents.py new file mode 100644 index 00000000..99d1596f --- /dev/null +++ b/doc/source/examples/dpkg-contents.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +"""Emulate dpkg --contents""" + +import grp +import pwd +import stat +import sys +import time + +import apt_inst + + +def format_mode(what, mode): + """Return the symbolic mode""" + s_mode = dict(DIR="d", HARDLINK="h", FILE="-").get(what) + s_mode += ((mode & stat.S_IRUSR) and "r" or "-") + s_mode += ((mode & stat.S_IWUSR) and "w" or "-") + s_mode += ((mode & stat.S_IXUSR) and (mode & stat.S_ISUID and "s" or "x") + or (mode & stat.S_ISUID and "S" or "-")) + s_mode += ((mode & stat.S_IRGRP) and "r" or "-") + s_mode += ((mode & stat.S_IWGRP) and "w" or "-") + s_mode += ((mode & stat.S_IXGRP) and (mode & stat.S_ISGID and "s" or "x") + or (mode & stat.S_ISGID and "S" or "-")) + s_mode += ((mode & stat.S_IROTH) and "r" or "-") + s_mode += ((mode & stat.S_IWOTH) and "w" or "-") + s_mode += ((mode & stat.S_IXOTH) and "x" or "-") + return s_mode + + +def callback(what, name, link, mode, uid, gid, size, mtime, major, minor): + """callback for debExtract""" + s_mode = format_mode(what, mode) + s_owner = "%s/%s" % (pwd.getpwuid(uid)[0], grp.getgrgid(gid)[0]) + s_size = "%9d" % size + s_time = time.strftime("%Y-%m-%d %H:%M", time.localtime(mtime)) + s_name = name.startswith(".") and name or ("./" + name) + if link: + s_name += " link to %s" % link + print s_mode, s_owner, s_size, s_time, s_name + + +def main(): + """Main function""" + if len(sys.argv) < 2: + print >> sys.stderr, "need filename argumnet" + sys.exit(1) + + fobj = open(sys.argv[1]) + try: + apt_inst.debExtract(fobj, callback, "data.tar.gz") + finally: + fobj.close() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-extract.py b/doc/source/examples/dpkg-extract.py new file mode 100644 index 00000000..ced8652f --- /dev/null +++ b/doc/source/examples/dpkg-extract.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +"""Emulate dpkg --extract package.deb outdir""" +import os +import sys + +import apt_inst + + +def main(): + """Main function.""" + if len(sys.argv) < 3: + print >> sys.stderr, "Usage:", __file__, "package.deb outdir" + sys.exit(1) + if not os.path.exists(sys.argv[2]): + print >> sys.stderr, "The directory %s does not exist" % sys.argv[2] + sys.exit(1) + + fobj = open(sys.argv[1]) + try: + apt_inst.debExtractArchive(fobj, sys.argv[2]) + finally: + fobj.close() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-info.py b/doc/source/examples/dpkg-info.py new file mode 100644 index 00000000..ff98d8b1 --- /dev/null +++ b/doc/source/examples/dpkg-info.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +"""Emulate dpkg --info package.deb control-file""" +import sys + +from apt_inst import debExtractControl + + +def main(): + """Main function.""" + if len(sys.argv) < 3: + print >> sys.stderr, 'Usage: tool file.deb control-file' + sys.exit(0) + fobj = open(sys.argv[1]) + try: + print debExtractControl(fobj, sys.argv[2]) + finally: + fobj.close() + +if __name__ == '__main__': + main() diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..d7c425bd --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,38 @@ +Welcome to python-apt's documentation! +====================================== + +.. note:: + + This documentation can not be considered complete at the moment. But it + provides better documentation than the documentation available through + pydoc. + +.. note:: + + + This documentation has been created by Sphinx, using reStructuredText files + written by Julian Andres Klode , and in case of the apt + package, from the documentation shipped in the modules. + + +Contents: + +.. toctree:: + :maxdepth: 2 + + apt/index + apt_pkg/index + apt_inst + aptsources/index + coding + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + + diff --git a/po/python-apt.pot b/po/python-apt.pot index 7a1002fb..6ffef103 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-11-24 14:45+0100\n" +"POT-Creation-Date: 2009-01-09 17:23+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -336,25 +336,25 @@ msgstr "" msgid "Custom servers" msgstr "" -#: ../apt/gtk/widgets.py:173 +#: ../apt/gtk/widgets.py:243 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "" -#: ../apt/gtk/widgets.py:179 +#: ../apt/gtk/widgets.py:249 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "" #. Setup some child widgets -#: ../apt/gtk/widgets.py:220 +#: ../apt/gtk/widgets.py:269 msgid "Details" msgstr "" -#: ../apt/gtk/widgets.py:310 +#: ../apt/gtk/widgets.py:351 msgid "Starting..." msgstr "" -#: ../apt/gtk/widgets.py:313 +#: ../apt/gtk/widgets.py:357 msgid "Complete" msgstr "" diff --git a/setup.py b/setup.py index bdb59ff2..1ff7cb16 100755 --- a/setup.py +++ b/setup.py @@ -10,24 +10,9 @@ import os.path import pydoc import shutil import string +import subprocess import sys -def build_docs(dir="html", modules=["apt","aptsources"]): - htmldir = os.path.join(os.getcwd(), dir) - for d in modules: - for (dirpath, dirnames, filenames) in os.walk(d): - pydoc.writedoc(dirpath.replace("/",".")) - for file in filenames: - if not file.endswith(".py"): - continue - if file in ["__init__.py"]: - continue - pydoc.writedoc(dirpath.replace("/",".")+"."+file.split(".py")[0]) - if not os.path.exists(htmldir): - os.mkdir(htmldir) - for f in glob.glob("*.html"): - shutil.move(f, htmldir) - return True # The apt_pkg module files = map(lambda source: "python/"+source, @@ -41,23 +26,31 @@ apt_inst = Extension("apt_inst", files, libraries=["apt-pkg","apt-inst"]); # Replace the leading _ that is used in the templates for translation templates = [] -if not os.path.exists("build/data/templates/"): - os.makedirs("build/data/templates") -for template in glob.glob('data/templates/*.info.in'): - source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: - build.write(line.lstrip("_")) - source.close() - build.close() # build doc -if sys.argv[1] == "build": - build_docs() +if len(sys.argv) > 1 and sys.argv[1] == "build": + if not os.path.exists("build/data/templates/"): + os.makedirs("build/data/templates") + for template in glob.glob('data/templates/*.info.in'): + source = open(template, "r") + build = open(os.path.join("build", template[:-3]), "w") + lines = source.readlines() + for line in lines: + build.write(line.lstrip("_")) + source.close() + build.close() + if subprocess.call(["make", "-C", "doc", "html"]) : + raise SystemError +if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: + for dirname in "doc/build", "build/data", "build/mo": + if os.path.exists(dirname): + print "Removing", dirname + shutil.rmtree(dirname) + else: + print "Not removing", dirname, "because it does not exist" setup(name="python-apt", - version="0.6.17", + version="0.7.9", description="Python bindings for APT", author="APT Development Team", author_email="deity@lists.debian.org", -- cgit v1.2.3 From 21ba650e32457ee67ac0f85b03c071969aa5934b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 9 Jan 2009 21:52:32 +0100 Subject: * setup.py, doc/source/conf.py: Fix building by adding build/lib* to PYTHONPATH We now build the extension first, and then the documentation. Also add the text docs. --- debian/changelog | 6 ++++-- debian/python-apt.docs | 3 ++- debian/rules | 1 + doc/Makefile | 4 ++++ doc/source/conf.py | 7 +++++-- po/python-apt.pot | 2 +- setup.py | 14 ++++++++++---- 7 files changed, 27 insertions(+), 10 deletions(-) (limited to 'setup.py') diff --git a/debian/changelog b/debian/changelog index 1002bead..7d37e7be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,7 +13,9 @@ python-apt (0.7.9~exp2) experimental; urgency=low - debian/rules: Build the documentation here - setup.py: Remove pydoc building and add new docs. - debian/examples: Include examples from documentation - - debian/python-apt.docs: Change html/ to doc/build/html. + - debian/python-apt.docs: + + Change html/ to build/doc/html. + + Add build/doc/text for the text-only documentation * setup.py: - Only create build/data when building, not all the time - Remove build/mo and build/data on clean -a @@ -22,7 +24,7 @@ python-apt (0.7.9~exp2) experimental; urgency=low they are only needed for oldstable (sarge) - Build-Depend on python-sphinx (>= 0.5) - -- Julian Andres Klode Fri, 09 Jan 2009 17:20:41 +0100 + -- Julian Andres Klode Fri, 09 Jan 2009 18:11:30 +0100 python-apt (0.7.9~exp1) experimental; urgency=low diff --git a/debian/python-apt.docs b/debian/python-apt.docs index ff53abec..6ba083f5 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -1,4 +1,5 @@ README apt/README.apt data/templates/README.templates -doc/build/html/ +build/doc/html/ +build/doc/text/ diff --git a/debian/rules b/debian/rules index adaad2a8..90b48cda 100755 --- a/debian/rules +++ b/debian/rules @@ -13,6 +13,7 @@ include /usr/share/cdbs/1/class/python-distutils.mk PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') +DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) build/python-apt-dbg:: diff --git a/doc/Makefile b/doc/Makefile index 39fe377f..327bba91 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -26,6 +26,10 @@ help: clean: -rm -rf build/* +text: + mkdir -p build/text build/doctrees + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) build/text + html: mkdir -p build/html build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html diff --git a/doc/source/conf.py b/doc/source/conf.py index 4cd444f1..907e2275 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -19,8 +19,11 @@ import sys, os # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. -sys.path.insert(0,os.path.abspath('..')) -sys.path.insert(0,os.path.abspath('../..')) +sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('../..')) +if os.path.exists("../../build"): + for dirname in os.listdir('../../build'): + sys.path.insert(0, os.path.abspath('../../build/' + dirname)) # General configuration # --------------------- diff --git a/po/python-apt.pot b/po/python-apt.pot index 6ffef103..6af898db 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-01-09 17:23+0100\n" +"POT-Creation-Date: 2009-01-09 18:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/setup.py b/setup.py index 1ff7cb16..016db85a 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ import os.path import pydoc import shutil import string -import subprocess import sys @@ -39,10 +38,10 @@ if len(sys.argv) > 1 and sys.argv[1] == "build": build.write(line.lstrip("_")) source.close() build.close() - if subprocess.call(["make", "-C", "doc", "html"]) : - raise SystemError + + if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "doc/build", "build/data", "build/mo": + for dirname in "build/doc", "doc/build", "build/data", "build/mo": if os.path.exists(dirname): print "Removing", dirname shutil.rmtree(dirname) @@ -65,3 +64,10 @@ setup(name="python-apt", license = 'GNU GPL', platforms = 'posix' ) + +if len(sys.argv) > 1 and sys.argv[1] == "build": + import sphinx + sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/html"]) + sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From 2e4443bbd9872f5599c9a8eb93a65d6c34c83ca2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 12 Jan 2009 17:01:34 +0100 Subject: Cleanup: Comparisons to True/False, ==/!= None, deprecated modules --- apt/cache.py | 16 +++++------ aptsources/distinfo.py | 16 +++++------ aptsources/distro.py | 13 +++++---- aptsources/sourceslist.py | 54 +++++++++++++++++-------------------- doc/examples/action.py | 4 +-- doc/examples/all_deps.py | 4 +-- doc/examples/build-deps.py | 3 +-- doc/examples/depcache.py | 4 +-- doc/examples/dependant-pkgs.py | 2 +- doc/examples/gui-inst.py | 9 +------ doc/examples/progress.py | 9 +++---- doc/examples/versiontest.py | 3 +-- doc/source/conf.py | 18 +++++++------ doc/source/examples/missing-deps.py | 1 + setup.py | 9 +++---- tests/depcache.py | 2 +- tests/pkgproblemresolver.py | 2 +- tests/test_aptsources_ports.py | 18 ++++++++----- tests/test_debextract.py | 19 ++++++++----- 19 files changed, 98 insertions(+), 108 deletions(-) (limited to 'setup.py') diff --git a/apt/cache.py b/apt/cache.py index f134ab0a..ff3149f5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -76,12 +76,12 @@ class Cache(object): self._dict = {} # build the packages dict - if progress != None: + if progress is not None: progress.Op = "Building data structures" i=last=0 size=len(self._cache.Packages) for pkg in self._cache.Packages: - if progress != None and last+100 < i: + if progress is not None and last+100 < i: progress.update(i/float(size)*100) last=i # drop stuff with no versions (cruft) @@ -91,7 +91,7 @@ class Cache(object): self, pkg) i += 1 - if progress != None: + if progress is not None: progress.done() self._runCallbacks("cache_post_open") @@ -216,7 +216,7 @@ class Cache(object): return providers for pkg in self: v = self._depcache.GetCandidateVer(pkg._pkg) - if v == None: + if v is None: continue for p in v.ProvidesList: if virtual == p[0]: @@ -232,7 +232,7 @@ class Cache(object): raise LockFailedException("Failed to lock %s" % lockfile) try: - if fetchProgress == None: + if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() return self._cache.Update(fetchProgress, self._list) finally: @@ -253,9 +253,9 @@ class Cache(object): # Current a failed download will just display "error" # which is less than optimal! - if fetchProgress == None: + if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() - if installProgress == None: + if installProgress is None: installProgress = apt.progress.InstallProgress() pm = apt_pkg.GetPackageManager(self._depcache) @@ -327,7 +327,7 @@ class FilteredCache(object): """ def __init__(self, cache=None, progress=None): - if cache == None: + if cache is None: self.cache = Cache(progress) else: self.cache = cache diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 3c499b52..59fa7e02 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -27,11 +27,9 @@ import os import gettext from os import getenv import ConfigParser -import string -import apt_pkg +import re -#from gettext import gettext as _ -import gettext +import apt_pkg def _(s): @@ -76,9 +74,9 @@ class Component: self.description_long = long_desc def get_description(self): - if self.description_long != None: + if self.description_long is not None: return self.description_long - elif self.description != None: + elif self.description is not None: return self.description else: return None @@ -221,8 +219,8 @@ class DistInfo: mirror_set = {} try: mirror_data = filter(match_mirror_line.match, - map(string.strip, open(value))) - except: + [x.strip() for x in open(value)]) + except Exception: print "WARNING: Failed to read mirror file" mirror_data = [] for line in mirror_data: @@ -256,7 +254,7 @@ class DistInfo: if not template: return # reuse some properties of the parent template - if template.match_uri == None and template.child: + if template.match_uri is None and template.child: for t in template.parents: if t.match_uri: template.match_uri = t.match_uri diff --git a/aptsources/distro.py b/aptsources/distro.py index a8f1d0fd..d8f191d6 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -21,7 +21,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import string import gettext import re import os @@ -86,7 +85,7 @@ class Distribution: # template.components self.source_template = template break - if self.source_template == None: + if self.source_template is None: raise NoDistroTemplateException("Error: could not find a " "distribution template") @@ -259,14 +258,14 @@ class Distribution: """ Add distribution specific sources """ - if uri == None: + if uri is None: # FIXME: Add support for the server selector uri = self.default_server - if dist == None: + if dist is None: dist = self.codename - if comps == None: + if comps is None: comps = list(self.enabled_comps) - if type == None: + if type is None: type = self.binary_type new_source = self.sourceslist.add(type, uri, dist, comps, comment) # if source code is enabled add a deb-src line after the new @@ -379,7 +378,7 @@ class Distribution: change_server_of_source(source, uri, seen_binary) for source in self.child_sources: # Do not change the forces server of a child source - if source.template.base_uri == None or \ + if source.template.base_uri is None or \ source.template.base_uri != source.uri: change_server_of_source(source, uri, seen_binary) for source in self.source_code_sources: diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index a0346267..dc2a5d45 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -23,18 +23,16 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import string import gettext -import re -import apt_pkg import glob -import shutil -import time import os.path +import re +import shutil import sys +import time -#from UpdateManager.Common.DistInfo import DistInfo -from distinfo import DistInfo +import apt_pkg +from aptsources.distinfo import DistInfo # some global helpers @@ -88,7 +86,7 @@ class SourceEntry: # (may empty) self.comment = "" # (optional) comment self.line = line # the original sources.list line - if file == None: + if file is None: file = apt_pkg.Config.FindDir( "Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist") self.file = file # the file that the entry is located in @@ -107,7 +105,7 @@ class SourceEntry: def mysplit(self, line): """ a split() implementation that understands the sources.list format better and takes [] into account (for e.g. cdroms) """ - line = string.strip(line) + line = line.strip() pieces = [] tmp = "" # we are inside a [..] block @@ -138,7 +136,7 @@ class SourceEntry: def parse(self, line): """ parse a given sources.list (textual) line and break it up into the field we have """ - line = string.strip(self.line) + line = self.line.strip() #print line # check if the source is enabled/disabled if line == "" or line == "#": # empty line @@ -146,7 +144,7 @@ class SourceEntry: return if line[0] == "#": self.disabled = True - pieces = string.split(line[1:]) + pieces = line[1:].strip() # if it looks not like a disabled deb line return if not pieces[0] in ("rpm", "rpm-src", "deb", "deb-src"): self.invalid = True @@ -165,18 +163,18 @@ class SourceEntry: self.invalid = True return # Type, deb or deb-src - self.type = string.strip(pieces[0]) + self.type = pieces[0].strip() # Sanity check if self.type not in ("deb", "deb-src", "rpm", "rpm-src"): self.invalid = True return # URI - self.uri = string.strip(pieces[1]) + self.uri = pieces[1].strip() if len(self.uri) < 1: self.invalid = True # distro and components (optional) # Directory or distro - self.dist = string.strip(pieces[2]) + self.dist = pieces[2].strip() if len(pieces) > 3: # List of components self.comps = pieces[3:] @@ -187,15 +185,11 @@ class SourceEntry: """ set a line to enabled or disabled """ self.disabled = not new_value # enable, remove all "#" from the start of the line - if new_value == True: - i=0 - self.line = string.lstrip(self.line) - while self.line[i] == "#": - i += 1 - self.line = self.line[i:] + if new_value: + self.line = self.line.lstrip().lstrip('#') else: # disabled, add a "#" - if string.strip(self.line)[0] != "#": + if self.line.strip()[0] != "#": self.line = "#" + self.line def __str__(self): @@ -251,7 +245,7 @@ class SourcesList: self.load(file) # check if the source item fits a predefined template for source in self.list: - if source.invalid == False: + if not source.invalid: self.matcher.match(source) def __iter__(self): @@ -272,7 +266,7 @@ class SourcesList: comps = orig_comps[:] # check if we have this source already in the sources.list for source in self.list: - if source.disabled == False and source.invalid == False and \ + if not source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist: for new_comp in comps: @@ -285,14 +279,14 @@ class SourcesList: for source in self.list: # if there is a repo with the same (type, uri, dist) just add the # components - if source.disabled == False and source.invalid == False and \ + if not source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist: comps = uniq(source.comps + comps) source.comps = comps return source # if there is a corresponding repo which is disabled, enable it - elif source.disabled == True and source.invalid == False and \ + elif source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist and \ len(set(source.comps) & set(comps)) == len(comps): @@ -306,7 +300,7 @@ class SourcesList: line = "%s #%s\n" % (line, comment) line = line + "\n" new_entry = SourceEntry(line) - if file != None: + if file is not None: new_entry.file = file self.matcher.match(new_entry) self.list.insert(pos, new_entry) @@ -333,7 +327,7 @@ class SourcesList: """ make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned) """ already_backuped = set() - if backup_ext == None: + if backup_ext is None: backup_ext = time.strftime("%y%m%d.%H%M") for source in self.list: if not source.file in already_backuped \ @@ -380,11 +374,11 @@ class SourcesList: used_child_templates = {} for source in sources_list: # try to avoid checking uninterressting sources - if source.template == None: + if source.template is None: continue # set up a dict with all used child templates and corresponding # source entries - if source.template.child == True: + if source.template.child: key = source.template if key not in used_child_templates: used_child_templates[key] = [] @@ -414,7 +408,7 @@ class SourceEntryMatcher: f = f[0:i] dist = DistInfo(f, base_dir=matcherPath) for template in dist.templates: - if template.match_uri != None: + if template.match_uri is not None: self.templates.append(template) return diff --git a/doc/examples/action.py b/doc/examples/action.py index 7153292c..9b9d7dd3 100644 --- a/doc/examples/action.py +++ b/doc/examples/action.py @@ -86,7 +86,7 @@ print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) for pkg in cache.Packages: - if pkg.CurrentVer != None and not depcache.MarkedInstall(pkg) \ + if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \ and depcache.IsUpgradable(pkg): print "Upgrade didn't upgrade (kept): %s" % pkg.Name @@ -101,7 +101,7 @@ print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) # overview about what would happen for pkg in cache.Packages: if depcache.MarkedInstall(pkg): - if pkg.CurrentVer != None: + if pkg.CurrentVer is not None: print "Marked upgrade: %s " % pkg.Name else: print "Marked install: %s" % pkg.Name diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py index 0a2f3157..992e98d8 100644 --- a/doc/examples/all_deps.py +++ b/doc/examples/all_deps.py @@ -1,13 +1,13 @@ #!/usr/bin/env python - import sys + import apt def dependencies(cache, pkg, deps, key="Depends"): #print "pkg: %s (%s)" % (pkg.name, deps) candver = cache._depcache.GetCandidateVer(pkg._pkg) - if candver == None: + if candver is None: return deps dependslist = candver.DependsList if key in dependslist: diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index dc1a6f4e..aeb5667c 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -3,7 +3,6 @@ import apt_pkg import sys -import sets # only needed for python2.3, python2.4 supports this naively def get_source_pkg(pkg, records, depcache): @@ -37,7 +36,7 @@ try: except KeyError: print "No package %s found" % sys.argv[1] sys.exit(1) -all_build_depends = sets.Set() +all_build_depends = set() # get the build depdends for the package itself srcpkg_name = get_source_pkg(base, records, depcache) diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py index ad884fe7..790cc9d6 100644 --- a/doc/examples/depcache.py +++ b/doc/examples/depcache.py @@ -84,7 +84,7 @@ print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) for pkg in cache.Packages: - if pkg.CurrentVer != None and not depcache.MarkedInstall(pkg) \ + if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \ and depcache.IsUpgradable(pkg): print "Upgrade didn't upgrade (kept): %s" % pkg.Name @@ -100,7 +100,7 @@ print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) # overview about what would happen for pkg in cache.Packages: if depcache.MarkedInstall(pkg): - if pkg.CurrentVer != None: + if pkg.CurrentVer is not None: print "Marked upgrade: %s " % pkg.Name else: print "Marked install: %s" % pkg.Name diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py index bb10ce70..5fbbc76d 100755 --- a/doc/examples/dependant-pkgs.py +++ b/doc/examples/dependant-pkgs.py @@ -7,7 +7,7 @@ pkgs = set() cache = apt.Cache() for pkg in cache: candver = cache._depcache.GetCandidateVer(pkg._pkg) - if candver == None: + if candver is None: continue dependslist = candver.DependsList for dep in dependslist.keys(): diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index cb49db3e..8138d922 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -1,20 +1,13 @@ #!/usr/bin/python # example how to install in a custom terminal widget # see also gnome bug: #169201 - -import apt -import apt_pkg -import sys, os, fcntl -import copy -import string -import fcntl - import pygtk pygtk.require('2.0') import gtk import apt.gtk.widgets + if __name__ == "__main__": win = gtk.Window() diff --git a/doc/examples/progress.py b/doc/examples/progress.py index c56734b7..83847598 100644 --- a/doc/examples/progress.py +++ b/doc/examples/progress.py @@ -1,8 +1,7 @@ -import apt -from apt import SizeToStr import sys import time -import string + +import apt class TextProgress(apt.OpProgress): @@ -39,8 +38,8 @@ class TextFetchProgress(apt.FetchProgress): def pulse(self): print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % ( - SizeToStr(self.currentCPS), SizeToStr(self.currentBytes), - SizeToStr(self.totalBytes), self.currentItems, self.totalItems) + apt.SizeToStr(self.currentCPS), SizeToStr(self.currentBytes), + apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems) return True def mediaChange(self, medium, drive): diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py index dd881f6b..fa13cc1c 100755 --- a/doc/examples/versiontest.py +++ b/doc/examples/versiontest.py @@ -4,7 +4,6 @@ import apt_pkg import sys import re -import string apt_pkg.InitConfig() apt_pkg.InitSystem() @@ -22,7 +21,7 @@ while(1): CurLine = CurLine + 1 if Line == "": break - Line = string.strip(Line) + Line = Line.strip() if len(Line) == 0 or Line[0] == '#': continue diff --git a/doc/source/conf.py b/doc/source/conf.py index bb8056ad..8f71e3e3 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -3,18 +3,20 @@ # python-apt documentation build configuration file, created by # sphinx-quickstart on Wed Jan 7 17:04:36 2009. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # The contents of this file are pickled, so don't put values in the namespace -# that aren't pickleable (module imports are okay, they're removed automatically). +# that aren't pickleable (module imports are okay, they're removed +# automatically). # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. - -import sys, os +import os +import sys # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it @@ -28,8 +30,8 @@ if os.path.exists("../../build"): # General configuration # --------------------- -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo'] intersphinx_mapping = {'http://docs.python.org/': None} @@ -76,7 +78,7 @@ release = '0.7.9~exp2' # for source files. exclude_trees = [] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -172,7 +174,7 @@ htmlhelp_basename = 'python-aptdoc' #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, document class [howto/manual]). +# (source index, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'python-apt.tex', ur'python-apt Documentation', ur'Julian Andres Klode ', 'manual'), diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py index 0870eb98..3ca16e45 100644 --- a/doc/source/examples/missing-deps.py +++ b/doc/source/examples/missing-deps.py @@ -10,6 +10,7 @@ def fmt_dep(dep): ret += " (%s %s)" % (dep.CompType, dep.TargetVer) return ret + def check_version(pkgver): """Check the version of the package""" missing = [] diff --git a/setup.py b/setup.py index c9f940a4..6a22734d 100755 --- a/setup.py +++ b/setup.py @@ -3,24 +3,21 @@ from distutils.core import setup, Extension from distutils.sysconfig import parse_makefile -from DistUtilsExtra.command import * +from DistUtilsExtra.command import build_extra, build_i18n import glob import os -import os.path -import pydoc import shutil -import string import sys # The apt_pkg module files = map(lambda source: "python/"+source, - string.split(parse_makefile("python/makefile")["APT_PKG_SRC"])) + parse_makefile("python/makefile")["APT_PKG_SRC"].split()) apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module files = map(lambda source: "python/"+source, - string.split(parse_makefile("python/makefile")["APT_INST_SRC"])) + parse_makefile("python/makefile")["APT_INST_SRC"].split()) apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation diff --git a/tests/depcache.py b/tests/depcache.py index b199c812..19aba680 100644 --- a/tests/depcache.py +++ b/tests/depcache.py @@ -22,7 +22,7 @@ def main(): x = pkg.Name # then get each version ver =depcache.GetCandidateVer(pkg) - if ver != None: + if ver is not None: depcache.MarkInstall(pkg) if depcache.InstCount == 0: if depcache.IsUpgradable(pkg): diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py index 7d5ae682..a21d8d9d 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/pkgproblemresolver.py @@ -22,7 +22,7 @@ def main(): x = pkg.Name # then get each version ver =depcache.GetCandidateVer(pkg) - if ver != None: + if ver is not None: depcache.MarkInstall(pkg) if depcache.BrokenCount > 0: fixer = apt_pkg.GetPkgProblemResolver(depcache) diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py index 203721c7..09d6e9d9 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -1,28 +1,32 @@ #!/usr/bin/env python import unittest -import apt_pkg + import os import copy - import sys + sys.path.insert(0, "../") +import apt_pkg import aptsources import aptsources.sourceslist import aptsources.distro + class TestAptSources(unittest.TestCase): + def __init__(self, methodName): unittest.TestCase.__init__(self, methodName) apt_pkg.init() - apt_pkg.Config.Set("APT::Architecture","powerpc") - apt_pkg.Config.Set("Dir::Etc", os.path.join(os.getcwd(),"test-data-ports")) - apt_pkg.Config.Set("Dir::Etc::sourceparts","/xxx") + apt_pkg.Config.Set("APT::Architecture", "powerpc") + apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports")) + apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist","sources.list") + apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro("Ubuntu","hardy","desc","8.04") + distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", + "8.04") distro.get_sources(sources) # test if all suits of the current distro were detected correctly dist_templates = set() diff --git a/tests/test_debextract.py b/tests/test_debextract.py index c080b26e..4ba498ae 100755 --- a/tests/test_debextract.py +++ b/tests/test_debextract.py @@ -1,13 +1,18 @@ #!/usr/bin/python +import sys import apt_inst -import sys -def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): + +def Callback(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) + What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) + + +def main(): + member = "data.tar.lzma" + if len(sys.argv) > 2: + member = sys.argv[2] + apt_inst.debExtract(open(sys.argv[1]), Callback, member) -member = "data.tar.lzma" -if len(sys.argv) > 2: - member = sys.argv[2] -apt_inst.debExtract(open(sys.argv[1]), Callback, member) +main() -- cgit v1.2.3