import re
def modify_url(line):
- list = line.split(' ')
+ my_list = line.split(' ')
#on récupère le premier élement envoyé
- old_url = list[0]
+ old_url = my_list[0]
new_url = '\n'
- ubuntu_archive = re.compile('[a-z][a-z].archive.ubuntu.com')
- if ubuntu_archive.search(old_url):
- new_url = 'http://miroir.ndere.cm.refer.org' + new_url
+ ubuntu_archive = re.compile(
+ r'^http://[a-z][a-z]\.archive\.ubuntu\.com/ubuntu')
+ ubuntu_security = re.compile(
+ r'^http://security\.ubuntu\.com/ubuntu')
+ if ubuntu_archive.match(old_url) or ubuntu_security.match(old_url) :
+ new_url = 'http://miroir.ndere.cm.refer.org/ubuntu' + new_url
+
+ debian_archive = re.compile(r'^http://ftp\.[a-z][a-z]\.debian\.org/debian')
+ debian_security = re.compile(r'^http://security\.debian\.org')
+
+ if debian_archive.match(old_url) :
+ new_url = 'http://miroir.ndere.cm.refer.org/debian' + new_url
+ if debian_security.match(old_url) :
+ new_url = 'http://miroir.ndere.cm.refer.org/debian-security' + new_url
return new_url