diff options
| author | Ben Finney <ben@benfinney.id.au> | 2008-05-16 14:58:00 +1000 |
|---|---|---|
| committer | Ben Finney <ben@benfinney.id.au> | 2008-05-16 14:58:00 +1000 |
| commit | b147f1846cd26ab25ad925105f52421992395918 (patch) | |
| tree | f1cb14ef290ab7ef91668b1b2a6f1a1bf41d3329 | |
| parent | 44faadf294230dc6384b309b06089520d562f199 (diff) | |
| download | python-apt-b147f1846cd26ab25ad925105f52421992395918.tar.gz | |
Remove trailing whitespace.
60 files changed, 646 insertions, 646 deletions
@@ -1,9 +1,9 @@ * apt.Package: - change all candidateInstalledSize() to installSize(useCandidate=True) - same for candidateOrigin() (see downloadable for a example). + same for candidateOrigin() (see downloadable for a example). - might be better to have "Package.candidate.{downloadable,size,etc} - + * aptsources: - make the distro detection in sources.list more clever by using the origin informaton to avoid adding full uris to (unofficial/internal) - mirrors + mirrors diff --git a/apt/cache.py b/apt/cache.py index a92bd5be..6773aeec 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 <michael.vogt@ubuntu.com> -# -# 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 """ @@ -53,7 +53,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 @@ -80,12 +80,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] @@ -106,7 +106,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 \ @@ -127,7 +127,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) @@ -136,7 +136,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 @@ -189,13 +189,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: @@ -276,7 +276,7 @@ class FilteredCache(object): self._filters = [] def __len__(self): return len(self._filtered) - + def __getitem__(self, key): return self.cache._dict[key] @@ -294,7 +294,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 = [] @@ -318,7 +318,7 @@ class FilteredCache(object): return self.__dict__[key] else: return getattr(self.cache, key) - + def cache_pre_changed(): print "cache pre changed" @@ -370,7 +370,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)" @@ -383,5 +383,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 ddde5bf1..73e0288d 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -27,7 +27,7 @@ class DebPackage(object): def __getitem__(self, key): return self._sections[key] - + def filelist(self): """ return the list of files in the deb """ files = [] @@ -49,10 +49,10 @@ class DebPackage(object): if __name__ == "__main__": import sys - + d = DebPackage(sys.argv[1]) print d["Section"] print d["Maintainer"] print "Files:" print "\n".join(d.filelist) - + diff --git a/apt/package.py b/apt/package.py index ac045969..043f58ca 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 <michael.vogt@ubuntu.com> -# -# 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 @@ -83,7 +83,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 @@ -138,7 +138,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) @@ -146,7 +146,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 @@ -263,7 +263,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): @@ -292,7 +292,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 """ @@ -315,7 +315,7 @@ 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) @@ -364,7 +364,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: @@ -424,7 +424,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 bb1bce35..19237a01 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 <michael.vogt@ubuntu.com> -# -# 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 8d1c8b69..8b137891 100644 --- a/aptsources/__init__.py +++ b/aptsources/__init__.py @@ -1 +1 @@ - + diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index fdd063a5..bc567a3a 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 <kov@debian.org> # Sebastian Heinlein <glatzor@ubuntu.com> -# -# 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 @@ -53,7 +53,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) @@ -238,8 +238,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 debbb12a..0a977445 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 <glatzor@ubuntu.com> # Michael Vogt <mvo@debian.org> -# -# 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): @@ -424,7 +424,7 @@ def get_distro(): 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 <michiel@eyesopened.nl> # Michael Vogt <mvo@debian.org> # Sebastian Heinlein <glatzor@ubuntu.com> -# -# 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/configure.in b/configure.in index e62985c2..1000f38c 100644 --- a/configure.in +++ b/configure.in @@ -21,7 +21,7 @@ EOF [AC_CHECK_LIB(python$ac_cv_ver_python,PyArg_ParseTuple, [AC_DEFINE(HAVE_PYTHONLIB) PYTHONLIB="-lpython$ac_cv_ver_python $ac_cv_libs_python"],[],$ac_cv_libs_python)]) AC_SUBST(PYTHONLIB) - + PYTHONVER=$ac_cv_ver_python PYTHONPREFIX=$ac_cv_prefix_python PYTHONEXECPREFIX=$ac_cv_execprefix_python diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in index 244e1c6b..8a5c94c5 100644 --- a/data/templates/Debian.info.in +++ b/data/templates/Debian.info.in @@ -5,7 +5,7 @@ RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchUri: ftp[0-9]*\.[a-z]\.debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors -_Description: Debian 4.0 'Etch' +_Description: Debian 4.0 'Etch' Component: main _CompDescription: Officially supported Component: contrib diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 47ab53de..ab3dc790 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -220,7 +220,7 @@ _CompDescription: Community-maintained (universe) _CompDescriptionLong: Community-maintained Open Source software Component: restricted _CompDescription: Non-free drivers -_CompDescriptionLong: Proprietary drivers for devices +_CompDescriptionLong: Proprietary drivers for devices Component: multiverse _CompDescription: Restricted software (Multiverse) _CompDescriptionLong: Software restricted by copyright or legal issues diff --git a/debian/changelog b/debian/changelog index 0c7a782c..c81885f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,7 +21,7 @@ python-apt (0.7.4) unstable; urgency=low * apt/debfile.py: - added wrapper around apt_inst.debExtract() - - support dictionary like access + - support dictionary like access * apt/package.py: - fix apt.package.Dependency.relation initialization * python/apt_instmodule.cc: @@ -40,7 +40,7 @@ python-apt (0.7.4) unstable; urgency=low * python/depcache.cc: - be more threading friendly * python/tag.cc - - support "None" as default in + - support "None" as default in ParseSection(control).get(field, default), LP: #44470 * python/progress.cc: - fix refcount problem in OpProgress @@ -72,7 +72,7 @@ python-apt (0.7.3) unstable; urgency=low * doc/examples/records.py: - added example how to use the new Records class * apt/cache.py: - - throw FetchCancelleException, FetchFailedException, + - throw FetchCancelleException, FetchFailedException, LockFailedException exceptions when something goes wrong * aptsources/distro.py: - generalized some code, bringing it into the Distribution @@ -91,7 +91,7 @@ python-apt (0.7.2) unstable; urgency=low * build against the new apt * support for new "aptsources" pythn module - (thanks to Sebastian Heinlein) + (thanks to Sebastian Heinlein) * merged support for translated package descriptions * merged support for automatic removal of unused dependencies @@ -126,7 +126,7 @@ python-apt (0.6.21) unstable; urgency=low - better cdrom handling support * apt/package.py: - added candidateDependencies, installedDependencies - - SizeToString supports PyLong too + - SizeToString supports PyLong too - support pkg.architecture - support candidateRecord, installedRecord * apt/cache.py: @@ -156,7 +156,7 @@ python-apt (0.6.20) unstable; urgency=low - use select() when checking for statusfd (lp: #53282) * acknoledge NMU (closes: #378048, #373512) * python/apt_pkgmodule.cc: - - fix missing docstring (closes: #368907), + - fix missing docstring (closes: #368907), Thanks to Josh Triplett * make it build against python2.5 * python/progress.cc: @@ -208,40 +208,40 @@ python-apt (0.6.18) unstable; urgency=low python-apt (0.6.17) unstable; urgency=low - * apt/progress.py: + * apt/progress.py: - initialize FetchProgress.eta with the correct type - strip the staus str before passing it to InstallProgress.statusChanged() - - added InstallProgress.statusChange(pkg, percent, status) - - make DumbInstallProgress a new-style class + - added InstallProgress.statusChange(pkg, percent, status) + - make DumbInstallProgress a new-style class (thanks to kamion for the suggestions) - fix various pychecker warnings * apt/cache.py: - return useful values on Cache.update() - Release locks on failure (thanks to Colin Watson) - fix various pychecker warnings - * apt/package.py: + * apt/package.py: - fix various pychecker warnings - check if looupRecords succeeded - fix bug in the return statement of _downloadable() * python/srcrecords.cc: - add "Restart" method - - don't run auto "Restart" before performing a Lookup + - don't run auto "Restart" before performing a Lookup - fix the initalization (no need to pass a PkgCacheType to the records) - added "Index" attribute * python/indexfile.cc: - added ArchiveURI() method - + -- Michael Vogt <mvo@debian.org> Mon, 8 May 2006 22:34:58 +0200 python-apt (0.6.16.2) unstable; urgency=low - + * Non-maintainer upload. * debian/control: + Replaces: python-apt (<< 0.6.11), instead of Conflicts which is not correct here. (closes: #308586). -- Pierre Habouzit <madcoder@debian.org> Fri, 14 Apr 2006 19:30:51 +0200 - + python-apt (0.6.16.1) unstable; urgency=low * memleak fixed when pkgCache objects are deallocated @@ -254,11 +254,11 @@ python-apt (0.6.16.1) unstable; urgency=low python-apt (0.6.16) unstable; urgency=low - * added GetPkgAcqFile to queue individual file downloads with the + * added GetPkgAcqFile to queue individual file downloads with the system (dosn't make use of the improved pkgAcqFile yet) * added SourceList.GetIndexes() * rewrote apt.cache.update() to use the improved aquire interface - * apt/ API change: apt.Package.candidateOrigin returns a list of origins + * apt/ API change: apt.Package.candidateOrigin returns a list of origins now instead of a single one * apt_pkg.Cdrom.Add() returns a boolean now, CdromProgress has totalSteps * added support for pkgIndexFile and added SourcesList.FindIndex() @@ -285,8 +285,8 @@ python-apt (0.6.14) unstable; urgency=low (this is the job of the caller now) * python/srcrecords.cc: - support for "srcrecords.Files" added - - always run "Restart" before performing a Lookup - * export locking via: GetLock(),PkgSystem{Lock,UnLock} + - always run "Restart" before performing a Lookup + * export locking via: GetLock(),PkgSystem{Lock,UnLock} * apt/cache.py: - added __iter__ to make "for pkg in apt.Cache:" stuff possible @@ -304,9 +304,9 @@ python-apt (0.6.13) unstable; urgency=low * native apt/ python directory added that contains a more pythonic interface to apt_pkg * made the apt/ python code PEP08 conform - * python exceptions return the apt error message now + * python exceptions return the apt error message now (thanks to Chris Halls for the patch) - + -- Michael Vogt <mvo@debian.org> Fri, 5 Aug 2005 10:30:31 +0200 python-apt (0.6.12.2) unstable; urgency=low @@ -319,7 +319,7 @@ python-apt (0.6.12.1) unstable; urgency=low * rebuild against the latest apt - -- Michael Vogt <mvo@debian.org> Tue, 28 Jun 2005 18:29:57 +0200 + -- Michael Vogt <mvo@debian.org> Tue, 28 Jun 2005 18:29:57 +0200 python-apt (0.6.12ubuntu1) breezy; urgency=low @@ -331,17 +331,17 @@ python-apt (0.6.12ubuntu1) breezy; urgency=low -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 12 May 2005 11:34:05 +0200 python-apt (0.6.12) breezy; urgency=low - + * added a tests/ directory * added tests/pkgsrcrecords.py that will check if the pkgsrcrecords interface does not segfault * new native python "apt" interface that hides the details of apt_pkg -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 6 May 2005 10:11:52 +0200 - + python-apt (0.6.11) experimental; urgency=low - * fixed some reference count problems in the depcache and + * fixed some reference count problems in the depcache and pkgsrcrecords code * DepCache.Init() is never called implicit now * merged with python-apt tree from Greek0@gmx.net--2005-main @@ -417,7 +417,7 @@ python-apt (0.5.8) unstable; urgency=low python-apt (0.5.5.2) unstable; urgency=low - * Add myself to Uploaders so that bugs don't get tagged as NMU-fixed anymore + * Add myself to Uploaders so that bugs don't get tagged as NMU-fixed anymore * Initial support for working with source packages (Closes: #199716) -- Matt Zimmerman <mdz@debian.org> Tue, 22 Jul 2003 22:20:00 -0400 @@ -427,7 +427,7 @@ python-apt (0.5.5.1) unstable; urgency=low * DepIterator::GlobOr increments the iterator; don't increment it again. This caused every other dependency to be skipped (Closes: #195805) * Avoid a null pointer dereference when calling keys() on an empty - configuration (Closes: #149380) + configuration (Closes: #149380) -- Matt Zimmerman <mdz@debian.org> Mon, 2 Jun 2003 23:18:53 -0400 @@ -457,7 +457,7 @@ python-apt (0.5.4.4) unstable; urgency=low Closes: #157773 -- Matt Zimmerman <mdz@debian.org> Tue, 27 Aug 2002 19:22:10 -0400 - + python-apt (0.5.4.3) unstable; urgency=low * #include <new> in python/generic.h so that we can build on ia64, which diff --git a/debian/control b/debian/control index 51bb064b..a1d9b807 100644 --- a/debian/control +++ b/debian/control @@ -18,7 +18,7 @@ Provides: ${python:Provides} Suggests: python-apt-dbg XB-Python-Version: ${python:Versions} Description: Python interface to libapt-pkg - The apt_pkg Python interface will provide full access to the internal + The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a variety of functions, such as: . @@ -27,7 +27,7 @@ Description: Python interface to libapt-pkg - Parsing of Debian package control files, and other files with a similar structure . - The included 'aptsources' Python interface provides an abstraction of + The included 'aptsources' Python interface provides an abstraction of the sources.list configuration on the repository and the distro level. Package: python-apt-dbg @@ -35,7 +35,7 @@ Priority: extra Architecture: any Depends: python-dbg, python-apt (= ${Source-Version}), ${shlibs:Depends} Description: Python interface to libapt-pkg (debug extension) - The apt_pkg Python interface will provide full access to the internal + The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a variety of functions. . diff --git a/debian/copyright b/debian/copyright index 1e310354..f8463185 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,6 @@ -APT is free software; you can redistribute them and/or modify them 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 +APT is free software; you can redistribute them and/or modify them 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. On Debian systems, a copy of the GNU General Public License can be diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 1291dbfa..cce3fb0d 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -38,7 +38,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) @@ -78,7 +78,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..fae7b55b 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 """ @@ -67,6 +67,6 @@ for dep in depends["Depends"]: # FIXME: do we need to consider PreDepends? #print "%s: %s " % (srcpkg_name, bd) for b in bd: all_build_depends.add(b[0]) - + print "\n".join(all_build_depends) 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 c2555134..5e5d2c99 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -105,7 +105,7 @@ iprogress = TermInstallProgress() # show the interface while gtk.events_pending(): gtk.main_iteration() - + pkg = cache["3dchess"] print "\n%s"%pkg.name 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/python/acquire.cc b/python/acquire.cc index 65f8f2d7..83b45fac 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -16,7 +16,7 @@ static PyObject *AcquireItemAttr(PyObject *Self,char *Name) { pkgAcquire::ItemIterator &I = GetCpp<pkgAcquire::ItemIterator>(Self); - + if (strcmp("ID",Name) == 0) return Py_BuildValue("i",(*I)->ID); else if (strcmp("Status",Name) == 0) @@ -56,7 +56,7 @@ static PyObject *AcquireItemAttr(PyObject *Self,char *Name) static PyObject *AcquireItemRepr(PyObject *Self) { pkgAcquire::ItemIterator &I = GetCpp<pkgAcquire::ItemIterator>(Self); - + char S[300]; snprintf(S,sizeof(S),"<pkgAcquire::ItemIterator object: " "Status: %i Complete: %i Local: %i IsTrusted: %i " @@ -91,11 +91,11 @@ PyTypeObject AcquireItemType = static PyObject *PkgAcquireRun(PyObject *Self,PyObject *Args) -{ +{ pkgAcquire *fetcher = GetCpp<pkgAcquire*>(Self); int pulseInterval = 500000; - if (PyArg_ParseTuple(Args, "|i", &pulseInterval) == 0) + if (PyArg_ParseTuple(Args, "|i", &pulseInterval) == 0) return 0; pkgAcquire::RunResult run = fetcher->Run(pulseInterval); @@ -104,19 +104,19 @@ static PyObject *PkgAcquireRun(PyObject *Self,PyObject *Args) } static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args) -{ +{ pkgAcquire *fetcher = GetCpp<pkgAcquire*>(Self); - if (PyArg_ParseTuple(Args, "") == 0) + if (PyArg_ParseTuple(Args, "") == 0) return 0; fetcher->Shutdown(); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } -static PyMethodDef PkgAcquireMethods[] = +static PyMethodDef PkgAcquireMethods[] = { {"Run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, {"Shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, @@ -128,16 +128,16 @@ static PyObject *AcquireAttr(PyObject *Self,char *Name) { pkgAcquire *fetcher = GetCpp<pkgAcquire*>(Self); - if(strcmp("TotalNeeded",Name) == 0) + if(strcmp("TotalNeeded",Name) == 0) return Py_BuildValue("d", fetcher->TotalNeeded()); - if(strcmp("FetchNeeded",Name) == 0) + if(strcmp("FetchNeeded",Name) == 0) return Py_BuildValue("d", fetcher->FetchNeeded()); - if(strcmp("PartialPresent",Name) == 0) + if(strcmp("PartialPresent",Name) == 0) return Py_BuildValue("d", fetcher->PartialPresent()); - if(strcmp("Items",Name) == 0) + if(strcmp("Items",Name) == 0) { PyObject *List = PyList_New(0); - for (pkgAcquire::ItemIterator I = fetcher->ItemsBegin(); + for (pkgAcquire::ItemIterator I = fetcher->ItemsBegin(); I != fetcher->ItemsEnd(); I++) { PyObject *Obj; @@ -149,11 +149,11 @@ static PyObject *AcquireAttr(PyObject *Self,char *Name) return List; } // some constants - if(strcmp("ResultContinue",Name) == 0) + if(strcmp("ResultContinue",Name) == 0) return Py_BuildValue("i", pkgAcquire::Continue); - if(strcmp("ResultFailed",Name) == 0) + if(strcmp("ResultFailed",Name) == 0) return Py_BuildValue("i", pkgAcquire::Failed); - if(strcmp("ResultCancelled",Name) == 0) + if(strcmp("ResultCancelled",Name) == 0) return Py_BuildValue("i", pkgAcquire::Cancelled); return Py_FindMethod(PkgAcquireMethods,Self,Name); @@ -201,7 +201,7 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) CppPyObject<pkgAcquire*> *FetcherObj = CppPyObject_NEW<pkgAcquire*>(&PkgAcquireType, fetcher); - + return FetcherObj; } @@ -253,8 +253,8 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) NULL}; if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|siss", kwlist, - &PkgAcquireType, &pyfetcher, &uri, &md5, - &size, &descr, &shortDescr) == 0) + &PkgAcquireType, &pyfetcher, &uri, &md5, + &size, &descr, &shortDescr) == 0) return 0; pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyfetcher); diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..95483ee0 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -5,10 +5,10 @@ apt_intmodule - Top level for the python module. Create the internal structures for the module in the interpriter. - + Note, this module shares state (particularly global config) with the apt_pkg module. - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -17,7 +17,7 @@ #include <apt-pkg/debfile.h> #include <apt-pkg/error.h> - + #include <sys/stat.h> #include <unistd.h> #include <Python.h> @@ -37,7 +37,7 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args) PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Member) == 0) return 0; - + // Subscope makes sure any clean up errors are properly handled. PyObject *Res = 0; { @@ -46,13 +46,13 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args) debDebFile Deb(Fd); if (_error->PendingError() == true) return HandleErrors(); - + debDebFile::MemControlExtract Extract(Member); if (Extract.Read(Deb) == false) return HandleErrors(); - + // Build the return result - + if (Extract.Control == 0) { Py_INCREF(Py_None); @@ -61,7 +61,7 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args) else Res = PyString_FromStringAndSize(Extract.Control,Extract.Length+2); } - + return HandleErrors(Res); } /*}}}*/ @@ -77,11 +77,11 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; - + // Subscope makes sure any clean up errors are properly handled. bool res = false; { - if(Rootdir != NULL) + if(Rootdir != NULL) { chdir(Rootdir); } @@ -98,7 +98,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) if (res == false) return HandleErrors(); - } + } return HandleErrors(Py_BuildValue("b",res)); } /*}}}*/ @@ -113,13 +113,13 @@ static PyObject *arCheckMember(PyObject *Self,PyObject *Args) PyObject *File; if (PyArg_ParseTuple(Args,"O!s",&PyFile_Type,&File,&Member) == 0) return 0; - + // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); ARArchive AR(Fd); if (_error->PendingError() == true) return HandleErrors(Py_BuildValue("b",res)); - + if(AR.FindMember(Member) != 0) res = true; diff --git a/python/apt_instmodule.h b/python/apt_instmodule.h index c8d09736..45ba5f85 100644 --- a/python/apt_instmodule.h +++ b/python/apt_instmodule.h @@ -4,7 +4,7 @@ /* ###################################################################### Prototypes for the module - + ##################################################################### */ /*}}}*/ #ifndef APT_INSTMODULE_H diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index ae1cf7be..bbb21523 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -5,7 +5,7 @@ apt_pkgmodule - Top level for the python module. Create the internal structures for the module in the interpriter. - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -22,7 +22,7 @@ #include <apt-pkg/sha256.h> #include <apt-pkg/init.h> #include <apt-pkg/pkgsystem.h> - + #include <sys/stat.h> #include <unistd.h> #include <Python.h> @@ -46,16 +46,16 @@ static PyObject *VersionCompare(PyObject *Self,PyObject *Args) char *B; int LenA; int LenB; - + if (PyArg_ParseTuple(Args,"s#s#",&A,&LenA,&B,&LenB) == 0) return 0; - + if (_system == 0) { PyErr_SetString(PyExc_ValueError,"_system not initialized"); return 0; } - + return Py_BuildValue("i",_system->VS->DoCmpVersion(A,A+LenA,B,B+LenB)); } @@ -66,7 +66,7 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args) char *B; char *OpStr; unsigned int Op = 0; - + if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) return 0; if (*debListParser::ConvertRelation(OpStr,Op) != 0) @@ -80,7 +80,7 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_ValueError,"_system not initialized"); return 0; } - + return Py_BuildValue("i",_system->VS->CheckDep(A,Op,B)); // return Py_BuildValue("i",pkgCheckDep(B,A,Op)); } @@ -94,7 +94,7 @@ static PyObject *UpstreamVersion(PyObject *Self,PyObject *Args) return CppPyString(_system->VS->UpstreamVersion(Ver)); } -static char *doc_ParseDepends = +static char *doc_ParseDepends = "ParseDepends(s) -> list of tuples\n" "\n" "The resulting tuples are (Pkg,Ver,Operation). Each anded dependency is a\n" @@ -107,11 +107,11 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, string Package; string Version; unsigned int Op; - + const char *Start; const char *Stop; int Len; - + if (PyArg_ParseTuple(Args,"s#",&Start,&Len) == 0) return 0; Stop = Start + Len; @@ -121,7 +121,7 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, { if (Start == Stop) break; - + Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op, ParseArchFlags); if (Start == 0) @@ -130,10 +130,10 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, Py_DECREF(List); return 0; } - + if (LastRow == 0) LastRow = PyList_New(0); - + if (Package.empty() == false) { PyObject *Obj; @@ -142,7 +142,7 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, pkgCache::CompTypeDeb(Op))); Py_DECREF(Obj); } - + // Group ORd deps into a single row.. if ((Op & pkgCache::Dep::Or) != pkgCache::Dep::Or) { @@ -150,7 +150,7 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, PyList_Append(List,LastRow); Py_DECREF(LastRow); LastRow = 0; - } + } } return List; } @@ -171,15 +171,15 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) PyObject *Obj; if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; - + // Digest of a string. if (PyString_Check(Obj) != 0) { MD5Summation Sum; Sum.Add(PyString_AsString(Obj)); return CppPyString(Sum.Result().Value()); - } - + } + // Digest of a file if (PyFile_Check(Obj) != 0) { @@ -192,10 +192,10 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) PyErr_SetFromErrno(PyExc_SystemError); return 0; } - + return CppPyString(Sum.Result().Value()); } - + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); return 0; } @@ -208,15 +208,15 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) PyObject *Obj; if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; - + // Digest of a string. if (PyString_Check(Obj) != 0) { SHA1Summation Sum; Sum.Add(PyString_AsString(Obj)); return CppPyString(Sum.Result().Value()); - } - + } + // Digest of a file if (PyFile_Check(Obj) != 0) { @@ -229,10 +229,10 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) PyErr_SetFromErrno(PyExc_SystemError); return 0; } - + return CppPyString(Sum.Result().Value()); } - + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); return 0; } @@ -245,15 +245,15 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) PyObject *Obj; if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; - + // Digest of a string. if (PyString_Check(Obj) != 0) { SHA256Summation Sum; Sum.Add(PyString_AsString(Obj)); return CppPyString(Sum.Result().Value()); - } - + } + // Digest of a file if (PyFile_Check(Obj) != 0) { @@ -266,27 +266,27 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) PyErr_SetFromErrno(PyExc_SystemError); return 0; } - + return CppPyString(Sum.Result().Value()); } - + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); return 0; } /*}}}*/ // init - 3 init functions /*{{{*/ // --------------------------------------------------------------------- -static char *doc_Init = +static char *doc_Init = "init() -> None\n" "Legacy. Do InitConfig then parse the command line then do InitSystem\n"; static PyObject *Init(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - - pkgInitConfig(*_config); + + pkgInitConfig(*_config); pkgInitSystem(*_config,_system); - + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -298,9 +298,9 @@ static PyObject *InitConfig(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - - pkgInitConfig(*_config); - + + pkgInitConfig(*_config); + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -312,9 +312,9 @@ static PyObject *InitSystem(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + pkgInitSystem(*_config,_system); - + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -322,7 +322,7 @@ static PyObject *InitSystem(PyObject *Self,PyObject *Args) // fileutils.cc: GetLock /*{{{*/ // --------------------------------------------------------------------- -static char *doc_GetLock = +static char *doc_GetLock = "GetLock(string) -> int\n" "This will create an empty file of the given name and lock it. Once this" " is done all other calls to GetLock in any other process will fail with" @@ -334,7 +334,7 @@ static PyObject *GetLock(PyObject *Self,PyObject *Args) char errors = false; if (PyArg_ParseTuple(Args,"s|b",&file,&errors) == 0) return 0; - + int fd = GetLock(file, errors); return HandleErrors(Py_BuildValue("i", fd)); @@ -347,9 +347,9 @@ static PyObject *PkgSystemLock(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + bool res = _system->Lock(); - + Py_INCREF(Py_None); return HandleErrors(Py_BuildValue("b", res)); } @@ -361,9 +361,9 @@ static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + bool res = _system->UnLock(); - + Py_INCREF(Py_None); return HandleErrors(Py_BuildValue("b", res)); } @@ -373,7 +373,7 @@ static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args) // initapt_pkg - Core Module Initialization /*{{{*/ // --------------------------------------------------------------------- /* */ -static PyMethodDef methods[] = +static PyMethodDef methods[] = { // Constructors {"newConfiguration",newConfiguration,METH_VARARGS,doc_newConfiguration}, @@ -395,16 +395,16 @@ static PyMethodDef methods[] = {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, - + // Versioning {"VersionCompare",VersionCompare,METH_VARARGS,doc_VersionCompare}, {"CheckDep",CheckDep,METH_VARARGS,doc_CheckDep}, {"UpstreamVersion",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion}, - + // Depends {"ParseDepends",ParseDepends,METH_VARARGS,doc_ParseDepends}, {"ParseSrcDepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, - + // Stuff {"md5sum",md5sum,METH_VARARGS,doc_md5sum}, {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, @@ -464,13 +464,13 @@ extern "C" void initapt_pkg() { PyObject *Module = Py_InitModule("apt_pkg",methods); PyObject *Dict = PyModule_GetDict(Module); - + // Global variable linked to the global configuration class CppPyObject<Configuration *> *Config = CppPyObject_NEW<Configuration *>(&ConfigurationPtrType); Config->Object = _config; PyDict_SetItemString(Dict,"Config",Config); Py_DECREF(Config); - + // Tag file constants PyObject *Obj; PyDict_SetItemString(Dict,"RewritePackageOrder", @@ -479,7 +479,7 @@ extern "C" void initapt_pkg() PyDict_SetItemString(Dict,"RewriteSourceOrder", Obj = CharCharToList(TFRewriteSourceOrder)); Py_DECREF(Obj); - + // Version.. AddStr(Dict,"Version",pkgVersion); AddStr(Dict,"LibVersion",pkgLibVersion); @@ -514,4 +514,4 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); } /*}}}*/ - + diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index f59c8ca0..fb407307 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -4,7 +4,7 @@ /* ###################################################################### Prototypes for the module - + ##################################################################### */ /*}}}*/ #ifndef APT_PKGMODULE_H @@ -49,7 +49,7 @@ PyObject *StrStringToBool(PyObject *self,PyObject *Args); PyObject *StrTimeRFC1123(PyObject *self,PyObject *Args); PyObject *StrStrToTime(PyObject *self,PyObject *Args); PyObject *StrCheckDomainList(PyObject *Self,PyObject *Args); - + // Cache Stuff extern PyTypeObject PkgCacheType; extern PyTypeObject PkgCacheFileType; diff --git a/python/cache.cc b/python/cache.cc index 36e49710..8accd4a7 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -32,7 +32,7 @@ struct PkgListStruct { pkgCache::PkgIterator Iter; unsigned long LastIndex; - + PkgListStruct(pkgCache::PkgIterator const &I) : Iter(I), LastIndex(0) {} PkgListStruct() {abort();}; // G++ Bug.. }; @@ -43,7 +43,7 @@ struct RDepListStruct pkgCache::DepIterator Start; unsigned long LastIndex; unsigned long Len; - + RDepListStruct(pkgCache::DepIterator const &I) : Iter(I), Start(I), LastIndex(0) { @@ -68,14 +68,14 @@ static PyObject *CreateProvides(PyObject *Owner,pkgCache::PrvIterator I) Ver); PyList_Append(List,Obj); Py_DECREF(Obj); - } + } return List; } // Cache Class /*{{{*/ // --------------------------------------------------------------------- static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) -{ +{ PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); @@ -94,7 +94,7 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) } static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) -{ +{ PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); Cache->Close(); @@ -104,7 +104,7 @@ static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) } static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) -{ +{ PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); @@ -134,7 +134,7 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) } -static PyMethodDef PkgCacheMethods[] = +static PyMethodDef PkgCacheMethods[] = { {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, {"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, @@ -145,7 +145,7 @@ static PyMethodDef PkgCacheMethods[] = static PyObject *CacheAttr(PyObject *Self,char *Name) { pkgCache *Cache = GetCpp<pkgCache *>(Self); - + if (strcmp("Packages",Name) == 0) return CppOwnedPyObject_NEW<PkgListStruct>(Self,&PkgListType,Cache->PkgBegin()); else if (strcmp("PackageCount",Name) == 0) @@ -169,7 +169,7 @@ static PyObject *CacheAttr(PyObject *Self,char *Name) Obj = CppOwnedPyObject_NEW<pkgCache::PkgFileIterator>(Self,&PackageFileType,I); PyList_Append(List,Obj); Py_DECREF(Obj); - } + } return List; } @@ -180,15 +180,15 @@ static PyObject *CacheAttr(PyObject *Self,char *Name) static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) { pkgCache *Cache = GetCpp<pkgCache *>(Self); - + if (PyString_Check(Arg) == 0) { PyErr_SetNone(PyExc_TypeError); return 0; } - + // Search for the package - const char *Name = PyString_AsString(Arg); + const char *Name = PyString_AsString(Arg); pkgCache::PkgIterator Pkg = Cache->FindPkg(Name); if (Pkg.end() == true) { @@ -274,7 +274,7 @@ static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) Self.LastIndex = 0; Self.Iter = Self.Iter.Cache()->PkgBegin(); } - + while ((unsigned)Index > Self.LastIndex) { Self.LastIndex++; @@ -285,12 +285,12 @@ static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) return 0; } } - + return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(GetOwner<PkgListStruct>(iSelf),&PackageType, Self.Iter); } -static PySequenceMethods PkgListSeq = +static PySequenceMethods PkgListSeq = { PkgListLen, 0, // concat @@ -298,9 +298,9 @@ static PySequenceMethods PkgListSeq = PkgListItem, 0, // slice 0, // assign item - 0 // assign slice + 0 // assign slice }; - + PyTypeObject PkgListType = { PyObject_HEAD_INIT(&PyType_Type) @@ -320,7 +320,7 @@ PyTypeObject PkgListType = 0, // tp_as_mapping 0, // tp_hash }; - + /*}}}*/ // Package Class /*{{{*/ // --------------------------------------------------------------------- @@ -328,7 +328,7 @@ static PyObject *PackageAttr(PyObject *Self,char *Name) { pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); PyObject *Owner = GetOwner<pkgCache::PkgIterator>(Self); - + if (strcmp("Name",Name) == 0) return PyString_FromString(Pkg.Name()); else if (strcmp("VersionList",Name) == 0) @@ -340,7 +340,7 @@ static PyObject *PackageAttr(PyObject *Self,char *Name) Obj = CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType,I); PyList_Append(List,Obj); Py_DECREF(Obj); - } + } return List; } else if (strcmp("CurrentVer",Name) == 0) @@ -350,7 +350,7 @@ static PyObject *PackageAttr(PyObject *Self,char *Name) Py_INCREF(Py_None); return Py_None; } - + return CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType, Pkg.CurrentVer()); } @@ -375,7 +375,7 @@ static PyObject *PackageAttr(PyObject *Self,char *Name) return Py_BuildValue("i",(Pkg->Flags & pkgCache::Flag::Essential) != 0); else if (strcmp("Important",Name) == 0) return Py_BuildValue("i",(Pkg->Flags & pkgCache::Flag::Important) != 0); - + PyErr_SetString(PyExc_AttributeError,Name); return 0; } @@ -383,7 +383,7 @@ static PyObject *PackageAttr(PyObject *Self,char *Name) static PyObject *PackageRepr(PyObject *Self) { pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); - + char S[300]; snprintf(S,sizeof(S),"<pkgCache::Package object: Name:'%s' Section: '%s'" " ID:%u Flags:0x%lX>", @@ -417,7 +417,7 @@ static PyObject *DescriptionAttr(PyObject *Self,char *Name) { pkgCache::DescIterator &Desc = GetCpp<pkgCache::DescIterator>(Self); PyObject *Owner = GetOwner<pkgCache::DescIterator>(Self); - + if (strcmp("LanguageCode",Name) == 0) return PyString_FromString(Desc.LanguageCode()); else if (strcmp("md5",Name) == 0) @@ -425,8 +425,8 @@ static PyObject *DescriptionAttr(PyObject *Self,char *Name) else if (strcmp("FileList",Name) == 0) { /* The second value in the tuple is the index of the VF item. If the - user wants to request a lookup then that number will be used. - Maybe later it can become an object. */ + user wants to request a lookup then that number will be used. + Maybe later it can become an object. */ PyObject *List = PyList_New(0); for (pkgCache::DescFileIterator I = Desc.FileList(); I.end() == false; I++) { @@ -436,7 +436,7 @@ static PyObject *DescriptionAttr(PyObject *Self,char *Name) Obj = Py_BuildValue("Nl",DescFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); - } + } return List; } PyErr_SetString(PyExc_AttributeError,Name); @@ -446,7 +446,7 @@ static PyObject *DescriptionAttr(PyObject *Self,char *Name) static PyObject *DescriptionRepr(PyObject *Self) { pkgCache::DescIterator &Desc = GetCpp<pkgCache::DescIterator>(Self); - + char S[300]; snprintf(S,sizeof(S), "<pkgCache::Description object: language_code:'%s' md5:'%s' ", @@ -477,14 +477,14 @@ PyTypeObject DescriptionType = // Version Class /*{{{*/ // --------------------------------------------------------------------- -/* This is the simple depends result, the elements are split like +/* This is the simple depends result, the elements are split like ParseDepends does */ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, bool AsObj) { PyObject *Dict = PyDict_New(); PyObject *LastDep = 0; - unsigned LastDepType = 0; + unsigned LastDepType = 0; for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false;) { pkgCache::DepIterator Start; @@ -498,7 +498,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, // it sucks to have it here duplicated, but we get it // translated from libapt and that is certainly not what // we want in a programing interface - const char *Types[] = + const char *Types[] = { "", "Depends","PreDepends","Suggests", "Recommends","Conflicts","Replaces", @@ -512,10 +512,10 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, LastDep = PyList_New(0); PyDict_SetItem(Dict,Dep,LastDep); Py_DECREF(LastDep); - } + } Py_DECREF(Dep); } - + PyObject *OrGroup = PyList_New(0); while (1) { @@ -535,19 +535,19 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, Start.TargetPkg().Name(), Start.TargetVer(), Start.CompType()); - } + } PyList_Append(OrGroup,Obj); Py_DECREF(Obj); - + if (Start == End) break; Start++; } - + PyList_Append(LastDep,OrGroup); Py_DECREF(OrGroup); - } - + } + return Dict; } @@ -555,7 +555,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) { pkgCache::VerIterator &Ver = GetCpp<pkgCache::VerIterator>(Self); PyObject *Owner = GetOwner<pkgCache::VerIterator>(Self); - + if (strcmp("VerStr",Name) == 0) return PyString_FromString(Ver.VerStr()); else if (strcmp("Section",Name) == 0) @@ -565,8 +565,8 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) else if (strcmp("FileList",Name) == 0) { /* The second value in the tuple is the index of the VF item. If the - user wants to request a lookup then that number will be used. - Maybe later it can become an object. */ + user wants to request a lookup then that number will be used. + Maybe later it can become an object. */ PyObject *List = PyList_New(0); for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; I++) { @@ -576,7 +576,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) Obj = Py_BuildValue("Nl",PkgFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); - } + } return List; } else if (strcmp("DependsListStr",Name) == 0) @@ -629,7 +629,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) static PyObject *VersionRepr(PyObject *Self) { pkgCache::VerIterator &Ver = GetCpp<pkgCache::VerIterator>(Self); - + char S[300]; snprintf(S,sizeof(S),"<pkgCache::Version object: Pkg:'%s' Ver:'%s' " "Section:'%s' Arch:'%s' Size:%lu ISize:%lu Hash:%u " @@ -659,16 +659,16 @@ PyTypeObject VersionType = 0, // tp_as_mapping 0, // tp_hash }; - + /*}}}*/ - + // PackageFile Class /*{{{*/ // --------------------------------------------------------------------- static PyObject *PackageFileAttr(PyObject *Self,char *Name) { pkgCache::PkgFileIterator &File = GetCpp<pkgCache::PkgFileIterator>(Self); // PyObject *Owner = GetOwner<pkgCache::PkgFileIterator>(Self); - + if (strcmp("FileName",Name) == 0) return Safe_FromString(File.FileName()); else if (strcmp("Archive",Name) == 0) @@ -695,7 +695,7 @@ static PyObject *PackageFileAttr(PyObject *Self,char *Name) return Py_BuildValue("i",(File->Flags & pkgCache::Flag::NotAutomatic) != 0); else if (strcmp("ID",Name) == 0) return Py_BuildValue("i",File->ID); - + PyErr_SetString(PyExc_AttributeError,Name); return 0; } @@ -703,7 +703,7 @@ static PyObject *PackageFileAttr(PyObject *Self,char *Name) static PyObject *PackageFileRepr(PyObject *Self) { pkgCache::PkgFileIterator &File = GetCpp<pkgCache::PkgFileIterator>(Self); - + char S[300]; snprintf(S,sizeof(S),"<pkgCache::PackageFile object: " "File:'%s' a=%s,c=%s,v=%s,o=%s,l=%s " @@ -734,7 +734,7 @@ PyTypeObject PackageFileType = 0, // tp_as_mapping 0, // tp_hash }; - + // depends class static PyObject *DependencyRepr(PyObject *Self) @@ -754,7 +754,7 @@ static PyObject *DepSmartTargetPkg(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self); PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self); @@ -764,7 +764,7 @@ static PyObject *DepSmartTargetPkg(PyObject *Self,PyObject *Args) Py_INCREF(Py_None); return Py_None; } - + return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,P); } @@ -772,7 +772,7 @@ static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self); PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self); @@ -789,7 +789,7 @@ static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) return List; } -static PyMethodDef DependencyMethods[] = +static PyMethodDef DependencyMethods[] = { {"SmartTargetPkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"}, {"AllTargets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"}, @@ -798,18 +798,18 @@ static PyMethodDef DependencyMethods[] = // Dependency Class /*{{{*/ // --------------------------------------------------------------------- - + static PyObject *DependencyAttr(PyObject *Self,char *Name) { pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self); PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self); - + if (strcmp("TargetVer",Name) == 0) { if (Dep->Version == 0) return PyString_FromString(""); return PyString_FromString(Dep.TargetVer()); - } + } else if (strcmp("TargetPkg",Name) == 0) return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType, Dep.TargetPkg()); @@ -824,7 +824,7 @@ static PyObject *DependencyAttr(PyObject *Self,char *Name) return PyString_FromString(Dep.DepType()); else if (strcmp("ID",Name) == 0) return Py_BuildValue("i",Dep->ID); - + return Py_FindMethod(DependencyMethods,Self,Name); } @@ -847,7 +847,7 @@ PyTypeObject DependencyType = 0, // tp_as_mapping 0, // tp_hash }; - + /*}}}*/ /*}}}*/ // Reverse Dependency List Class /*{{{*/ @@ -865,13 +865,13 @@ static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) PyErr_SetNone(PyExc_IndexError); return 0; } - + if ((unsigned)Index < Self.LastIndex) { Self.LastIndex = 0; Self.Iter = Self.Start; } - + while ((unsigned)Index > Self.LastIndex) { Self.LastIndex++; @@ -882,12 +882,12 @@ static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) return 0; } } - + return CppOwnedPyObject_NEW<pkgCache::DepIterator>(GetOwner<RDepListStruct>(iSelf), &DependencyType,Self.Iter); } -static PySequenceMethods RDepListSeq = +static PySequenceMethods RDepListSeq = { RDepListLen, 0, // concat @@ -895,9 +895,9 @@ static PySequenceMethods RDepListSeq = RDepListItem, 0, // slice 0, // assign item - 0 // assign slice + 0 // assign slice }; - + PyTypeObject RDepListType = { PyObject_HEAD_INIT(&PyType_Type) @@ -917,7 +917,7 @@ PyTypeObject RDepListType = 0, // tp_as_mapping 0, // tp_hash }; - + /*}}}*/ @@ -943,7 +943,7 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) CppOwnedPyObject<pkgCacheFile*> *CacheFileObj = CppOwnedPyObject_NEW<pkgCacheFile*>(0,&PkgCacheFileType, Cache); - + CppOwnedPyObject<pkgCache *> *CacheObj = CppOwnedPyObject_NEW<pkgCache *>(CacheFileObj,&PkgCacheType, (pkgCache *)(*Cache)); diff --git a/python/cdrom.cc b/python/cdrom.cc index aca1be26..0831548e 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -19,7 +19,7 @@ struct PkgCdromStruct }; static PyObject *PkgCdromAdd(PyObject *Self,PyObject *Args) -{ +{ PkgCdromStruct &Struct = GetCpp<PkgCdromStruct>(Self); PyObject *pyCdromProgressInst = 0; @@ -32,11 +32,11 @@ static PyObject *PkgCdromAdd(PyObject *Self,PyObject *Args) bool res = Struct.cdrom.Add(&progress); - return HandleErrors(Py_BuildValue("b", res)); + return HandleErrors(Py_BuildValue("b", res)); } static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args) -{ +{ PkgCdromStruct &Struct = GetCpp<PkgCdromStruct>(Self); PyObject *pyCdromProgressInst = 0; @@ -52,11 +52,11 @@ static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args) PyObject *result = Py_BuildValue("(bs)", res, ident.c_str()); - return HandleErrors(result); + return HandleErrors(result); } -static PyMethodDef PkgCdromMethods[] = +static PyMethodDef PkgCdromMethods[] = { {"Add",PkgCdromAdd,METH_VARARGS,"Add a cdrom"}, {"Ident",PkgCdromIdent,METH_VARARGS,"Ident a cdrom"}, @@ -100,7 +100,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args) CppOwnedPyObject<pkgCdrom> *CdromObj = CppOwnedPyObject_NEW<pkgCdrom>(0,&PkgCdromType, *cdrom); - + return CdromObj; } diff --git a/python/configuration.cc b/python/configuration.cc index 55eac1bf..f52c3c97 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -10,10 +10,10 @@ ConfigurationPtr - A pointer to a configuration instance, used only for the global instance (_config) ConfigurationSub - A subtree - has a reference to its owner. - + The wrapping is mostly 1:1 with the C++ code, but there are additions to - wrap the linked tree walking into nice flat sequence walking. - + wrap the linked tree walking into nice flat sequence walking. + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -113,7 +113,7 @@ static PyObject *CnfSet(PyObject *Self,PyObject *Args) char *Value = 0; if (PyArg_ParseTuple(Args,"ss",&Name,&Value) == 0) return 0; - + GetSelf(Self).Set(Name,Value); Py_INCREF(Py_None); return Py_None; @@ -134,9 +134,9 @@ static PyObject *CnfClear(PyObject *Self,PyObject *Args) char *Name = 0; if (PyArg_ParseTuple(Args,"s",&Name) == 0) return 0; - + GetSelf(Self).Clear(Name); - + Py_INCREF(Py_None); return Py_None; } @@ -170,7 +170,7 @@ static PyObject *CnfList(PyObject *Self,PyObject *Args) char *RootName = 0; if (PyArg_ParseTuple(Args,"|s",&RootName) == 0) return 0; - + // Convert the whole configuration space into a list PyObject *List = PyList_New(0); const Configuration::Item *Top = GetSelf(Self).Tree(RootName); @@ -180,10 +180,10 @@ static PyObject *CnfList(PyObject *Self,PyObject *Args) for (; Top != 0; Top = Top->Next) { PyObject *Obj; - PyList_Append(List,Obj = CppPyString(Top->FullTag(Root))); + PyList_Append(List,Obj = CppPyString(Top->FullTag(Root))); Py_DECREF(Obj); } - + return List; } @@ -195,7 +195,7 @@ static PyObject *CnfValueList(PyObject *Self,PyObject *Args) char *RootName = 0; if (PyArg_ParseTuple(Args,"|s",&RootName) == 0) return 0; - + // Convert the whole configuration space into a list PyObject *List = PyList_New(0); const Configuration::Item *Top = GetSelf(Self).Tree(RootName); @@ -207,7 +207,7 @@ static PyObject *CnfValueList(PyObject *Self,PyObject *Args) PyList_Append(List,Obj = CppPyString(Top->Value)); Py_DECREF(Obj); } - + return List; } @@ -216,7 +216,7 @@ static PyObject *CnfMyTag(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + const Configuration::Item *Top = GetSelf(Self).Tree(0); if (Top == 0) return Py_BuildValue("s",""); @@ -230,7 +230,7 @@ static PyObject *CnfKeys(PyObject *Self,PyObject *Args) char *RootName = 0; if (PyArg_ParseTuple(Args,"|s",&RootName) == 0) return 0; - + // Convert the whole configuration space into a list PyObject *List = PyList_New(0); const Configuration::Item *Top = GetSelf(Self).Tree(RootName); @@ -241,17 +241,17 @@ static PyObject *CnfKeys(PyObject *Self,PyObject *Args) if (Top != 0) Root = GetSelf(Self).Tree(0)->Parent; for (; Top != 0;) - { + { PyObject *Obj; PyList_Append(List,Obj = CppPyString(Top->FullTag(Root))); Py_DECREF(Obj); - + if (Top->Child != 0) { Top = Top->Child; continue; } - + while (Top != 0 && Top->Next == 0 && Top != Root && Top->Parent != Stop) Top = Top->Parent; @@ -270,13 +270,13 @@ static PyObject *CnfMap(PyObject *Self,PyObject *Arg) PyErr_SetNone(PyExc_TypeError); return 0; } - + if (GetSelf(Self).Exists(PyString_AsString(Arg)) == false) - { + { PyErr_SetString(PyExc_KeyError,PyString_AsString(Arg)); return 0; } - + return CppPyString(GetSelf(Self).Find(PyString_AsString(Arg))); } @@ -288,7 +288,7 @@ static int CnfMapSet(PyObject *Self,PyObject *Arg,PyObject *Val) PyErr_SetNone(PyExc_TypeError); return -1; } - + GetSelf(Self).Set(PyString_AsString(Arg),PyString_AsString(Val)); return 0; } @@ -305,10 +305,10 @@ PyObject *LoadConfig(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration."); return 0; } - + if (ReadConfigFile(GetSelf(Self),Name,false) == false) return HandleErrors(); - + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -323,10 +323,10 @@ PyObject *LoadConfigISC(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration."); return 0; } - + if (ReadConfigFile(GetSelf(Self),Name,true) == false) return HandleErrors(); - + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -336,7 +336,7 @@ PyObject *LoadConfigISC(PyObject *Self,PyObject *Args) // --------------------------------------------------------------------- char *doc_ParseCommandLine = "ParseCommandLine(Configuration,ListOfOptions,List-argv) -> List\n" -"\n" +"\n" "This function is like getopt except it manipulates a configuration space.\n" "output is a list of non-option arguments (filenames, etc).\n" "ListOfOptions is a list of tuples of the form:\n" @@ -355,13 +355,13 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration."); return 0; } - + // Convert the option list int Length = PySequence_Length(POList); CommandLine::Args *OList = new CommandLine::Args[Length+1]; OList[Length].ShortOpt = 0; OList[Length].LongOpt = 0; - + for (int I = 0; I != Length; I++) { char *Type = 0; @@ -373,7 +373,7 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) return 0; } OList[I].Flags = 0; - + // Convert the type over to flags.. if (Type != 0) { @@ -389,7 +389,7 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) OList[I].Flags = CommandLine::ConfigFile; else if (strcasecmp(Type,"ArbItem") == 0) OList[I].Flags = CommandLine::ArbItem; - } + } } // Convert the argument list into a char ** @@ -399,7 +399,7 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) delete [] OList; return 0; } - + // Do the command line processing PyObject *List = 0; { @@ -410,16 +410,16 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) delete [] OList; return HandleErrors(); } - + // Convert the file listing into a python sequence for (Length = 0; CmdL.FileList[Length] != 0; Length++); - List = PyList_New(Length); + List = PyList_New(Length); for (int I = 0; CmdL.FileList[I] != 0; I++) { PyList_SetItem(List,I,PyString_FromString(CmdL.FileList[I])); - } + } } - + delete [] argv; delete [] OList; return HandleErrors(List); @@ -427,7 +427,7 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) /*}}}*/ // Method table for the Configuration object -static PyMethodDef CnfMethods[] = +static PyMethodDef CnfMethods[] = { // Query {"Find",CnfFind,METH_VARARGS,doc_Find}, @@ -444,7 +444,7 @@ static PyMethodDef CnfMethods[] = {"ValueList",CnfValueList,METH_VARARGS,doc_ValueList}, {"MyTag",CnfMyTag,METH_VARARGS,doc_MyTag}, {"Clear",CnfClear,METH_VARARGS,doc_Clear}, - + // Python Special {"keys",CnfKeys,METH_VARARGS,doc_Keys}, {"has_key",CnfExists,METH_VARARGS,doc_Exists}, @@ -462,7 +462,7 @@ static PyObject *CnfGetAttr(PyObject *Self,char *Name) // Type for a Normal Configuration object static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; -PyTypeObject ConfigurationType = +PyTypeObject ConfigurationType = { PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size @@ -481,8 +481,8 @@ PyTypeObject ConfigurationType = &ConfigurationMap, // tp_as_mapping 0, // tp_hash }; - -PyTypeObject ConfigurationPtrType = + +PyTypeObject ConfigurationPtrType = { PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size @@ -501,7 +501,7 @@ PyTypeObject ConfigurationPtrType = &ConfigurationMap, // tp_as_mapping 0, // tp_hash }; - + PyTypeObject ConfigurationSubType = { PyObject_HEAD_INIT(&PyType_Type) @@ -521,4 +521,4 @@ PyTypeObject ConfigurationSubType = &ConfigurationMap, // tp_as_mapping 0, // tp_hash }; - + diff --git a/python/depcache.cc b/python/depcache.cc index 5664a6d8..505cfc9d 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -39,7 +39,7 @@ static PyObject *PkgDepCacheInit(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *pyCallbackInst = 0; @@ -57,18 +57,18 @@ static PyObject *PkgDepCacheInit(PyObject *Self,PyObject *Args) pkgApplyStatus(*depcache); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) -{ +{ PyObject *result; pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *pyInstallProgressInst = 0; PyObject *pyFetchProgressInst = 0; - if (PyArg_ParseTuple(Args, "OO", + if (PyArg_ParseTuple(Args, "OO", &pyFetchProgressInst, &pyInstallProgressInst) == 0) { return 0; } @@ -78,7 +78,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) if (_error->PendingError() == true) return HandleErrors(); } - + pkgRecords Recs(*depcache); if (_error->PendingError() == true) HandleErrors(Py_None); @@ -108,22 +108,22 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) while (1) { bool Transient = false; - + if (Fetcher.Run() == pkgAcquire::Failed) return false; - + // Print out errors bool Failed = false; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) { - - //std::cout << "looking at: " << (*I)->DestFile + + //std::cout << "looking at: " << (*I)->DestFile // << " status: " << (*I)->Status << std::endl; if ((*I)->Status == pkgAcquire::Item::StatDone && (*I)->Complete == true) continue; - + if ((*I)->Status == pkgAcquire::Item::StatIdle) { //std::cout << "transient failure" << std::endl; @@ -146,7 +146,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) Py_INCREF(Py_None); return HandleErrors(Py_None); } - + // Try to deal with missing package files if (Failed == true && PM->FixMissing() == false) { @@ -156,9 +156,9 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } - // fail if something else went wrong - //FIXME: make this more flexible, e.g. with a failedDl handler - if(Failed) + // fail if something else went wrong + //FIXME: make this more flexible, e.g. with a failedDl handler + if(Failed) return Py_BuildValue("b", false); _system->UnLock(true); @@ -174,25 +174,25 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) } //std::cout << "looping again, install unfinished" << std::endl; - + // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); if (PM->GetArchives(&Fetcher,&List,&Recs) == false) { return Py_BuildValue("b", false); } _system->Lock(); - } - + } + return HandleErrors(Py_None); } static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; PyObject *VersionObj; if (PyArg_ParseTuple(Args,"O!O!", - &PackageType, &PackageObj, + &PackageType, &PackageObj, &VersionType, &VersionObj) == 0) return 0; @@ -202,12 +202,12 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("b",false)); } depcache->SetCandidateVersion(I); - + return HandleErrors(Py_BuildValue("b",true)); } static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; PyObject *CandidateObj; @@ -226,7 +226,7 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) } static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args) -{ +{ bool res; pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); @@ -242,11 +242,11 @@ static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args) Py_END_ALLOW_THREADS Py_INCREF(Py_None); - return HandleErrors(Py_BuildValue("b",res)); + return HandleErrors(Py_BuildValue("b",res)); } static PyObject *PkgDepCacheMinimizeUpgrade(PyObject *Self,PyObject *Args) -{ +{ bool res; pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); @@ -258,33 +258,33 @@ static PyObject *PkgDepCacheMinimizeUpgrade(PyObject *Self,PyObject *Args) Py_END_ALLOW_THREADS Py_INCREF(Py_None); - return HandleErrors(Py_BuildValue("b",res)); + return HandleErrors(Py_BuildValue("b",res)); } static PyObject *PkgDepCacheReadPinFile(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); - + char *file=NULL; if (PyArg_ParseTuple(Args,"|s",&file) == 0) return 0; - if(file == NULL) + if(file == NULL) ReadPinFile((pkgPolicy&)depcache->GetPolicy()); else ReadPinFile((pkgPolicy&)depcache->GetPolicy(), file); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheFixBroken(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); - + bool res=true; if (PyArg_ParseTuple(Args,"") == 0) return 0; @@ -292,12 +292,12 @@ static PyObject *PkgDepCacheFixBroken(PyObject *Self,PyObject *Args) res &=pkgFixBroken(*depcache); res &=pkgMinimizeUpgrade(*depcache); - return HandleErrors(Py_BuildValue("b",res)); + return HandleErrors(Py_BuildValue("b",res)); } static PyObject *PkgDepCacheMarkKeep(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache*>(Self); PyObject *PackageObj; @@ -308,11 +308,11 @@ static PyObject *PkgDepCacheMarkKeep(PyObject *Self,PyObject *Args) depcache->MarkKeep(Pkg); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheSetReInstall(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache*>(Self); PyObject *PackageObj; @@ -324,12 +324,12 @@ static PyObject *PkgDepCacheSetReInstall(PyObject *Self,PyObject *Args) depcache->SetReInstall(Pkg,value); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheMarkDelete(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -341,18 +341,18 @@ static PyObject *PkgDepCacheMarkDelete(PyObject *Self,PyObject *Args) depcache->MarkDelete(Pkg,purge); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; char autoInst=1; char fromUser=1; - if (PyArg_ParseTuple(Args,"O!|bb",&PackageType,&PackageObj, + if (PyArg_ParseTuple(Args,"O!|bb",&PackageType,&PackageObj, &autoInst, &fromUser) == 0) return 0; @@ -362,11 +362,11 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) Py_END_ALLOW_THREADS Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -376,11 +376,11 @@ static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Upgradable())); + return HandleErrors(Py_BuildValue("b",state.Upgradable())); } static PyObject *PkgDepCacheIsGarbage(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -390,11 +390,11 @@ static PyObject *PkgDepCacheIsGarbage(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Garbage)); + return HandleErrors(Py_BuildValue("b",state.Garbage)); } static PyObject *PkgDepCacheIsAutoInstalled(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -404,11 +404,11 @@ static PyObject *PkgDepCacheIsAutoInstalled(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Flags & pkgCache::Flag::Auto)); + return HandleErrors(Py_BuildValue("b",state.Flags & pkgCache::Flag::Auto)); } static PyObject *PkgDepCacheIsNowBroken(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -418,11 +418,11 @@ static PyObject *PkgDepCacheIsNowBroken(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.NowBroken())); + return HandleErrors(Py_BuildValue("b",state.NowBroken())); } static PyObject *PkgDepCacheIsInstBroken(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -432,12 +432,12 @@ static PyObject *PkgDepCacheIsInstBroken(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.InstBroken())); + return HandleErrors(Py_BuildValue("b",state.InstBroken())); } static PyObject *PkgDepCacheMarkedInstall(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -447,12 +447,12 @@ static PyObject *PkgDepCacheMarkedInstall(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.NewInstall())); + return HandleErrors(Py_BuildValue("b",state.NewInstall())); } static PyObject *PkgDepCacheMarkedUpgrade(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -462,11 +462,11 @@ static PyObject *PkgDepCacheMarkedUpgrade(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Upgrade())); + return HandleErrors(Py_BuildValue("b",state.Upgrade())); } static PyObject *PkgDepCacheMarkedDelete(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -476,11 +476,11 @@ static PyObject *PkgDepCacheMarkedDelete(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Delete())); + return HandleErrors(Py_BuildValue("b",state.Delete())); } static PyObject *PkgDepCacheMarkedKeep(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -490,11 +490,11 @@ static PyObject *PkgDepCacheMarkedKeep(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Keep())); + return HandleErrors(Py_BuildValue("b",state.Keep())); } static PyObject *PkgDepCacheMarkedDowngrade(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -504,11 +504,11 @@ static PyObject *PkgDepCacheMarkedDowngrade(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); pkgDepCache::StateCache &state = (*depcache)[Pkg]; - return HandleErrors(Py_BuildValue("b",state.Downgrade())); + return HandleErrors(Py_BuildValue("b",state.Downgrade())); } static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); PyObject *PackageObj; @@ -520,11 +520,11 @@ static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) bool res = state.Install() && (state.iFlags & pkgDepCache::ReInstall); - return HandleErrors(Py_BuildValue("b",res)); + return HandleErrors(Py_BuildValue("b",res)); } -static PyMethodDef PkgDepCacheMethods[] = +static PyMethodDef PkgDepCacheMethods[] = { {"Init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, {"GetCandidateVer",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, @@ -564,20 +564,20 @@ static PyObject *DepCacheAttr(PyObject *Self,char *Name) pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); // size querries - if(strcmp("KeepCount",Name) == 0) + if(strcmp("KeepCount",Name) == 0) return Py_BuildValue("l", depcache->KeepCount()); - else if(strcmp("InstCount",Name) == 0) + else if(strcmp("InstCount",Name) == 0) return Py_BuildValue("l", depcache->InstCount()); - else if(strcmp("DelCount",Name) == 0) + else if(strcmp("DelCount",Name) == 0) return Py_BuildValue("l", depcache->DelCount()); - else if(strcmp("BrokenCount",Name) == 0) + else if(strcmp("BrokenCount",Name) == 0) return Py_BuildValue("l", depcache->BrokenCount()); - else if(strcmp("UsrSize",Name) == 0) + else if(strcmp("UsrSize",Name) == 0) return Py_BuildValue("d", depcache->UsrSize()); - else if(strcmp("DebSize",Name) == 0) + else if(strcmp("DebSize",Name) == 0) return Py_BuildValue("d", depcache->DebSize()); - - + + return Py_FindMethod(PkgDepCacheMethods,Self,Name); } @@ -658,7 +658,7 @@ PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) -{ +{ bool res; pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); @@ -674,7 +674,7 @@ static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) } static PyObject *PkgProblemResolverResolveByKeep(PyObject *Self,PyObject *Args) -{ +{ bool res; pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); if (PyArg_ParseTuple(Args,"") == 0) @@ -688,7 +688,7 @@ static PyObject *PkgProblemResolverResolveByKeep(PyObject *Self,PyObject *Args) } static PyObject *PkgProblemResolverProtect(PyObject *Self,PyObject *Args) -{ +{ pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); PyObject *PackageObj; if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) @@ -708,11 +708,11 @@ static PyObject *PkgProblemResolverRemove(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); fixer->Remove(Pkg); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } static PyObject *PkgProblemResolverClear(PyObject *Self,PyObject *Args) -{ +{ pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); PyObject *PackageObj; if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) @@ -720,11 +720,11 @@ static PyObject *PkgProblemResolverClear(PyObject *Self,PyObject *Args) pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); fixer->Clear(Pkg); Py_INCREF(Py_None); - return HandleErrors(Py_None); -} + return HandleErrors(Py_None); +} static PyObject *PkgProblemResolverInstallProtect(PyObject *Self,PyObject *Args) -{ +{ pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); if (PyArg_ParseTuple(Args,"") == 0) return 0; @@ -733,7 +733,7 @@ static PyObject *PkgProblemResolverInstallProtect(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } -static PyMethodDef PkgProblemResolverMethods[] = +static PyMethodDef PkgProblemResolverMethods[] = { // config {"Protect", PkgProblemResolverProtect, METH_VARARGS, "Protect(PkgIterator)"}, @@ -751,7 +751,7 @@ static PyMethodDef PkgProblemResolverMethods[] = static PyObject *ProblemResolverAttr(PyObject *Self,char *Name) { pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self); - + return Py_FindMethod(PkgProblemResolverMethods,Self,Name); } @@ -783,7 +783,7 @@ PyTypeObject PkgProblemResolverType = static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) -{ +{ pkgDepCache::ActionGroup *ag = GetCpp<pkgDepCache::ActionGroup*>(Self); if (PyArg_ParseTuple(Args,"") == 0) return 0; @@ -792,7 +792,7 @@ static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } -static PyMethodDef PkgActionGroupMethods[] = +static PyMethodDef PkgActionGroupMethods[] = { {"release", PkgActionGroupRelease, METH_VARARGS, "release()"}, {} @@ -802,7 +802,7 @@ static PyMethodDef PkgActionGroupMethods[] = static PyObject *ActionGroupAttr(PyObject *Self,char *Name) { pkgDepCache::ActionGroup *ag = GetCpp<pkgDepCache::ActionGroup*>(Self); - + return Py_FindMethod(PkgActionGroupMethods,Self,Name); } diff --git a/python/generic.cc b/python/generic.cc index 044569b9..7309d978 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -4,7 +4,7 @@ /* ###################################################################### generic - Some handy functions to make integration a tad simpler - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -24,10 +24,10 @@ PyObject *HandleErrors(PyObject *Res) _error->Discard(); return Res; } - + if (Res != 0) Py_DECREF(Res); - + string Err; int errcnt = 0; while (_error->empty() == false) @@ -55,7 +55,7 @@ const char **ListToCharChar(PyObject *List,bool NullTerm) int Length = PySequence_Length(List); const char **Res = new const char *[Length + (NullTerm == true?1:0)]; for (int I = 0; I != Length; I++) - { + { PyObject *Itm = PySequence_GetItem(List,I); if (PyString_Check(Itm) == 0) { @@ -80,12 +80,12 @@ PyObject *CharCharToList(const char **List,unsigned long Size) for (const char **I = List; *I != 0; I++) Size++; } - + // Convert the whole configuration space into a list PyObject *PList = PyList_New(Size); for (unsigned long I = 0; I != Size; I++, List++) PyList_SetItem(PList,I,PyString_FromString(*List)); - + return PList; } /*}}}*/ diff --git a/python/generic.h b/python/generic.h index a1b662bb..ce79a54c 100644 --- a/python/generic.h +++ b/python/generic.h @@ -4,24 +4,24 @@ /* ###################################################################### generic - Some handy functions to make integration a tad simpler - - Python needs this little _HEAD tacked onto the front of the object.. + + Python needs this little _HEAD tacked onto the front of the object.. This complicates the integration with C++. We use some templates to make that quite transparent to us. It would have been nice if Python internally used a page from the C++ ref counting book to hide its little header from the world, but it doesn't. - The CppPyObject has the target object and the Python header, this is - needed to ensure proper alignment. + The CppPyObject has the target object and the Python header, this is + needed to ensure proper alignment. GetCpp returns the C++ object from a PyObject. CppPyObject_NEW creates the Python object and then uses placement new to init the C++ class.. This is good for simple situations and as an example on how to do it in other more specific cases. - CppPyObject_Dealloc should be used in the Type as the destructor + CppPyObject_Dealloc should be used in the Type as the destructor function. HandleErrors converts errors from the internal _error stack into Python exceptions and makes sure the _error stack is empty. - + ##################################################################### */ /*}}}*/ #ifndef GENERIC_H @@ -38,7 +38,7 @@ typedef int Py_ssize_t; template <class T> struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the - // c'tor is never called. + // c'tor is never called. // However if T doesn't have a default c'tor C++ doesn't generate one for // CppPyObject (since it can't know how it should initialize Object). // diff --git a/python/indexfile.cc b/python/indexfile.cc index 4e32f2ab..107eae27 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -16,7 +16,7 @@ #include <Python.h> static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) -{ +{ pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self); char *path; @@ -26,7 +26,7 @@ static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str())); } -static PyMethodDef PackageIndexFileMethods[] = +static PyMethodDef PackageIndexFileMethods[] = { {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, {} @@ -48,20 +48,20 @@ static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name) return Py_BuildValue("i",(File->Size())); else if (strcmp("IsTrusted",Name) == 0) return Py_BuildValue("i",(File->IsTrusted())); - + return Py_FindMethod(PackageIndexFileMethods,Self,Name); } static PyObject *PackageIndexFileRepr(PyObject *Self) { pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self); - + char S[1024]; snprintf(S,sizeof(S),"<pkIndexFile object: " "Label:'%s' Describe='%s' Exists='%i' " "HasPackages='%i' Size='%i' " "IsTrusted='%i' ArchiveURI='%s'>", - File->GetType()->Label, File->Describe().c_str(), File->Exists(), + File->GetType()->Label, File->Describe().c_str(), File->Exists(), File->HasPackages(), File->Size(), File->IsTrusted(), File->ArchiveURI("").c_str()); return PyString_FromString(S); @@ -86,7 +86,7 @@ PyTypeObject PackageIndexFileType = 0, // tp_as_mapping 0, // tp_hash }; - + diff --git a/python/makefile b/python/makefile index e0c62541..3e6458f4 100644 --- a/python/makefile +++ b/python/makefile @@ -7,20 +7,20 @@ include ../buildlib/defaults.mak # The apt_pkg module MODULE=apt_pkg -SLIBS = -lapt-pkg +SLIBS = -lapt-pkg LIB_MAKES = apt-pkg/makefile APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ indexfile.cc metaindex.cc -SOURCE := $(APT_PKG_SRC) +SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h -# The apt_int module.. +# The apt_int module.. MODULE=apt_inst SLIBS = -lapt-inst -lapt-pkg LIB_MAKES = apt-inst/makefile APT_INST_SRC = apt_instmodule.cc tar.cc generic.cc -SOURCE := $(APT_INST_SRC) +SOURCE := $(APT_INST_SRC) include $(PYTHON_H) diff --git a/python/metaindex.cc b/python/metaindex.cc index c9a86ab4..25742bd9 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -29,13 +29,13 @@ static PyObject *MetaIndexAttr(PyObject *Self,char *Name) { PyObject *List = PyList_New(0); vector<pkgIndexFile *> *indexFiles = meta->GetIndexFiles(); - for (vector<pkgIndexFile *>::const_iterator I = indexFiles->begin(); + for (vector<pkgIndexFile *>::const_iterator I = indexFiles->begin(); I != indexFiles->end(); I++) { PyObject *Obj; Obj = CppPyObject_NEW<pkgIndexFile*>(&PackageIndexFileType,*I); PyList_Append(List,Obj); - } + } return List; } } @@ -43,7 +43,7 @@ static PyObject *MetaIndexAttr(PyObject *Self,char *Name) static PyObject *MetaIndexRepr(PyObject *Self) { metaIndex *meta = GetCpp<metaIndex*>(Self); - + char S[1024]; snprintf(S,sizeof(S),"<metaIndex object: " "Type='%s', URI:'%s' Dist='%s' IsTrusted='%i'>", @@ -72,7 +72,7 @@ PyTypeObject MetaIndexType = 0, // tp_as_mapping 0, // tp_hash }; - + diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 9670f238..0eaa28cd 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -19,14 +19,14 @@ static PyObject *PkgManagerGetArchives(PyObject *Self,PyObject *Args) -{ +{ pkgPackageManager *pm = GetCpp<pkgPackageManager*>(Self); PyObject *fetcher, *list, *recs; - + if (PyArg_ParseTuple(Args, "O!O!O!", &PkgAcquireType,&fetcher, &PkgSourceListType, &list, - &PkgRecordsType, &recs) == 0) + &PkgRecordsType, &recs) == 0) return 0; pkgAcquire *s_fetcher = GetCpp<pkgAcquire*>(fetcher); @@ -44,12 +44,12 @@ static PyObject *PkgManagerDoInstall(PyObject *Self,PyObject *Args) //PkgManagerStruct &Struct = GetCpp<PkgManagerStruct>(Self); pkgPackageManager *pm = GetCpp<pkgPackageManager*>(Self); int status_fd = -1; - + if (PyArg_ParseTuple(Args, "|i", &status_fd) == 0) return 0; pkgPackageManager::OrderResult res = pm->DoInstall(status_fd); - + return HandleErrors(Py_BuildValue("i",res)); } @@ -62,11 +62,11 @@ static PyObject *PkgManagerFixMissing(PyObject *Self,PyObject *Args) return 0; bool res = pm->FixMissing(); - + return HandleErrors(Py_BuildValue("b",res)); } -static PyMethodDef PkgManagerMethods[] = +static PyMethodDef PkgManagerMethods[] = { {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"}, {"DoInstall",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"}, @@ -81,11 +81,11 @@ static PyObject *PkgManagerAttr(PyObject *Self,char *Name) pkgPackageManager *pm = GetCpp<pkgPackageManager*>(Self); // some constants - if(strcmp("ResultCompleted",Name) == 0) + if(strcmp("ResultCompleted",Name) == 0) return Py_BuildValue("i", pkgPackageManager::Completed); - if(strcmp("ResultFailed",Name) == 0) + if(strcmp("ResultFailed",Name) == 0) return Py_BuildValue("i", pkgPackageManager::Failed); - if(strcmp("ResultIncomplete",Name) == 0) + if(strcmp("ResultIncomplete",Name) == 0) return Py_BuildValue("i", pkgPackageManager::Incomplete); return Py_FindMethod(PkgManagerMethods,Self,Name); @@ -125,7 +125,7 @@ PyObject *GetPkgManager(PyObject *Self,PyObject *Args) CppPyObject<pkgPackageManager*> *PkgManagerObj = CppPyObject_NEW<pkgPackageManager*>(&PkgManagerType,pm); - + return PkgManagerObj; } diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 93bc54d9..18240ce0 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -16,20 +16,20 @@ #include <Python.h> /*}}}*/ - + // PkgRecords Class /*{{{*/ // --------------------------------------------------------------------- static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) -{ +{ PkgRecordsStruct &Struct = GetCpp<PkgRecordsStruct>(Self); - + PyObject *PkgFObj; long int Index; if (PyArg_ParseTuple(Args,"(O!l)",&PackageFileType,&PkgFObj,&Index) == 0) return 0; - + // Get the index and check to make sure it is reasonable pkgCache::PkgFileIterator &PkgF = GetCpp<pkgCache::PkgFileIterator>(PkgFObj); pkgCache *Cache = PkgF.Cache(); @@ -39,15 +39,15 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) PyErr_SetNone(PyExc_IndexError); return 0; } - + // Do the lookup Struct.Last = &Struct.Records.Lookup(pkgCache::VerFileIterator(*Cache,Cache->VerFileP+Index)); // always return true (to make it consistent with the pkgsrcrecords object return Py_BuildValue("i", 1); } - -static PyMethodDef PkgRecordsMethods[] = + +static PyMethodDef PkgRecordsMethods[] = { {"Lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, {} @@ -79,14 +79,14 @@ static PyObject *PkgRecordsAttr(PyObject *Self,char *Name) return CppPyString(Struct.Last->Name()); else if (strcmp("Homepage",Name) == 0) return CppPyString(Struct.Last->Homepage()); - else if (strcmp("Record", Name) == 0) + else if (strcmp("Record", Name) == 0) { const char *start, *stop; Struct.Last->GetRec(start, stop); return PyString_FromStringAndSize(start,stop-start); } } - + return Py_FindMethod(PkgRecordsMethods,Self,Name); } PyTypeObject PkgRecordsType = diff --git a/python/pkgrecords.h b/python/pkgrecords.h index 78787eab..1e26c8cf 100644 --- a/python/pkgrecords.h +++ b/python/pkgrecords.h @@ -4,7 +4,7 @@ struct PkgRecordsStruct { pkgRecords Records; pkgRecords::Parser *Last; - + PkgRecordsStruct(pkgCache *Cache) : Records(*Cache), Last(0) {}; PkgRecordsStruct() : Records(*(pkgCache *)0) {abort();}; // G++ Bug.. }; diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 5e04f5fc..1a52e8f1 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -21,7 +21,7 @@ struct PkgSrcRecordsStruct pkgSourceList List; pkgSrcRecords *Records; pkgSrcRecords::Parser *Last; - + PkgSrcRecordsStruct() : Last(0) { List.ReadMainList(); Records = new pkgSrcRecords(List); @@ -30,24 +30,24 @@ struct PkgSrcRecordsStruct delete Records; }; }; - + // PkgSrcRecords Class /*{{{*/ // --------------------------------------------------------------------- static char *doc_PkgSrcRecordsLookup = "xxx"; static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) -{ +{ PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self); - + char *Name = 0; if (PyArg_ParseTuple(Args,"s",&Name) == 0) return 0; - + Struct.Last = Struct.Records->Find(Name, false); if (Struct.Last == 0) { Struct.Records->Restart(); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } return Py_BuildValue("i", 1); @@ -55,20 +55,20 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) static char *doc_PkgSrcRecordsRestart = "Start Lookup from the begining"; static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) -{ +{ PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self); - + char *Name = 0; if (PyArg_ParseTuple(Args,"") == 0) return 0; - + Struct.Records->Restart(); Py_INCREF(Py_None); - return HandleErrors(Py_None); + return HandleErrors(Py_None); } -static PyMethodDef PkgSrcRecordsMethods[] = +static PyMethodDef PkgSrcRecordsMethods[] = { {"Lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, {"Restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, @@ -109,10 +109,10 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name) PyObject *v; for(unsigned int i=0;i<f.size();i++) { - v = Py_BuildValue("(siss)", - f[i].MD5Hash.c_str(), - f[i].Size, - f[i].Path.c_str(), + v = Py_BuildValue("(siss)", + f[i].MD5Hash.c_str(), + f[i].Size, + f[i].Path.c_str(), f[i].Type.c_str()); PyList_Append(List, v); Py_DECREF(v); @@ -127,7 +127,7 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name) PyObject *v; for(unsigned int i=0;i<bd.size();i++) { - v = Py_BuildValue("(ssii)", bd[i].Package.c_str(), + v = Py_BuildValue("(ssii)", bd[i].Package.c_str(), bd[i].Version.c_str(), bd[i].Op, bd[i].Type); PyList_Append(List, v); Py_DECREF(v); @@ -135,7 +135,7 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name) return List; } } - + return Py_FindMethod(PkgSrcRecordsMethods,Self,Name); } PyTypeObject PkgSrcRecordsType = @@ -172,7 +172,7 @@ PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) #endif if (PyArg_ParseTuple(Args,"") == 0) return 0; - + return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(&PkgSrcRecordsType)); } diff --git a/python/progress.cc b/python/progress.cc index 793265db..9c8b65a8 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -14,7 +14,7 @@ // generic -bool PyCallbackObj::RunSimpleCallback(const char* method_name, +bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, PyObject **res) { @@ -50,8 +50,8 @@ bool PyCallbackObj::RunSimpleCallback(const char* method_name, } -// OpProgress interface -void PyOpProgress::Update() +// OpProgress interface +void PyOpProgress::Update() { PyObject *o; o = Py_BuildValue("s", Op.c_str()); @@ -64,7 +64,7 @@ void PyOpProgress::Update() PyObject_SetAttrString(callbackInst, "majorChange", o); Py_XDECREF(o); - // Build up the argument list... + // Build up the argument list... if(CheckChange(0.05)) { PyObject *arglist = Py_BuildValue("(f)", Percent); @@ -128,7 +128,7 @@ void PyFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) // Ignore certain kinds of transient failures (bad code) if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) return; - + if (Itm.Owner->Status == pkgAcquire::Item::StatDone) { UpdateStatus(Itm, DLIgnored); @@ -159,7 +159,7 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) //std::cout << "Pulse" << std::endl; if(callbackInst == 0) return false; - + // set stats PyObject *o; o = Py_BuildValue("f", CurrentCPS); @@ -179,11 +179,11 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) Py_XDECREF(o); PyObject *arglist = Py_BuildValue("()"); - PyObject *result; + PyObject *result; RunSimpleCallback("pulse", arglist, &result); bool res = true; - if(!PyArg_Parse(result, "b", &res)) + if(!PyArg_Parse(result, "b", &res)) { // mvo: this is harmless, we shouldn't print anything here //std::cerr << "result could not be parsed" << std::endl; @@ -197,22 +197,22 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) // install progress -void PyInstallProgress::StartUpdate() +void PyInstallProgress::StartUpdate() { RunSimpleCallback("startUpdate"); } -void PyInstallProgress::UpdateInterface() +void PyInstallProgress::UpdateInterface() { RunSimpleCallback("updateInterface"); } - -void PyInstallProgress::FinishUpdate() + +void PyInstallProgress::FinishUpdate() { RunSimpleCallback("finishUpdate"); } -pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) +pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) { void *dummy; pkgPackageManager::OrderResult res; @@ -231,7 +231,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) std::cerr << "custom fork found" << std::endl; PyObject *arglist = Py_BuildValue("()"); PyObject *result = PyEval_CallObject(method, arglist); - Py_DECREF(arglist); + Py_DECREF(arglist); if (result == NULL) { std::cerr << "fork method invalid" << std::endl; PyErr_Print(); @@ -246,7 +246,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) //std::cerr << "using build-in fork()" << std::endl; child_id = fork(); } - + #if 0 // FIXME: this needs to be merged into apt to support medium swaping if (child_id == 0) { @@ -275,7 +275,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) //std::cerr << "custom waitChild found" << std::endl; PyObject *arglist = Py_BuildValue("(i)",child_id); PyObject *result = PyEval_CallObject(method, arglist); - Py_DECREF(arglist); + Py_DECREF(arglist); if (result == NULL) { std::cerr << "waitChild method invalid" << std::endl; PyErr_Print(); @@ -289,7 +289,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) //std::cerr << "got child_res: " << res << std::endl; } else { //std::cerr << "using build-in waitpid()" << std::endl; - + while (waitpid(child_id, &ret, WNOHANG) == 0) UpdateInterface(); diff --git a/python/progress.h b/python/progress.h index f04bd683..5ac67b1c 100644 --- a/python/progress.h +++ b/python/progress.h @@ -53,7 +53,7 @@ struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj virtual bool MediaChange(string Media, string Drive); - /* apt stuff */ + /* apt stuff */ virtual void IMSHit(pkgAcquire::ItemDesc &Itm); virtual void Fetch(pkgAcquire::ItemDesc &Itm); virtual void Done(pkgAcquire::ItemDesc &Itm); diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 76df015d..5dcaf86b 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -17,18 +17,18 @@ /*}}}*/ - + // PkgsourceList Class /*{{{*/ // --------------------------------------------------------------------- static char *doc_PkgSourceListFindIndex = "xxx"; static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) -{ +{ pkgSourceList *list = GetCpp<pkgSourceList*>(Self); PyObject *pyPkgFileIter; PyObject *pyPkgIndexFile; - if (PyArg_ParseTuple(Args, "O!", &PackageFileType,&pyPkgFileIter) == 0) + if (PyArg_ParseTuple(Args, "O!", &PackageFileType,&pyPkgFileIter) == 0) return 0; pkgCache::PkgFileIterator &i = GetCpp<pkgCache::PkgFileIterator>(pyPkgFileIter); @@ -40,7 +40,7 @@ static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) } //&PackageIndexFileType,&pyPkgIndexFile) - + Py_INCREF(Py_None); return Py_None; } @@ -61,7 +61,7 @@ static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args) PyObject *pyFetcher; char all = 0; - if (PyArg_ParseTuple(Args, "O!|b",&PkgAcquireType,&pyFetcher, &all) == 0) + if (PyArg_ParseTuple(Args, "O!|b",&PkgAcquireType,&pyFetcher, &all) == 0) return 0; pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyFetcher); @@ -70,7 +70,7 @@ static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("b",res)); } -static PyMethodDef PkgSourceListMethods[] = +static PyMethodDef PkgSourceListMethods[] = { {"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, {"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, @@ -85,13 +85,13 @@ static PyObject *PkgSourceListAttr(PyObject *Self,char *Name) if (strcmp("List",Name) == 0) { PyObject *List = PyList_New(0); - for (vector<metaIndex *>::const_iterator I = list->begin(); + for (vector<metaIndex *>::const_iterator I = list->begin(); I != list->end(); I++) { PyObject *Obj; Obj = CppPyObject_NEW<metaIndex*>(&MetaIndexType,*I); PyList_Append(List,Obj); - } + } return List; } return Py_FindMethod(PkgSourceListMethods,Self,Name); diff --git a/python/string.cc b/python/string.cc index 1fa5a901..8168ea5b 100644 --- a/python/string.cc +++ b/python/string.cc @@ -3,22 +3,22 @@ // $Id: string.cc,v 1.3 2002/01/08 06:53:04 jgg Exp $ /* ###################################################################### - string - Mappings for the string functions that are worthwile for + string - Mappings for the string functions that are worthwile for Python users - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ #include "apt_pkgmodule.h" #include "generic.h" - + #include <apt-pkg/strutl.h> #include <Python.h> /*}}}*/ - + // Templated function /*{{{*/ -/* Macro for the generic string in string out function */ +/* Macro for the generic string in string out function */ #define MkStr(Python,CFunc) \ PyObject *Python(PyObject *Self,PyObject *Args) \ { \ @@ -36,7 +36,7 @@ PyObject *Python(PyObject *Self,PyObject *Args) \ return 0; \ return CppPyString(CFunc(Val)); \ } - + MkStr(StrDeQuote,DeQuoteString); MkStr(StrBase64Encode,Base64Encode); MkStr(StrURItoFileName,URItoFileName); @@ -58,7 +58,7 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args) return CppPyString(SizeToStr(PyLong_AsDouble(Obj))); if (PyFloat_Check(Obj)) return CppPyString(SizeToStr(PyFloat_AsDouble(Obj))); - + PyErr_SetString(PyExc_TypeError,"Only understand integers and floats"); return 0; } @@ -69,14 +69,14 @@ PyObject *StrQuoteString(PyObject *Self,PyObject *Args) char *Bad = 0; if (PyArg_ParseTuple(Args,"ss",&Str,&Bad) == 0) return 0; - return CppPyString(QuoteString(Str,Bad)); + return CppPyString(QuoteString(Str,Bad)); } PyObject *StrStringToBool(PyObject *Self,PyObject *Args) { char *Str = 0; if (PyArg_ParseTuple(Args,"s",&Str) == 0) - return 0; + return 0; return Py_BuildValue("i",StringToBool(Str)); } @@ -85,14 +85,14 @@ PyObject *StrStrToTime(PyObject *Self,PyObject *Args) char *Str = 0; if (PyArg_ParseTuple(Args,"s",&Str) == 0) return 0; - + time_t Result; if (StrToTime(Str,Result) == false) { Py_INCREF(Py_None); return Py_None; } - + return Py_BuildValue("i",Result); } diff --git a/python/tag.cc b/python/tag.cc index 4b378a55..217be290 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -4,18 +4,18 @@ /* ###################################################################### Tag - Binding for the RFC 822 tag file parser - + Upon reflection I have make the TagSection wrapper look like a map.. The other option was to use a sequence (which nicely matches the internal - storage) but really makes no sense to a Python Programmer.. One - specialized lookup is provided, the FindFlag lookup - as well as the + storage) but really makes no sense to a Python Programmer.. One + specialized lookup is provided, the FindFlag lookup - as well as the usual set of duplicate things to match the C++ interface. - - The TagFile interface is also slightly different, it has a built in + + The TagFile interface is also slightly different, it has a built in internal TagSection object that is used. Do not hold onto a reference to a TagSection and let TagFile go out of scope! The underlying storage for the section will go away and it will seg. - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -80,7 +80,7 @@ static PyObject *TagSecFind(PyObject *Self,PyObject *Args) char *Default = 0; if (PyArg_ParseTuple(Args,"s|z",&Name,&Default) == 0) return 0; - + const char *Start; const char *Stop; if (GetCpp<pkgTagSection>(Self).Find(Name,Start,Stop) == false) @@ -98,7 +98,7 @@ static PyObject *TagSecFindFlag(PyObject *Self,PyObject *Args) char *Name = 0; if (PyArg_ParseTuple(Args,"s",&Name) == 0) return 0; - + unsigned long Flag = 0; if (GetCpp<pkgTagSection>(Self).FindFlag(Name,Flag,1) == false) { @@ -116,15 +116,15 @@ static PyObject *TagSecMap(PyObject *Self,PyObject *Arg) PyErr_SetNone(PyExc_TypeError); return 0; } - + const char *Start; const char *Stop; if (GetCpp<pkgTagSection>(Self).Find(PyString_AsString(Arg),Start,Stop) == false) - { + { PyErr_SetString(PyExc_KeyError,PyString_AsString(Arg)); return 0; } - + return PyString_FromStringAndSize(Start,Stop-Start); } @@ -142,17 +142,17 @@ static PyObject *TagSecKeys(PyObject *Self,PyObject *Args) pkgTagSection &Tags = GetCpp<pkgTagSection>(Self); if (PyArg_ParseTuple(Args,"") == 0) return 0; - + // Convert the whole configuration space into a list PyObject *List = PyList_New(0); for (unsigned int I = 0; I != Tags.Count(); I++) - { + { const char *Start; const char *Stop; Tags.Get(Start,Stop,I); const char *End = Start; for (; End < Stop && *End != ':'; End++); - + PyObject *Obj; PyList_Append(List,Obj = PyString_FromStringAndSize(Start,End-Start)); Py_DECREF(Obj); @@ -166,7 +166,7 @@ static PyObject *TagSecExists(PyObject *Self,PyObject *Args) char *Name = 0; if (PyArg_ParseTuple(Args,"s",&Name) == 0) return 0; - + const char *Start; const char *Stop; if (GetCpp<pkgTagSection>(Self).Find(Name,Start,Stop) == false) @@ -179,7 +179,7 @@ static PyObject *TagSecBytes(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + return Py_BuildValue("i",GetCpp<pkgTagSection>(Self).size()); } @@ -197,11 +197,11 @@ static PyObject *TagFileStep(PyObject *Self,PyObject *Args) { if (PyArg_ParseTuple(Args,"") == 0) return 0; - + TagFileData &Obj = *(TagFileData *)Self; if (Obj.Object.Step(Obj.Section->Object) == false) return HandleErrors(Py_BuildValue("i",0)); - + return HandleErrors(Py_BuildValue("i",1)); } @@ -219,11 +219,11 @@ static PyObject *TagFileJump(PyObject *Self,PyObject *Args) int Offset; if (PyArg_ParseTuple(Args,"i",&Offset) == 0) return 0; - + TagFileData &Obj = *(TagFileData *)Self; if (Obj.Object.Jump(Obj.Section->Object,Offset) == false) return HandleErrors(Py_BuildValue("i",0)); - + return HandleErrors(Py_BuildValue("i",1)); } /*}}}*/ @@ -235,23 +235,23 @@ PyObject *ParseSection(PyObject *self,PyObject *Args) char *Data; if (PyArg_ParseTuple(Args,"s",&Data) == 0) return 0; - + // Create the object.. TagSecData *New = PyObject_NEW(TagSecData,&TagSecType); new (&New->Object) pkgTagSection(); New->Data = new char[strlen(Data)+2]; snprintf(New->Data,strlen(Data)+2,"%s\n",Data); - + if (New->Object.Scan(New->Data,strlen(New->Data)) == false) { cerr << New->Data << endl; Py_DECREF((PyObject *)New); PyErr_SetString(PyExc_ValueError,"Unable to parse section data"); return 0; - } - + } + New->Object.Trim(); - + return New; } /*}}}*/ @@ -264,26 +264,26 @@ PyObject *ParseTagFile(PyObject *self,PyObject *Args) PyObject *File; if (PyArg_ParseTuple(Args,"O!",&PyFile_Type,&File) == 0) return 0; - + TagFileData *New = PyObject_NEW(TagFileData,&TagFileType); new (&New->Fd) FileFd(fileno(PyFile_AsFile(File)),false); New->File = File; Py_INCREF(New->File); new (&New->Object) pkgTagFile(&New->Fd); - + // Create the section New->Section = PyObject_NEW(TagSecData,&TagSecType); new (&New->Section->Object) pkgTagSection(); New->Section->Data = 0; - + return HandleErrors(New); } - /*}}}*/ + /*}}}*/ // RewriteSection - Rewrite a section.. /*{{{*/ // --------------------------------------------------------------------- -/* An interesting future extension would be to add a user settable +/* An interesting future extension would be to add a user settable order list */ -char *doc_RewriteSection = +char *doc_RewriteSection = "RewriteSection(Section,Order,RewriteList) -> String\n" "\n" "The section rewriter allows a section to be taken in, have fields added,\n" @@ -306,10 +306,10 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) if (PyArg_ParseTuple(Args,"O!O!O!",&TagSecType,&Section, &PyList_Type,&Order,&PyList_Type,&Rewrite) == 0) return 0; - + // Convert the order list const char **OrderList = ListToCharChar(Order,true); - + // Convert the Rewrite list. TFRewriteData *List = new TFRewriteData[PySequence_Length(Rewrite)+1]; memset(List,0,sizeof(*List)*(PySequence_Length(Rewrite)+1)); @@ -324,7 +324,7 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) return 0; } } - + /* This is a glibc extension.. If not running on glibc I'd just take this whole function out, it is probably infrequently used */ char *bp = 0; @@ -336,13 +336,13 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) delete [] OrderList; delete [] List; fclose(F); - + if (Res == false) { free(bp); return HandleErrors(); } - + // Return the string PyObject *ResObj = PyString_FromStringAndSize(bp,size); free(bp); @@ -351,13 +351,13 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) /*}}}*/ // Method table for the Tag Section object -static PyMethodDef TagSecMethods[] = +static PyMethodDef TagSecMethods[] = { // Query {"Find",TagSecFind,METH_VARARGS,doc_Find}, {"FindFlag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, {"Bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, - + // Python Special {"keys",TagSecKeys,METH_VARARGS,doc_Keys}, {"has_key",TagSecExists,METH_VARARGS,doc_Exists}, @@ -398,13 +398,13 @@ PyTypeObject TagSecType = }; // Method table for the Tag File object -static PyMethodDef TagFileMethods[] = +static PyMethodDef TagFileMethods[] = { // Query {"Step",TagFileStep,METH_VARARGS,doc_Step}, {"Offset",TagFileOffset,METH_VARARGS,doc_Offset}, {"Jump",TagFileJump,METH_VARARGS,doc_Jump}, - + {} }; @@ -418,8 +418,8 @@ static PyObject *TagFileGetAttr(PyObject *Self,char *Name) PyObject *Obj = ((TagFileData *)Self)->Section; Py_INCREF(Obj); return Obj; - } - + } + return Py_FindMethod(TagFileMethods,Self,Name); } diff --git a/python/tar.cc b/python/tar.cc index 61c9d708..e5aaee6f 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -4,7 +4,7 @@ /* ###################################################################### Tar Inteface - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -23,9 +23,9 @@ class ProcessTar : public pkgDirStream public: PyObject *Function; - + virtual bool DoItem(Item &Itm,int &Fd); - + ProcessTar(PyObject *Function) : Function(Function) { Py_INCREF(Function); @@ -48,55 +48,55 @@ bool ProcessTar::DoItem(Item &Itm,int &Fd) case Item::File: Type = "FILE"; break; - + case Item::HardLink: Type = "HARDLINK"; break; - + case Item::SymbolicLink: Type = "SYMLINK"; break; - + case Item::CharDevice: Type = "CHARDEV"; break; - + case Item::BlockDevice: Type = "BLKDEV"; break; - + case Item::Directory: Type = "DIR"; break; - + case Item::FIFO: Type = "FIFO"; break; } - + if (PyObject_CallFunction(Function,"sssiiiiiii",Type,Itm.Name, Itm.LinkTarget,Itm.Mode,Itm.UID,Itm.GID,Itm.Size, Itm.MTime,Itm.Major,Itm.Minor) == 0) return false; - + Fd = -1; return true; } /*}}}*/ - + // tarExtract - Examine files from a tar /*{{{*/ // --------------------------------------------------------------------- /* */ char *doc_tarExtract = "tarExtract(File,Func,Comp) -> None\n" "The tar file referenced by the file object File, Func called for each\n" -"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; +"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; PyObject *tarExtract(PyObject *Self,PyObject *Args) { PyObject *File; PyObject *Function; char *Comp; - + if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, &Function,&Comp) == 0) return 0; @@ -106,19 +106,19 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); return 0; } - + { // Open the file and associate the tar FileFd Fd(fileno(PyFile_AsFile(File)),false); ExtractTar Tar(Fd,0xFFFFFFFF,Comp); if (_error->PendingError() == true) return HandleErrors(); - + ProcessTar Proc(Function); if (Tar.Go(Proc) == false) return HandleErrors(); - } - + } + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -138,11 +138,11 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) PyObject *Function; char *Chunk; const char *Comp = "gzip"; - + if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, &Function,&Chunk) == 0) return 0; - + if (PyCallable_Check(Function) == 0) { PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); @@ -156,15 +156,15 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) debDebFile Deb(Fd); if (_error->PendingError() == true) return HandleErrors(); - - // Get the archive member and positition the file + + // Get the archive member and positition the file const ARArchive::Member *Member = Deb.GotoMember(Chunk); if (Member == 0) { _error->Error("Cannot find chunk %s",Chunk); return HandleErrors(); } - + // Extract it. if (strcmp(".bz2", &Chunk[strlen(Chunk)-4]) == 0) Comp = "bzip2"; @@ -174,8 +174,8 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) ProcessTar Proc(Function); if (Tar.Go(Proc) == false) return HandleErrors(); - } - + } + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -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", diff --git a/tests/cache.py b/tests/cache.py index 47d9a3b4..3ec87b40 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 @@ -41,7 +41,7 @@ def main(): k = ver.DependsListStr j = ver.DependsList pass - + 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 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/memleak.py b/tests/memleak.py index b5d05afc..58a2f886 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -20,7 +20,7 @@ for i in range(100): f.write("%s\n" % str(obj)) f.close() -# memleak +# memleak #for i in range(100): # cache = apt.Cache() # time.sleep(1) 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 3ee106be..734503d2 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -55,7 +55,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/", @@ -89,7 +89,7 @@ class TestAptSources(unittest.TestCase): #print dist_templates for d in ["edgy","edgy-security","edgy-updates","hoary","breezy", "breezy-backports"]: self.assertTrue(d in dist_templates) - # test enable + # test enable comp = "restricted" distro.enable_component(sources, comp) found = {} 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 <glatzor@ubuntu.com> -# -# 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 <glatzor@ubuntu.com> -# -# 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 <glatzor@ubuntu.com> -# -# 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/mirrortest b/utils/mirrortest index 75ef917b..a724c81f 100755 --- a/utils/mirrortest +++ b/utils/mirrortest @@ -24,8 +24,8 @@ class MirrorTest: host = mirror.hostname except: continue - print "Pinging (Worker %s) %s (%s) ..." % (self.id, - host, + print "Pinging (Worker %s) %s (%s) ..." % (self.id, + host, MirrorTest.completed_pings) commando = os.popen("ping -q -c 4 -W 2 -i 0.3 %s" % host, "r") |
