fucking fedora.
This commit is contained in:
		
							parent
							
								
									3ece313a6f
								
							
						
					
					
						commit
						1a5068d77d
					
				| @ -25,47 +25,54 @@ class Ranker(classes.Ranker): | ||||
|         if preferred_proto not in ('rsync', 'ftp'): | ||||
|             raise ValueError('Invalid preferred_proto; must be one of rsync or ftp') | ||||
|         non_preferred = ('rsync' if preferred_proto == 'ftp' else 'ftp') | ||||
|         mirror_section = self.bs.find('h2', string = 'Public active mirrors') | ||||
|         mirror_table = mirror_section.find_next('table') | ||||
|         if mirror_table is None: | ||||
|             return(None) | ||||
|         # https://stackoverflow.com/a/56835562/733214 | ||||
|         headers = [h.text for h in mirror_table.find_all('th')] | ||||
|         rows = [m for m in mirror_table.find_all('tr')][1:] | ||||
|         for row in rows: | ||||
|             mirror = {} | ||||
|             do_skip = False | ||||
|             for idx, cell in enumerate(row.find_all('td')): | ||||
|                 k = headers[idx] | ||||
|                 v = cell.text.strip() | ||||
|                 if k == 'Country' and v != self.my_info['country']: | ||||
|                     do_skip = True | ||||
|                     continue | ||||
|                 if k == 'Categories' and not do_skip: | ||||
|                     if 'EPEL' not in v: | ||||
|                         do_skip = True | ||||
|                         continue | ||||
|                     pref_proto = cell.find('a', attrs = { | ||||
|                         'href': re.compile(r'^{0}://'.format(preferred_proto), re.IGNORECASE)}) | ||||
|                     non_pref = cell.find('a', attrs = { | ||||
|                         'href': re.compile(r'^{0}://'.format(non_preferred), re.IGNORECASE)}) | ||||
|                     if pref_proto is not None: | ||||
|                         v = pref_proto['href'] | ||||
|                     elif non_pref is not None: | ||||
|                         v = non_pref['href'] | ||||
|                     else: | ||||
|                         v = None | ||||
|                     mirror['url'] = v | ||||
|                 # Fedora team can't spell. | ||||
|                 elif k in ('Bandwidth', 'Bandwith'): | ||||
|                     mirror['bw'] = int(v) | ||||
|             if do_skip: | ||||
|                 continue | ||||
|             if not mirror['url']: | ||||
|                 continue | ||||
|             self.raw_mirrors.append(mirror) | ||||
|             self.mirror_candidates.append(mirror['url']) | ||||
|         print(('Fedora (who maintains EPEL) do their mirroring in an extremely weird way.\n' | ||||
|                'See https://fedoraproject.org/wiki/Infrastructure/Mirroring and ' | ||||
|                'https://fedoraproject.org/wiki/Infrastructure/Mirroring/Tiering#Tier_1_Mirrors for which mirrors and ' | ||||
|                'how to sync.')) | ||||
|         return(None) | ||||
|         # mirror_section = self.bs.find('h2', string = 'Public active mirrors') | ||||
|         # mirror_table = mirror_section.find_next('table') | ||||
|         # if mirror_table is None: | ||||
|         #     return(None) | ||||
|         # # https://stackoverflow.com/a/56835562/733214 | ||||
|         # headers = [h.text for h in mirror_table.find_all('th')] | ||||
|         # rows = [m for m in mirror_table.find_all('tr')][1:] | ||||
|         # for row in rows: | ||||
|         #     mirror = {} | ||||
|         #     do_skip = False | ||||
|         #     for idx, cell in enumerate(row.find_all('td')): | ||||
|         #         k = headers[idx] | ||||
|         #         v = cell.text.strip() | ||||
|         #         if k == 'Country' and v != self.my_info['country']: | ||||
|         #             do_skip = True | ||||
|         #             continue | ||||
|         #         if k == 'Categories' and not do_skip: | ||||
|         #             # TODO: DO THIS BETTER! Their mirrorlist sucks and is not easily parsed at all. | ||||
|         #             # I need to check and try to grab the specific URL that contains "epel". | ||||
|         #             if 'EPEL' not in v: | ||||
|         #                 do_skip = True | ||||
|         #                 continue | ||||
|         #             pref_proto = cell.find('a', attrs = { | ||||
|         #                 'href': re.compile(r'^{0}://'.format(preferred_proto), re.IGNORECASE)}) | ||||
|         #             non_pref = cell.find('a', attrs = { | ||||
|         #                 'href': re.compile(r'^{0}://'.format(non_preferred), re.IGNORECASE)}) | ||||
|         #             if pref_proto is not None: | ||||
|         #                 v = pref_proto['href'] | ||||
|         #             elif non_pref is not None: | ||||
|         #                 v = non_pref['href'] | ||||
|         #             else: | ||||
|         #                 v = None | ||||
|         #             mirror['url'] = v | ||||
|         #         # Fedora team can't spell. | ||||
|         #         elif k in ('Bandwidth', 'Bandwith'): | ||||
|         #             mirror['bw'] = int(v) | ||||
|         #     if do_skip: | ||||
|         #         continue | ||||
|         #     if not mirror['url']: | ||||
|         #         continue | ||||
|         #     self.raw_mirrors.append(mirror) | ||||
|         #     self.mirror_candidates.append(mirror['url']) | ||||
|         # return(None) | ||||
| 
 | ||||
| 
 | ||||
| def parseArgs(): | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user