Commit a8902e87 by Michael DeHaan

Merge pull request #4347 from sashka/devel

Remove options and protocols in source line with regex.
parents 4826d4b8 2bd6c5e2
......@@ -133,16 +133,14 @@ class SourcesList(object):
return os.path.abspath(os.path.join(apt_pkg.config.find_dir('Dir::Etc::sourceparts'), filename))
def _suggest_filename(self, line):
def _remove_protocol(s):
if '://' in s:
return s.split('://')[1]
else:
return s
def _cleanup_filename(s):
return '_'.join(re.sub('[^a-zA-Z0-9]', ' ', s).split())
parts = [_remove_protocol(part) for part in line.split() if part not in VALID_SOURCE_TYPES]
# Drop options and protocols.
line = re.sub('\[[^\]]+\]', '', line)
line = re.sub('\w+://', '', line)
parts = [part for part in line.split() if part not in VALID_SOURCE_TYPES]
return '%s.list' % _cleanup_filename(' '.join(parts[:1]))
def _parse(self, line, raise_if_invalid_or_disabled=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment