Skip to content

Commit af480a6

Browse files
committed
chore: run black and clean up imports
1 parent 536a290 commit af480a6

31 files changed

Lines changed: 132 additions & 169 deletions

timetable_kit/amtrak/access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
This has very similar code to baggage.py
99
"""
1010

11-
from io import StringIO # for parsing JSON
1211
import json
12+
from io import StringIO # for parsing JSON
1313

1414
import pandas as pd
1515

timetable_kit/amtrak/accessibility_check.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,18 @@
1111
Requires local bad_stations.csv file: That is generated by "json_stations.py process"
1212
"""
1313
import json
14-
from pathlib import Path
1514
from io import StringIO # Needed to parse JSON
1615

1716
import pandas as pd
1817

19-
# These are mine
20-
21-
from timetable_kit.file_locations import get_timetable_kit_data_home
22-
2318
from timetable_kit.amtrak.json_stations import (
2419
load_stations_json,
2520
load_station_details,
2621
)
2722

2823
# To filter out that which is not a train station
2924
from timetable_kit.amtrak.station_type import is_train_station
25+
from timetable_kit.file_locations import get_timetable_kit_data_home
3026

3127
station_stats_dir = get_timetable_kit_data_home() / "amtrak" / "station_stats"
3228
stations_csv_path = get_timetable_kit_data_home() / "amtrak" / "stations.csv"

timetable_kit/amtrak/agency.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,33 @@
55
66
This holds a class for "AgencyAmtrak" intended to be used as a singleton.
77
"""
8-
from timetable_kit.feed_enhanced import FeedEnhanced # Mostly for typechecking
9-
10-
from timetable_kit.generic_agency import Agency
11-
12-
# for patch_feed
13-
import timetable_kit.amtrak.gtfs_patches as gtfs_patches
14-
158
# for patch_add_wheelchair_boarding
169
import timetable_kit.amtrak.access as access
1710

18-
# for sleeper trains, which trains have checked baggage, major stations, etc
19-
import timetable_kit.amtrak.special_data as special_data
20-
2111
# for whether stations have checked baggage
2212
import timetable_kit.amtrak.baggage as baggage
2313

14+
# for patch_feed
15+
import timetable_kit.amtrak.gtfs_patches as gtfs_patches
16+
2417
# for get_station_name
2518
import timetable_kit.amtrak.json_stations as json_stations
2619

20+
# for get_route_name
21+
import timetable_kit.amtrak.route_names as route_names
22+
23+
# for sleeper trains, which trains have checked baggage, major stations, etc
24+
import timetable_kit.amtrak.special_data as special_data
25+
2726
# for get_station_name_pretty (subroutines)
2827
import timetable_kit.text_assembly as text_assembly
29-
from timetable_kit.text_assembly import SAFE_BR
3028

3129
# Map from station codes to connecting service names
3230
# This is stashed in a class variable
3331
from timetable_kit.amtrak.connecting_services_data import connecting_services_dict
34-
35-
# for get_route_name
36-
import timetable_kit.amtrak.route_names as route_names
32+
from timetable_kit.feed_enhanced import FeedEnhanced # Mostly for typechecking
33+
from timetable_kit.generic_agency import Agency
34+
from timetable_kit.text_assembly import SAFE_BR
3735

3836

3937
class AgencyAmtrak(Agency):

timetable_kit/amtrak/agency_cleanup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def revised_amtrak_agencies(agency):
7171
)
7272
# Edit the lookup table:
7373
# This was only needed for pre-2022 Amtrak data.
74-
agency_lookup_table[
75-
174
76-
] = "Amtrak Directly Operated Thruway Bus" # Is "Amtrak" in feed
74+
agency_lookup_table[174] = (
75+
"Amtrak Directly Operated Thruway Bus" # Is "Amtrak" in feed
76+
)
7777
agency_lookup_table[192] = "Thruway Bus Operator 192"
7878
agency_lookup_table[1206] = "Thruway Bus Operator 1206"
7979
agency_lookup_table[1207] = "Thruway Bus Operator 1207"

timetable_kit/amtrak/baggage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
Requires local copy of Amtrak stations database: That local copy is generated by "json_stations.py download"
88
"""
99

10-
from io import StringIO # for parsing JSON
1110
import json
11+
from io import StringIO # for parsing JSON
1212

1313
import pandas as pd
1414

