From 33e69ef649c1beaeb82a9030ce8c1ed87397f57e Mon Sep 17 00:00:00 2001 From: Wolfgang Fahl Date: Fri, 27 Sep 2024 13:11:17 +0200 Subject: [PATCH] more debugging --- tests/test_smw_api.py | 8 ++++---- wikibot3rd/wikibot.py | 5 +++-- wikibot3rd/wikiclient.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_smw_api.py b/tests/test_smw_api.py index 0e95287..01fbcf5 100644 --- a/tests/test_smw_api.py +++ b/tests/test_smw_api.py @@ -56,11 +56,11 @@ def testGetConcept(self): print(concept) self.assertEqual(concept, "Semantic MediaWiki Cons 2012") - def getSMWs(self, wikiId="smwcopy"): + def getSMWs(self, wikiId="smwcopy",debug:bool=False): """get the alternative SMW access instances for the given wiki id""" wikiuser = self.getSMW_WikiUser(wikiId) - wikibot = WikiBot.ofWikiUser(wikiuser) - wikiclient = WikiClient.ofWikiUser(wikiuser) + wikibot = WikiBot.ofWikiUser(wikiuser,debug=debug) + wikiclient = WikiClient.ofWikiUser(wikiuser,debug=debug) smwbot = SMWBot(wikibot.site) # https://github.com/wikimedia/pywikibot/blob/master/pywikibot/config.py#L719 smwclient = SMWClient(wikiclient.getSite()) @@ -281,7 +281,7 @@ def testIssue5(self): prop, prop, ) - for smw in self.getSMWs("smwcopy"): + for smw in self.getSMWs("smwcopy",debug=debug): result = self.getAskResult(smw, ask) if debug: print(f"{prop}: {result}") diff --git a/wikibot3rd/wikibot.py b/wikibot3rd/wikibot.py index e68ce88..cd8d664 100644 --- a/wikibot3rd/wikibot.py +++ b/wikibot3rd/wikibot.py @@ -44,14 +44,15 @@ def getBots(limit=None, name=None, valueExpr=None): return bots @staticmethod - def ofWikiId(wikiId, lenient=True, debug=False): + def ofWikiId(wikiId, lenient:bool=True, debug:bool=False): wikiUser = WikiUser.ofWikiId(wikiId, lenient=lenient) wikibot = WikiBot(wikiUser, debug=debug) return wikibot @staticmethod - def ofWikiUser(wikiUser): + def ofWikiUser(wikiUser,debug:bool=False): wikibot = WikiBot(wikiUser) + wikibot.debug=debug return wikibot def __init__( diff --git a/wikibot3rd/wikiclient.py b/wikibot3rd/wikiclient.py index c91812a..5e01e5b 100644 --- a/wikibot3rd/wikiclient.py +++ b/wikibot3rd/wikiclient.py @@ -243,7 +243,7 @@ def ofWikiId( wiki_id: str, lenient: bool = True, debug: bool = False ) -> "WikiClient": """Deprecated: Use of_wiki_id instead.""" - return WikiClient.of_wiki_id(wiki_id, lenient, debug) + return WikiClient.of_wiki_id(wiki_id, lenient=lenient, debug=debug) @staticmethod def of_wiki_user(wiki_user: WikiUser) -> "WikiClient":