summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-03-27 21:25:05 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-03-27 21:25:05 +0200
commit01c2875f19b40695b75c1014f4d1adc536c081fe (patch)
tree02c420b9e6bdbcb912682ee4f949fc7c304c5233 /SoftwareProperties
parentbd4359789d0e72fbbcd49f22b7f535e9238f3f93 (diff)
downloadpython-apt-01c2875f19b40695b75c1014f4d1adc536c081fe.tar.gz
* small fixes
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/aptsources.py36
-rw-r--r--SoftwareProperties/dialog_add.py12
2 files changed, 25 insertions, 23 deletions
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index 3e82c74b..933d9960 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -189,24 +189,6 @@ class SourceEntry:
line += "\n"
return line
- def add(self, type, uri, dist, comps, comment="", pos=-1):
- # if there is a repo with the same (type, uri, dist) just add the
- # components
- for i in self.list:
- if i.type == type and is_mirror(uri,i.uri) and i.dist == dist:
- comps = uniq(i.comps + comps)
- # set to the old position and preserve comment
- comment = i.comment
- pos = self.list.index(i)
- self.list.remove(i)
- line = "%s %s %s" % (type,uri,dist)
- for c in comps:
- line = line + " " + c;
- if comment != "":
- line = "%s #%s\n" %(line,comment)
- line = line + "\n"
- self.list.insert(pos, SourceEntry(line))
-
# the SourceList file as a class
class SourcesList:
def __init__(self):
@@ -229,6 +211,24 @@ class SourcesList:
yield entry
raise StopIteration
+ def add(self, type, uri, dist, comps, comment="", pos=-1):
+ # if there is a repo with the same (type, uri, dist) just add the
+ # components
+ for i in self.list:
+ if i.type == type and is_mirror(uri,i.uri) and i.dist == dist:
+ comps = uniq(i.comps + comps)
+ # set to the old position and preserve comment
+ comment = i.comment
+ pos = self.list.index(i)
+ self.list.remove(i)
+ line = "%s %s %s" % (type,uri,dist)
+ for c in comps:
+ line = line + " " + c;
+ if comment != "":
+ line = "%s #%s\n" %(line,comment)
+ line = line + "\n"
+ self.list.insert(pos, SourceEntry(line))
+
def remove(self, source_entry):
self.list.remove(source_entry)
diff --git a/SoftwareProperties/dialog_add.py b/SoftwareProperties/dialog_add.py
index 9a074396..cee2f9b8 100644
--- a/SoftwareProperties/dialog_add.py
+++ b/SoftwareProperties/dialog_add.py
@@ -39,6 +39,10 @@ class dialog_add:
self.custom = False
# we have a source_entry that we want to modify
self.source_entry = source_entry
+ if source_entry:
+ self.source_entry_index = sourceslist.list.index(source_entry)
+ else:
+ self.source_entry_index = None
# templates
self.templatelist = aptsources.SourceEntryTemplates(datadir)
@@ -116,14 +120,13 @@ class dialog_add:
# since we're passing the SourceEntry as it is now,
# this SourceEntry needs to be in the sourceslist,
# so temporarily swap the original for the current
- source_entry_index = self.sourcelist.list.index(source_entry)
- self.sourceslist.list[source_entry_index] = source_entry
+ self.sourceslist.list[self.source_entry_index] = source_entry
dialog = dialog_edit.dialog_edit(self.parent, self.sourceslist,
source_entry, self.datadir)
res = dialog.run()
if res == gtk.RESPONSE_CANCEL:
# restore original SourceEntry
- self.sourceslist.list[source_entry_index] = self.source_entry
+ self.sourceslist.list[self.source_entry_index] = self.source_entry
elif res == gtk.RESPONSE_OK:
# the sourceslist is allready updated, but we'll overwrite it
# in self.run if we're not carefull
@@ -167,8 +170,7 @@ class dialog_add:
if self.source_entry:
# 'edit' - ode
if not self.custom:
- source_entry_index = self.sourcelist.list.index(source_entry)
- self.sourceslist.list[source_entry_index] = self._make_source_entry()
+ self.sourceslist.list[self.source_entry_index] = self._make_source_entry()
else:
# 'add' mode
self.sourceslist.add(self.selected.type,