Skip to content

Commit 77977f0

Browse files
committed
Allow custom Wikifactory project base URL
Replace `wikifactory.com` with `example.com` in accepted project URLs through environment variable.
1 parent 90dff20 commit 77977f0

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

oshminer/supported_platforms.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@
33
# SPDX-FileCopyrightText: 2022 Pen-Yuan Hsing
44
# SPDX-License-Identifier: AGPL-3.0-or-later
55

6+
# Python Standard Library imports
7+
import os
8+
import sys
9+
10+
# Internal imports
611
import oshminer.GitHub
712
import oshminer.Wikifactory
813

14+
# Set Wikifactory base URL for projects
15+
# Looks for the `WIF_BASE_URL` environment variable, and if not found, default to:
16+
# `wikifactory.com`
17+
# See:
18+
# https://www.twilio.com/blog/environment-variables-python
19+
WIF_BASE_URL: str = os.environ.get("WIF_BASE_URL", "wikifactory.com")
20+
print(f"Wikifactory base URL: {WIF_BASE_URL}", file=sys.stderr)
21+
922
# Supported hosting platforms as a dictionary of their domains, which are
1023
# matched to names of internal functions that construct API requests to the
1124
# associated platforms.
12-
# `repo_urls` need to include one of these domains.
25+
# `repo_urls` in the request body needs to include one of these domains.
1326
supported_domains: dict = {
1427
"github.com": oshminer.GitHub.make_GitHub_request,
15-
"wikifactory.com": oshminer.Wikifactory.make_Wikifactory_request
28+
WIF_BASE_URL: oshminer.Wikifactory.make_Wikifactory_request
1629
}

0 commit comments

Comments
 (0)