Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyisi committed Oct 24, 2024
1 parent 126727c commit 68e9040
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/servicex_did_finder_lib/replica_distance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def sort_replicas(self, replicas: List[str], location: Mapping[str, float]) -> L
location: dict of the form {'latitude': xxx, 'longitude': yyy} where xxx and yyy are floats
giving the latitude and longitude in signed degrees
"""
if not self.reader:
if not self._reader:
return replicas
if len(replicas) == 1:
return replicas
fqdns = [(urlparse(replica).hostname, replica) for replica in replicas]
distances = [(_get_distance(self.reader, fqdn, location['latitude'],
distances = [(_get_distance(self._reader, fqdn, location['latitude'],
location['longitude']),
replica) for fqdn, replica in fqdns]
distances.sort()
Expand Down Expand Up @@ -145,15 +145,15 @@ def _download_data(self, db_url_tuple: Optional[Tuple[str, bool]]) -> None:
return
try:
if unpacked:
self.reader = geoip2.database.Reader(fname)
self._reader = geoip2.database.Reader(fname)
else:
tarball = tarfile.open(fname)
self._tmpdir = tempfile.TemporaryDirectory()
tarball.extractall(self._tmpdir.name)
self.reader = geoip2.database.Reader(glob.glob(os.path.join(self._tmpdir.name,
self._reader = geoip2.database.Reader(glob.glob(os.path.join(self._tmpdir.name,
'*/*mmdb')
)[0])
except Exception as e:
logger.error(f'Failure initializing the GeoIP database reader.\nError: {e}')
self.reader = None
self._reader = None
return

0 comments on commit 68e9040

Please sign in to comment.