Skip to content

Commit

Permalink
Black formatting and types for achive method
Browse files Browse the repository at this point in the history
  • Loading branch information
jessemortenson committed Jul 31, 2024
1 parent 2442a91 commit f289b27
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions openstates/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,21 @@ def do_scrape(
return report


def archive_to_cloud_storage(datadir, juris, last_scrape_end_datetime):
def archive_to_cloud_storage(
datadir: str, juris: State, last_scrape_end_datetime: datetime.datetime
) -> None:
# check if we have necessary settings
if GCP_PROJECT is None or BUCKET_NAME is None:
logger.error("Scrape archiving is turned on, but necessary settings are missing. No archive was done.")
logger.error(
"Scrape archiving is turned on, but necessary settings are missing. No archive was done."
)
return
cloud_storage_client = storage.Client()
bucket = cloud_storage_client.bucket(BUCKET_NAME, GCP_PROJECT)
jurisdiction_id = juris.jurisdiction_id.replace("ocd-jurisdiction/", "")
destination_prefx = f"{SCRAPE_LAKE_PREFIX}/{jurisdiction_id}/{last_scrape_end_datetime.isoformat()}"
destination_prefx = (
f"{SCRAPE_LAKE_PREFIX}/{jurisdiction_id}/{last_scrape_end_datetime.isoformat()}"
)

# read files in directory and upload
for file_path in glob.glob(datadir + "/*.json"):
Expand Down

0 comments on commit f289b27

Please sign in to comment.