timetable_kit/amtrak/get_wiki_stations.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
"""
1212

1313
import argparse
14-
from pathlib import Path
1514
import re
1615
from math import nan
16+
from pathlib import Path
1717

1818
import pandas as pd
1919

20-
2120
arg_parser = argparse.ArgumentParser(
2221
formatter_class=argparse.RawDescriptionHelpFormatter,
2322
description="""Process the list of Amtrak stations in Wikipedia.

timetable_kit/amtrak/gtfs_patches.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
"""
88
# TODO: all the Amtrak-specific stuff needs to be made object oriented in an "Amtrak object" perhaps
99

10-
from timetable_kit.debug import debug_print
11-
from timetable_kit.feed_enhanced import FeedEnhanced
12-
1310
# Add the wheelchair boarding information from JSON into the GTFS
1411
from timetable_kit.amtrak.access import patch_add_wheelchair_boarding
12+
from timetable_kit.debug import debug_print
13+
from timetable_kit.feed_enhanced import FeedEnhanced
1514

1615
arizona_stops_list = [
1716
# Sunset Limited
@@ -116,7 +115,7 @@ def patch_hiawatha(feed: FeedEnhanced):
116115

117116

118117
def patch_sunset_limited(feed: FeedEnhanced):
119-
"""Patch a bug where Sunset Limited #2 has wrong departure days.
118+
"""Patch a bug where Sunset Limited #2 has wrong departure days.
120119
It departs from LAX on Su/We/Fr and not Sa/Tu/Th
121120
122121
The bug is because it starts so late it starts on the following day in Eastern Standard Time.
@@ -139,17 +138,17 @@ def patch_sunset_limited(feed: FeedEnhanced):
139138
debug_print(1, "Found #2 listed as running on Saturday, patching")
140139
new_calendar.loc[index, "sunday"] = 0
141140
new_calendar.loc[index, "monday"] = 1
142-
#feed.calendar = new_calendar
141+
# feed.calendar = new_calendar
143142
if new_calendar.loc[index, "wednesday"] == 1: # This is incorrrect.
144143
debug_print(1, "Found #2 listed as running on Tuesday, patching")
145144
new_calendar.loc[index, "wednesday"] = 0
146145
new_calendar.loc[index, "thursday"] = 1
147-
#feed.calendar = new_calendar
146+
# feed.calendar = new_calendar
148147
if new_calendar.loc[index, "friday"] == 1: # This is incorrrect.
149148
debug_print(1, "Found #2 listed as running on Thursday, patching")
150149
new_calendar.loc[index, "friday"] = 0
151150
new_calendar.loc[index, "saturday"] = 1
152-
#feed.calendar = new_calendar
151+
# feed.calendar = new_calendar
153152
feed.calendar = new_calendar
154153

155154

timetable_kit/amtrak/json_stations.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@
1818
# will download Amtrak's station files into the './stations/' directory
1919
# otherwise runs test case
2020

21-
import sys
22-
from pathlib import Path
23-
from io import StringIO # Needed to parse JSON
2421
import argparse
25-
26-
import requests
27-
import json # better for the details import
22+
import random
23+
from io import StringIO # Needed to parse JSON
24+
from pathlib import Path
2825
from time import sleep # Avoid slamming Amtrak's server too fast -- not needed
2926

3027
import pandas as pd
31-
32-
import random
28+
import requests
3329

3430
from timetable_kit.file_locations import get_timetable_kit_data_home
3531

timetable_kit/amtrak/station_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313

1414
import sys # for sys.exit
1515
from io import StringIO # Needed to parse JSON
16-
import pandas as pd
1716

1817
# For parsing the HTML pages
1918
import lxml.html
19+
import pandas as pd
2020

2121
from timetable_kit.amtrak.json_stations import (
2222
load_stations_json,
2323
load_station_details_html,
2424
)
2525

2626
# These are mine
27-
from timetable_kit.debug import set_debug_level, debug_print
27+
from timetable_kit.debug import set_debug_level
2828

2929
# This is a map from what we might see in the web page,
3030
# to the key information in the form:

timetable_kit/amtrak/wiki_station_cleanup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
get station names from Amtrak's JSON data.
1010
"""
1111

12-
import pandas as pd
1312
import gtfs_kit # type: ignore # Tell MyPy this has no type stubs
14-
13+
import pandas as pd
1514

1615
# Cities with multiple stations in the same city, requiring disambiguation
1716
two_station_cities = [

0 commit comments

Comments
 (0)