initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Coded by [email protected]
|
||||
|
||||
""" Geolocation info """
|
||||
class GeoData(object):
|
||||
def __init__(self, geo_data: dict):
|
||||
u = "Unknown"
|
||||
self.ip_address = geo_data["ip_address"]
|
||||
try: self.city = geo_data["city"]["names"]["en"]
|
||||
except: self.city = u
|
||||
try: self.country = geo_data["country"]["names"]["en"]
|
||||
except: self.country = u
|
||||
try: self.iso_code = geo_data["country"]["iso_code"]
|
||||
except: self.iso_code = u
|
||||
|
||||
""" Get country statistics """
|
||||
def GetCountryStatistics(reports: list) -> dict:
|
||||
stats = {}
|
||||
for report in reports:
|
||||
if not report.geo_data.iso_code in stats:
|
||||
stats[report.geo_data.iso_code] = []
|
||||
stats[report.geo_data.iso_code].append(report.geo_data)
|
||||
return stats
|
||||
Reference in New Issue
Block a user