34 lines
974 B
Python
34 lines
974 B
Python
|
import argparse
|
||
|
|
||
|
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")
|
||
|
vereine: [Verein] = []
|
||
|
for verein_id in verein_ids:
|
||
|
try:
|
||
|
vereine.append(get_verein_for_id(verein_id))
|
||
|
except RuntimeError:
|
||
|
pass
|
||
|
|
||
|
print("Exporting Verein information")
|
||
|
export_vereine(vereine, args.export_file)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|