[SCM] GUI front-end for Debian Live. branch, master, updated. 11e67a56b24563c3f7a488602604f9ba897740c3
Chris Lamb
chris at chris-lamb.co.uk
Tue Mar 4 03:01:20 UTC 2008
The following commit has been merged in the master branch:
commit 0e0283730d8e7b3efb3a81064ee27240f329624b
Author: Chris Lamb <chris at chris-lamb.co.uk>
Date: Tue Mar 4 03:00:28 2008 +0000
Move sources.list heuristics into DebianLive.utils.
Signed-off-by: Chris Lamb <chris at chris-lamb.co.uk>
diff --git a/DebianLive/utils/sources_list.py b/DebianLive/utils/sources_list.py
new file mode 100644
index 0000000..a84f00d
--- /dev/null
+++ b/DebianLive/utils/sources_list.py
@@ -0,0 +1,55 @@
+import os
+import re
+
+class SourcesList(object):
+ comments = re.compile(r'\s*#')
+ patterns = (
+ re.compile(r'http://ftp.?\..{2}\.debian\.org[^\s]*'),
+ re.compile(r'http://(localhost|127\.0\.0\.1)[^\s]*'),
+ re.compile(r'http://[^\s]*'),
+ )
+ reject_patterns = (
+ re.compile(r'backports\.'),
+ re.compile(r'security\.'),
+ )
+
+ def __init__(self, filename=None):
+ if filename is None:
+ filename = r'/etc/apt/sources.list'
+
+ self.filename = filename
+
+ def get_mirror(self, fallback=None):
+ if fallback is not None:
+ fallback = 'http://www.us.debian.org/'
+
+ result = fallback
+
+ f = open(self.filename, 'r')
+ try:
+ try:
+ for line in f.readlines():
+ if self.comments.match(line):
+ continue
+
+ flag = False
+ for pat in self.reject_patterns:
+ m = pat.search(line)
+ if m:
+ flag = True
+ break
+ if flag:
+ continue
+
+ for pat in self.patterns:
+ m = pat.search(line)
+ if not m:
+ continue
+
+ result = m.group(0)
+ finally:
+ f.close()
+ except IOError:
+ pass
+
+ return result
--
GUI front-end for Debian Live.
More information about the debian-live-changes
mailing list