Skip to content

Commit

Permalink
reformats
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jul 27, 2024
1 parent a337afe commit bea95c0
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 22 deletions.
1 change: 1 addition & 0 deletions tests/basetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import getpass
import os
import time
Expand Down
1 change: 1 addition & 0 deletions tests/test_MediaWikiTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import unittest
from datetime import date, datetime

Expand Down
38 changes: 23 additions & 15 deletions tests/test_SMWApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import unittest
from datetime import datetime
from unittest.mock import patch
Expand Down Expand Up @@ -432,11 +433,12 @@ def _askForAllResults_mock_sideEffect(query, limit):
if query == expectedQuery:
return [RESULT_N(i)]

with patch(
"wikibot3rd.smw.SMWClient.askForAllResults"
) as askForAllResults_mock, patch(
"wikibot3rd.smw.SMWClient.getBoundariesOfQuery"
) as getBoundariesOfQuery:
with (
patch("wikibot3rd.smw.SMWClient.askForAllResults") as askForAllResults_mock,
patch(
"wikibot3rd.smw.SMWClient.getBoundariesOfQuery"
) as getBoundariesOfQuery,
):
getBoundariesOfQuery.return_value = (
datetime.strptime("01/01/2020 00:00:00", "%d/%m/%Y %H:%M:%S"),
datetime.strptime("11/01/2020 00:00:00", "%d/%m/%Y %H:%M:%S"),
Expand Down Expand Up @@ -528,11 +530,14 @@ def askForAllResults_mock_side_effect(query, limit=None, kwargs={}):
for smw in self.getSMWs():
if isinstance(smw, SMWClient):
# Test default case
with patch(
"wikibot3rd.smw.SMWClient.askForAllResults"
) as askForAllResults_mock, patch(
"wikibot3rd.smw.SMWClient.askPartitionQuery"
) as askPartitionQuery_mock:
with (
patch(
"wikibot3rd.smw.SMWClient.askForAllResults"
) as askForAllResults_mock,
patch(
"wikibot3rd.smw.SMWClient.askPartitionQuery"
) as askPartitionQuery_mock,
):
askForAllResults_mock.return_value = [RESULT]
askPartitionQuery_mock.return_value = None
result = smw.ask(QUERY)
Expand All @@ -541,11 +546,14 @@ def askForAllResults_mock_side_effect(query, limit=None, kwargs={}):
self.assertEqual(askPartitionQuery_mock.call_count, 0)
# Test if query division is used if 'queryDivision' attribute is set above 1
smw.queryDivision = 10
with patch(
"wikibot3rd.smw.SMWClient.askForAllResults"
) as askForAllResults_mock, patch(
"wikibot3rd.smw.SMWClient.askPartitionQuery"
) as askPartitionQuery_mock:
with (
patch(
"wikibot3rd.smw.SMWClient.askForAllResults"
) as askForAllResults_mock,
patch(
"wikibot3rd.smw.SMWClient.askPartitionQuery"
) as askPartitionQuery_mock,
):
askForAllResults_mock.return_value = None
askPartitionQuery_mock.return_value = [RESULT]
result = smw.ask(QUERY)
Expand Down
1 change: 1 addition & 0 deletions tests/test_Selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Created on 2020-12-20
@author: wf
"""

import getpass
import logging
import sys
Expand Down
1 change: 1 addition & 0 deletions tests/test_WikiPush.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import io
import os
import unittest
Expand Down
1 change: 1 addition & 0 deletions tests/test_WikiUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import os
import tempfile
import unittest
Expand Down
1 change: 1 addition & 0 deletions tests/test_duckinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import unittest

from tests.basetest import BaseTest
Expand Down
1 change: 1 addition & 0 deletions tests/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import unittest

from lodstorage.query import Query
Expand Down
1 change: 1 addition & 0 deletions tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import os

import yaml
Expand Down
1 change: 1 addition & 0 deletions tests/test_wikibot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import unittest

from tests.basetest import BaseTest
Expand Down
1 change: 1 addition & 0 deletions tests/test_wikiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

from tests.basetest import BaseTest
from wikibot3rd.wikiclient import WikiClient

Expand Down
1 change: 1 addition & 0 deletions tests/test_wikiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import json
import unittest
from contextlib import redirect_stdout
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import base64
import os
import secrets
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/lambda_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import html
import re

Expand Down
7 changes: 3 additions & 4 deletions wikibot3rd/smw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import re
import sys
from datetime import datetime
Expand Down Expand Up @@ -501,10 +502,8 @@ def askForAllResults(self, query, limit=None, kwargs={}):
Raises:
QueryResultSizeExceedException: Raised if not all results can be retrieved
"""
endShowProgress = (
lambda showProgress, c: print("\n" if not c % 80 == 0 else "")
if showProgress
else None
endShowProgress = lambda showProgress, c: (
print("\n" if not c % 80 == 0 else "") if showProgress else None
)
offset = 0
done = False
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
with ChatGPT-4 prompting
"""

import base64
import hashlib
import socket
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import wikibot3rd


Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikiaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

from lodstorage.query import Query

from wikibot3rd.lambda_action import Code, LambdaAction
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikibackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikibot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import re
import sys
from os.path import isfile
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikiedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikinuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down
8 changes: 5 additions & 3 deletions wikibot3rd/wikipush.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@copyright: Wolfgang Fahl. All rights reserved.
"""

import datetime

# from difflib import Differ
Expand Down Expand Up @@ -424,7 +425,7 @@ def upload(self, files, force=False):
self.uploadImage(file, filename, description, force)
self.log("✅")
except Exception as ex:
self.show_exception(ex)
self.show_exception(ex)

def backup(self, pageTitles, backupPath=None, git=False, withImages=False):
"""
Expand Down Expand Up @@ -626,7 +627,7 @@ def pushImages(self, imageList, delim="", ignore=False):
print(image.imageinfo)
except Exception as ex:
self.handleException(ex, ignore)

def show_exception(self, ex: Exception):
"""
Show the given exception and, if debug mode is on, show the traceback.
Expand All @@ -635,7 +636,7 @@ def show_exception(self, ex: Exception):
if self.debug:
# Append the formatted traceback to the message
msg += "\n" + traceback.format_exc()

self.log(msg)

def handleException(self, ex, ignoreExists=False):
Expand Down Expand Up @@ -803,6 +804,7 @@ def restore(self, pageTitles=None, backupPath=None, listFile=None, stdIn=False):
except Exception as ex:
self.show_exception(ex)


__version__ = Version.version
__date__ = Version.date
__updated__ = Version.updated
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikirestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikitext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Created on 2023-02-24
@author: tholzheim
"""

import typing
import warnings

Expand Down
1 change: 1 addition & 0 deletions wikibot3rd/wikiupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: wf
"""

import sys

import wikibot3rd.wikipush
Expand Down

0 comments on commit bea95c0

Please sign in to comment.