Skip to content

Commit efc1fc6

Browse files
committed
Made requested changes
1 parent 7448af1 commit efc1fc6

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

scripts/1-fetch/wikipedia_fetch.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
from requests.adapters import HTTPAdapter
2020
from urllib3.util.retry import Retry
2121

22-
# First-party/Local
23-
import shared # noqa: E402
24-
from shared import STATUS_FORCELIST, USER_AGENT
25-
2622
# Add parent directory so shared can be imported
2723
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
2824

25+
# First-party/Local
26+
import shared # noqa: E402
27+
2928
# Setup
3029
LOGGER, PATHS = shared.setup(__file__)
3130
FILE_LANGUAGES = os.path.join(
@@ -63,11 +62,11 @@ def get_requests_session():
6362
max_retries = Retry(
6463
total=5,
6564
backoff_factor=10,
66-
status_forcelist=STATUS_FORCELIST,
65+
status_forcelist=shared.STATUS_FORCELIST,
6766
)
6867
session = requests.Session()
6968
session.mount("https://", HTTPAdapter(max_retries=max_retries))
70-
session.headers.update({"User-Agent": USER_AGENT})
69+
session.headers.update({"User-Agent": shared.USER_AGENT})
7170
return session
7271

7372

scripts/shared.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
from git import InvalidGitRepositoryError, NoSuchPathError, Repo
88
from pandas import PeriodIndex
99

10-
USER_AGENT = (
11-
"QuantifyingTheCommons/1.0 "
12-
"(https://github.com/creativecommons/quantifying)"
13-
)
1410
STATUS_FORCELIST = [
1511
408, # Request Timeout
1612
422, # Unprocessable Content (Validation failed, or endpoint spammed)
@@ -21,6 +17,11 @@
2117
504, # Gateway Timeout
2218
]
2319

20+
USER_AGENT = (
21+
"QuantifyingTheCommons/1.0 "
22+
"(https://github.com/creativecommons/quantifying)"
23+
)
24+
2425

2526
class QuantifyingException(Exception):
2627
def __init__(self, message, exit_code=None):

0 commit comments

Comments
 (0)