summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorMichael Vogt <egon@top>2005-12-05 13:58:50 +0100
committerMichael Vogt <egon@top>2005-12-05 13:58:50 +0100
commit94cf8cacad5850683d35b84682ab024fb7636df0 (patch)
treee89748b8970ccab7627c8325fd83b6f14e203b51 /SoftwareProperties
parent05dfbc4450a14f46fe5719f3bf321345f8b422ed (diff)
downloadpython-apt-94cf8cacad5850683d35b84682ab024fb7636df0.tar.gz
* DistUpgrade/ tool started
* SoftwareProperties/aptsources.py: - added "backup" and some comments * UpdateManager/UpdateManager.py: - comments updated
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/aptsources.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index aa3cbb5a..d059a719 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -26,6 +26,8 @@ import gettext
import re
import apt_pkg
import glob
+import shutil
+import time
from UpdateManager.Common.DistInfo import DistInfo
@@ -156,6 +158,11 @@ class SourcesList:
for file in glob.glob("%s/*.list" % partsdir):
self.load(file)
+ def __iter__(self):
+ for entry in self.list:
+ yield entry
+ raise StopIteration
+
def is_mirror(self, add_uri, orig_uri):
"""check if the given add_url is idential or a mirror of orig_uri
e.g. add_uri = archive.ubuntu.com
@@ -204,7 +211,19 @@ class SourcesList:
def remove(self, source_entry):
self.list.remove(source_entry)
+ def backup(self, backup_ext=None):
+ """ make a backup of the current source files, if no backup extension
+ is given, the current date/time is used (and returned) """
+ already_backuped = set()
+ if backup_ext == None:
+ backup_ext = time.strftime("%d%m%y.%H%M")
+ for source in self.list:
+ if not source.file in already_backuped:
+ shutil.copy(source.file,"%s.%s" % (source.file,backup_ext))
+ return backup_ext
+
def load(self,file):
+ """ (re)load the current sources """
f = open(file, "r")
lines = f.readlines()
for line in lines:
@@ -213,6 +232,7 @@ class SourcesList:
f.close()
def save(self,file):
+ """ save the current sources """
files = {}
for source in self.list:
if not files.has_key(source.file):