Skip to content

Commit 7065410

Browse files
committed
support multiple file output types and handle missing AOR
Signed-off-by: John Seekins <[email protected]>
1 parent 81a0019 commit 7065410

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ice_scrapers/field_offices.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ def _extract_single_office(element: BeautifulSoup, page_url: str) -> dict:
120120
field_office = element.select_one(".views-field-title")
121121
if field_office:
122122
office["field_office"] = field_office.text.strip()
123-
office["id"] = field_office_to_aor[office["field_office"]]
123+
try:
124+
office["id"] = field_office_to_aor[office["field_office"]]
125+
except Exception:
126+
logger.warning("Could not attach %s as a field office! Maybe update AORs?", office["field_office"])
124127
address = element.select_one(".address-line1")
125128
if address:
126129
office["address"]["street"] = address.text.strip()

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def main() -> None:
5555
)
5656
parser.add_argument(
5757
"--file-type",
58-
default="csv",
5958
choices=supported_output_types,
6059
help="type of file to export",
6160
)
@@ -157,7 +156,11 @@ def main() -> None:
157156
output_filename = args.output_file_name
158157
if args.enrich and not output_filename.endswith("_enriched"):
159158
output_filename = f"{output_filename}_enriched"
160-
export_to_file(facilities_data, output_filename, args.file_type)
159+
if not args.file_type:
160+
for ftype in supported_output_types:
161+
export_to_file(facilities_data, output_filename, ftype)
162+
else:
163+
export_to_file(facilities_data, output_filename, args.file_type)
161164
print_summary(facilities_data)
162165
else:
163166
logger.warning(" No data to export!")

0 commit comments

Comments
 (0)