diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/main.py b/main.py deleted file mode 100644 index 3fbf3e7..0000000 --- a/main.py +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | import json, requests, datetime, argparse, pytz | ||
3 | |||
4 | import library | ||
5 | |||
6 | def parse_args(): | ||
7 | parser = argparse.ArgumentParser() | ||
8 | parser.add_argument('-d', '--days', type=int) | ||
9 | parser.add_argument('-H', '--hours', type=int) | ||
10 | parser.add_argument('-l', '--location', type=str, required=True) | ||
11 | return parser.parse_args() | ||
12 | |||
13 | |||
14 | def hourly_forecast(args, raw_data): | ||
15 | |||
16 | init_time = library.get_current_rounded_time() | ||
17 | if args.hours is not None: | ||
18 | delta = datetime.timedelta(hours=args.hours) | ||
19 | elif args.days is not None: | ||
20 | delta = datetime.timedelta(days=args.days) | ||
21 | else: | ||
22 | delta = datetime.timedelta(hours=(24-init_time.hour)) | ||
23 | end_time = init_time + delta | ||
24 | |||
25 | hourly_data = library.get_hourly_data(raw_data, end_time) | ||
26 | |||
27 | for point in hourly_data: | ||
28 | print(point["time"].strftime("%a %x %I:%M %p")) | ||
29 | print(f'\t Temperature - { point["temp"] }°F') | ||
30 | print(f'\t Humidity - { point["humidity"] }%') | ||
31 | print(f'\t Chance of Precipitation - { point["precip_chance"] }%') | ||
32 | print(f'\t Precipitation Amount - { point["precip_amount"] } in') | ||
33 | print(f'\t Wind Speed - { point["wind_speed"] } MPH') | ||
34 | print(f'\t Wind Direction - { point["wind_direction"] }') | ||
35 | print('\n') | ||
36 | |||
37 | |||
38 | |||
39 | def daily_forecast(raw_data): | ||
40 | pass | ||
41 | |||
42 | |||
43 | def main(): | ||
44 | args = parse_args() | ||
45 | latitude, longitude = library.get_lat_long(args.location) | ||
46 | grid_data = library.get_grid_data(latitude, longitude) | ||
47 | raw_data = library.get_raw_data(grid_data["grid_id"], grid_data["grid_x"], grid_data["grid_y"]) | ||
48 | hourly_forecast(args, raw_data) | ||
49 | |||
50 | |||
51 | |||
52 | if __name__ == '__main__': | ||
53 | main() | ||