XZise has submitted this change and it was merged.
Change subject: Use sensible default for config.mylang ......................................................................
Use sensible default for config.mylang
If the user has not altered user-config.mylang, it is set to 'language' and pywikibot.Site() raises a confusing exception: UnknownSite: Language language does not exist in family wikipedia
Detect this situation, report a warning, and set the default to family 'test' and mylang 'test, which is test.wikipedia.org.
Change-Id: I3b890039381c7f8d06dfe6c0d83140ec5f2f3ed6 --- M pywikibot/config2.py 1 file changed, 7 insertions(+), 0 deletions(-)
Approvals: XZise: Looks good to me, approved
diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 4e01416..55453dc 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -50,6 +50,8 @@ family = 'wikipedia' # The language code of the site we're working on. mylang = 'language' +# If family and mylang are not modified from the above, the default is changed +# to test:test, which is test.wikipedia.org, at the end of this module.
# The dictionary usernames should contain a username for each site where you # have a bot account. Please set your usernames by adding such lines to your @@ -831,6 +833,11 @@ elif transliteration_target in ('None', 'none'): transliteration_target = None
+# Fix up default site +if family == 'wikipedia' and mylang == 'language': + print("WARNING: family and mylang are not set.\n" + "Defaulting to family='test' and mylang='test'.") + family = mylang = 'test'
# # When called as main program, list all configuration variables