Lines 44-49
class MirrorParser3:
Link Here
|
44 |
def _reset(self): |
44 |
def _reset(self): |
45 |
self._dict = {} |
45 |
self._dict = {} |
|
|
46 |
def _get_proto(self, uri=None): |
47 |
if not uri: # Don't parse if empty |
48 |
return None; |
49 |
try: |
50 |
import sys; |
51 |
if sys.version_info[0] >= 3: |
52 |
from urllib.parse import urlparse |
53 |
return urlparse(uri).scheme |
54 |
else: |
55 |
from urllib2 import Request |
56 |
return Request(uri).get_type() |
57 |
except Exception as e: # Add general exception to catch errors |
58 |
from mirrorselect.output import Output |
59 |
Output.write(('_get_proto(): Exception while parsing the protocol ' |
60 |
'for URI %s: %s\n')% (uri, e), 2) |
61 |
|
46 |
def parse(self, text): |
62 |
def parse(self, text): |
47 |
self._reset() |
63 |
self._reset() |
48 |
for mirrorgroup in ET.XML(text): |
64 |
for mirrorgroup in ET.XML(text): |
Lines 60-66
class MirrorParser3:
Link Here
|
60 |
"region": mirrorgroup.get("region"), |
76 |
"region": mirrorgroup.get("region"), |
61 |
"ipv4": e.get("ipv4"), |
77 |
"ipv4": e.get("ipv4"), |
62 |
"ipv6": e.get("ipv6"), |
78 |
"ipv6": e.get("ipv6"), |
63 |
"proto": e.get("protocol"), |
79 |
"proto": e.get("protocol") or self._get_proto(uri), |
64 |
} |
80 |
} |
65 |
def tuples(self): |
81 |
def tuples(self): |
66 |
- |
|
|