Skip to content

Commit 6e18282

Browse files
committed
Allow custom Wikifactory API URL
Set with environmental variable `WIF_API_URL`.
1 parent f4408a6 commit 6e18282

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

oshminer/Wikifactory.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Python Standard Library imports
77
from datetime import datetime
88
import json
9+
import os
910
import urllib.parse
1011
import sys
1112

@@ -17,6 +18,14 @@
1718
import oshminer.filetypes as filetypes
1819
from oshminer.errors import exceptions
1920

21+
# Set Wikifactory API URL
22+
# Looks for the `WIF_API_URL` environment variable, and if not found, default to:
23+
# https://wikifactory.com/api/graphql
24+
# See:
25+
# https://www.twilio.com/blog/environment-variables-python
26+
WIF_API_URL: str = os.environ.get("WIF_API_URL", "https://wikifactory.com/api/graphql")
27+
# print(f"Wikifactory API URL: {WIF_API_URL}", file=sys.stderr)
28+
2029
async def get_files_info(project: dict, session) -> dict:
2130
# Provide a GraphQL query
2231
query = gql(
@@ -419,7 +428,7 @@ async def make_Wikifactory_request(url: str, data: list) -> str:
419428
}
420429

421430
# Select transport with the Wikifactory API endpoint URL
422-
transport = AIOHTTPTransport(url = "https://wikifactory.com/api/graphql")
431+
transport = AIOHTTPTransport(url = WIF_API_URL)
423432

424433
# Get "space" and "slug" components from this repository's URL
425434
space_slug: dict = parse_url(url)

0 commit comments

Comments
 (0)