@@ -641,26 +641,25 @@ for year in sorted(yearly_stats.keys()):
641
641
# Find the most popular year
642
642
best_year = max(yearly_stats.keys(), key=lambda y: yearly_stats[y])
643
643
print(f"\n Best year: {best_year} with {yearly_stats[best_year]:,} unique IPs")
644
+ ` ` `
644
645
645
- # Example: List all sites sorted by total unique IPs
646
- def get_sites_ranking():
647
- """Get all sites ranked by total unique IPs."""
648
- import json
649
-
650
- with urllib.request.urlopen('https://sites.imagej.net/sites.json') as response:
651
- sites_data = json.load(response)
646
+ And another example to list all sites sorted by total unique IPs:
647
+ ` ` ` python
648
+ import json
649
+ import urllib.request
652
650
653
- # Sort sites by total unique IPs
654
- ranked_sites = sorted(
655
- sites_data.items(),
656
- key=lambda x: x[1]['total_unique_ips'],
657
- reverse=True
658
- )
651
+ with urllib.request.urlopen('https://sites.imagej.net/sites.json') as response:
652
+ sites_data = json.load(response)
659
653
660
- print("Sites ranked by total unique IPs:")
661
- for site_name, metadata in ranked_sites:
662
- print(f" {site_name}: {metadata['total_unique_ips']:,} unique IPs "
663
- f"({metadata['days_with_data']} days of data)")
654
+ # Sort sites by total unique IPs
655
+ ranked_sites = sorted(
656
+ sites_data.items(),
657
+ key=lambda x: x[1]['total_unique_ips'],
658
+ reverse=True
659
+ )
664
660
665
- get_sites_ranking()
661
+ print("Sites ranked by total unique IPs:")
662
+ for site_name, metadata in ranked_sites:
663
+ print(f" {site_name}: {metadata['total_unique_ips']:,} unique IPs "
664
+ f"({metadata['days_with_data']} days of data)")
666
665
` ` `
0 commit comments