Skip to content

Commit bdcd6cc

Browse files
committed
Moved sessions to main function
1 parent 9f4ebe7 commit bdcd6cc

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

scripts/1-fetch/arxiv_fetch.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,6 @@ def initialize_all_data_files(args):
333333
initialize_data_file(FILE_ARXIV_AUTHOR_BUCKET, HEADER_AUTHOR_BUCKET)
334334

335335

336-
session = shared.get_requests_session()
337-
338-
339336
def normalize_license_text(raw_text):
340337
"""
341338
Convert raw license text to standardized CC license identifiers.

scripts/1-fetch/europeana_fetch.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ def parse_arguments():
102102
return args
103103

104104

105-
session = shared.get_requests_session(accept_header="application/json")
106-
107-
108105
def simplify_legal_tool(legal_tool):
109106
"""Simplify license URLs into human-readable labels
110107
@@ -422,7 +419,7 @@ def main():
422419
"EUROPEANA_API_KEY not found in environment variables", 1
423420
)
424421

425-
session = shared.get_requests_session()
422+
session = shared.get_requests_session(accept_header="application/json")
426423

427424
# Fetch facet lists once, including counts
428425
providers_full = get_facet_list(session, "DATA_PROVIDER")

scripts/1-fetch/github_fetch.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ def check_for_completion():
7878
pass # File may not be found without --enable-save, etc.
7979

8080

81-
session = shared.get_requests_session(
82-
headers={"accept": "application/vnd.github+json"},
83-
auth_token=GH_TOKEN,
84-
auth_prefix="Bearer",
85-
)
86-
87-
8881
def write_data(args, tool_data):
8982
if not args.enable_save:
9083
return args
@@ -148,7 +141,11 @@ def main():
148141
args = parse_arguments()
149142
shared.paths_log(LOGGER, PATHS)
150143
check_for_completion()
151-
session = shared.get_requests_session()
144+
session = shared.get_requests_session(
145+
headers={"accept": "application/vnd.github+json"},
146+
auth_token=GH_TOKEN,
147+
auth_prefix="Bearer",
148+
)
152149
tool_data = query_github(args, session)
153150
args = write_data(args, tool_data)
154151
args = shared.git_add_and_commit(

scripts/1-fetch/openverse_fetch.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ def parse_arguments():
8181
return args
8282

8383

84-
session = shared.get_requests_session(accept_header="application/json")
85-
86-
8784
def get_all_sources_and_licenses(session, media_type):
8885
"""
8986
Fetch all available sources for a given media_type.
@@ -212,8 +209,8 @@ def write_data(args, data):
212209

213210
def main():
214211
args = parse_arguments()
215-
session = shared.get_requests_session()
216212
LOGGER.info("Starting Openverse Fetch Script...")
213+
session = shared.get_requests_session(accept_header="application/json")
217214
records = query_openverse(session)
218215
write_data(args, records)
219216
LOGGER.info(f"Fetched {len(records)} unique Openverse records.")

scripts/1-fetch/wikipedia_fetch.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ def parse_arguments():
6363
return args
6464

6565

66-
session = shared.get_requests_session()
67-
68-
6966
def write_data(args, tool_data):
7067
if not args.enable_save:
7168
return args

0 commit comments

Comments
 (0)