diff options
| author | Sebastian Heinlein <sebi@sebi-laptop> | 2007-02-05 09:19:39 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@sebi-laptop> | 2007-02-05 09:19:39 +0100 |
| commit | 3ee70c61924e65e3c4ef6bf0fa0673d2e866b042 (patch) | |
| tree | d282bf57ebe1bbc3a0084a83ab6bc70ff93cbf74 /aptsources/sourceslist.py | |
| parent | 238e469ebc586cc50095a855b64619632c22fbf2 (diff) | |
| download | python-apt-3ee70c61924e65e3c4ef6bf0fa0673d2e866b042.tar.gz | |
* write an empty default sources.list if all sources have been removed
Diffstat (limited to 'aptsources/sourceslist.py')
| -rw-r--r-- | aptsources/sourceslist.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 14c2a0ea..e5b8dab9 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -342,6 +342,15 @@ class SourcesList: def save(self): """ save the current sources """ files = {} + # write an empty default config file if there aren't any sources + if len(self.list) == 0: + path = "%s%s" % (apt_pkg.Config.FindDir("Dir::Etc"), + apt_pkg.Config.Find("Dir::Etc::sourcelist")) + header = ("## See sources.list(5) for more information, especialy\n" + "# Remember that you can only use http, ftp or file URIs\n" + "# CDROMs are managed through the apt-cdrom tool.\n") + open(path,"w").write(header) + return for source in self.list: if not files.has_key(source.file): files[source.file]=open(source.file,"w") |
