import datetime
import logging
+import iso3166
import math
import os.path
import random
return self._get_mirror("SELECT * FROM mirrors \
WHERE hostname = %s", hostname)
+ def get_by_countries(self):
+ mirrors = {}
+
+ for m in self:
+ try:
+ mirrors[m.country].append(m)
+ except KeyError:
+ mirrors[m.country] = [m]
+
+ return mirrors
+
class Mirror(Object):
def init(self, id, data=None):
if self.location:
return self.location.longitude
+ @lazy_property
+ def country(self):
+ return iso3166.countries.get(self.country_code)
+
@property
def country_code(self):
return self.data.country_code