diff options
| author | Julian Andres Klode <jak@debian.org> | 2011-04-06 10:42:38 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2011-04-06 10:42:38 +0200 |
| commit | b766dc001aeea1c18b0c17c1d5029673ef539ef0 (patch) | |
| tree | 0156349c1b9180df235ea81272b69df22ccd31e1 | |
| parent | 30a0dff267d9e99c25d5902e296fd115746e05c9 (diff) | |
| download | python-apt-b766dc001aeea1c18b0c17c1d5029673ef539ef0.tar.gz | |
aptsources: Various cleanup work
| -rw-r--r-- | aptsources/sourceslist.py | 53 | ||||
| -rw-r--r-- | debian/changelog | 1 |
2 files changed, 27 insertions, 27 deletions
diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 85db2de9..38831e9c 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -275,6 +275,12 @@ class SourcesList(object): yield entry raise StopIteration + def __find(self, *predicates, **attrs): + for source in self.list: + if (all(getattr(source, key) == attrs[key] for key in attrs) and + all(predicate(source) for predicate in predicates)): + yield source + def add(self, type, uri, dist, orig_comps, comment="", pos=-1, file=None, architectures=[]): """ Add a new source to the sources.list. @@ -286,39 +292,32 @@ class SourcesList(object): # create a working copy of the component list so that # we can modify it later comps = orig_comps[:] + sources = self.__find(lambda s: set(s.architectures) == architectures, + disabled=False, invalid=False, type=type, uri=uri, + dist=dist) # check if we have this source already in the sources.list - for source in self.list: - if not source.disabled and not source.invalid and \ - source.type == type and uri == source.uri and \ - source.dist == dist and \ - set(source.architectures) == architectures: - for new_comp in comps: - if new_comp in source.comps: - # we have this component already, delete it - # from the new_comps list - del comps[comps.index(new_comp)] - if len(comps) == 0: - return source - for source in self.list: + for source in sources: + for new_comp in comps: + if new_comp in source.comps: + # we have this component already, delete it + # from the new_comps list + del comps[comps.index(new_comp)] + if len(comps) == 0: + return source + + sources = self.__find(lambda s: set(s.architectures) == architectures, + invalid=False, type=type, uri=uri, dist=dist) + + for source in sources: # if there is a repo with the same (type, uri, dist) just add the # components - if not source.disabled and not source.invalid and \ - source.type == type and uri == source.uri and \ - source.dist == dist and \ - set(source.architectures) == architectures: - comps = uniq(source.comps + comps) - source.comps = comps - return source - # if there is a corresponding repo which is disabled, enable it - elif source.disabled and not source.invalid and \ - source.type == type and uri == source.uri and \ - set(source.architectures) == architectures and \ - source.dist == dist and \ - len(set(source.comps) & set(comps)) == len(comps): + if source.disabled and set(source.comps) == comps: source.disabled = False return source + elif not source.disabled: + source.comps = uniq(source.comps + comps) + return source # there isn't any matching source, so create a new line and parse it - line = type if architectures: line += " [arch=%s]" % ",".join(architectures) diff --git a/debian/changelog b/debian/changelog index 7ceda2ce..2864126a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.8.0~exp2) UNRELEASED; urgency=low * aptsources: Parse multi-arch sources.list files correctly * aptsources: Allow insertion of new multi-arch entries + * aptsources: Various cleanup work -- Julian Andres Klode <jak@debian.org> Wed, 06 Apr 2011 09:46:52 +0200 |
