2023-05-15 14:35:18 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2023-05-15 09:30:56 +02:00
|
|
|
import argparse
|
2023-05-15 10:02:05 +02:00
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
2023-05-15 09:30:56 +02:00
|
|
|
|
|
|
|
from csv_exporter import export_vereine
|
|
|
|
from verein import Verein
|
|
|
|
from verein_fetcher import get_verein_ids_near_location, get_verein_for_id
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
prog='Rewe Vereinsscheine',
|
|
|
|
description='Get the amount of Vereinsscheine for Vereine near a location')
|
|
|
|
parser.add_argument('latitude')
|
|
|
|
parser.add_argument('longitude')
|
|
|
|
parser.add_argument('-f', '--export-file', default='vereine.csv', required=False)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
print("Fetching Vereine")
|
|
|
|
verein_ids = get_verein_ids_near_location(args.latitude, args.longitude)
|
|
|
|
|
|
|
|
print("Getting Verein information")
|
2023-05-15 10:02:05 +02:00
|
|
|
vereine: [Verein]
|
|
|
|
with ThreadPoolExecutor() as executor:
|
|
|
|
vereine = list(executor.map(get_verein_for_id, verein_ids))
|
2023-05-15 09:30:56 +02:00
|
|
|
|
|
|
|
print("Exporting Verein information")
|
|
|
|
export_vereine(vereine, args.export_file)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|