jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876306 )
Change subject: [doc] Allow setting a theme with make.bat
......................................................................
[doc] Allow setting a theme with make.bat
The default furo build needs several minutes to be completed.
This patch enables to use other themes like "basic" od "nature"
to speed up building a documentation. The theme must be added to
the target option like
make html nature
The time usage was also added.
Bug: T322979
Change-Id: I3daa81a12cbeff708cea7cf3334b3199dca2b1b3
---
M docs/make.bat
1 file changed, 56 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/make.bat b/docs/make.bat
index 6726495..7819bc3 100644
--- a/docs/make.bat
+++ b/docs/make.bat
@@ -15,6 +15,10 @@
if "%1" == "" goto help
if "%1" == "help" goto help
+if "%2" == "" goto notheme
+set SPHINXOPTS=%SPHINXOPTS% -D "html_theme=%2"
+:notheme
+
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
@@ -28,14 +32,45 @@
exit /b 1
)
+set STARTTIME=%TIME:~0,8%
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
+set ENDTIME=%TIME:~0,8%
+
+echo Start: %STARTTIME%
+echo End: %ENDTIME%
+
+rem calculate elapsed time, code modified from
+rem https://stackoverflow.com/questions/4487100/how-can-i-use-a-windows-batch-f…
+
+rem convert STARTTIME and ENDTIME to seconds
+set /A STARTTIME=(1%STARTTIME:~0,2%-100)*3600 + (1%STARTTIME:~3,2%-100)*60 + (1%STARTTIME:~6,2%-100)
+set /A ENDTIME=(1%ENDTIME:~0,2%-100)*3600 + (1%ENDTIME:~3,2%-100)*60 + (1%ENDTIME:~6,2%-100)
+
+rem calculating the duratyion is easy
+set /A DURATION=%ENDTIME%-%STARTTIME%
+
+rem we might have measured the time inbetween days
+if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
+
+rem now break the seconds down to hors, minutes, seconds
+set /A DURATIONH=%DURATION% / 3600
+set /A DURATIONM=(%DURATION% - %DURATIONH%*3600) / 60
+set /A DURATIONS=(%DURATION% - %DURATIONH%*3600 - %DURATIONM%*60)
+
+rem some formatting
+if %DURATIONH% LSS 10 set DURATIONH=0%DURATIONH%
+if %DURATIONM% LSS 10 set DURATIONM=0%DURATIONM%
+if %DURATIONS% LSS 10 set DURATIONS=0%DURATIONS%
+
+echo Elapsed: %DURATIONH%:%DURATIONM%:%DURATIONS%
+
goto end
:help
echo.
echo make has the following options:
-echo make ^<target^> [^<sphinx options^>]
-echo make html -D "html_theme=basic"
+echo make ^<target^> [^<theme^>]
+echo make html basic
echo.
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR%
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876306
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3daa81a12cbeff708cea7cf3334b3199dca2b1b3
Gerrit-Change-Number: 876306
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874026 )
Change subject: [IMPR] improve warning if a Non-JSON response was received from server
......................................................................
[IMPR] improve warning if a Non-JSON response was received from server
- remove html script part to be more informative
- show the warning only once (but to not check if the html page is
really the same)
- remove multiple empty lines
- use f-string formatting
Bug: T326046
Change-Id: I03d410fcfe0e0b8e72f89667d259da79ccbeb1e6
---
M pywikibot/data/api/_requests.py
1 file changed, 33 insertions(+), 12 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index a4d2f6c..9d4dc8e 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -1,6 +1,6 @@
"""Objects representing API requests."""
#
-# (C) Pywikibot team, 2007-2022
+# (C) Pywikibot team, 2007-2023
#
# Distributed under the terms of the MIT license.
#
@@ -35,7 +35,7 @@
TimeoutError,
)
from pywikibot.login import LoginStatus
-from pywikibot.textlib import removeHTMLParts
+from pywikibot.textlib import removeDisabledParts, removeHTMLParts
from pywikibot.tools import PYTHON_VERSION
@@ -203,6 +203,7 @@
self.retry_wait = pywikibot.config.retry_wait
else:
self.retry_wait = retry_wait
+ self.json_warning = False
# The only problem with that system is that it won't detect when
# 'parameters' is actually the only parameter for the request as it
# then assumes it's using the new mode (and the parameters are actually
@@ -720,19 +721,21 @@
try:
result = response.json()
except ValueError:
- # if the result isn't valid JSON, there may be a server
- # problem. Wait a few seconds and try again
- # Show 20 lines of bare text
- text = '\n'.join(removeHTMLParts(response.text).splitlines()[:20])
- msg = """\
-Non-JSON response received from server {site} for url
-{resp.url}
+ # if the result isn't valid JSON, there may be a server problem.
+ # Wait a few seconds and try again.
+ # Show 20 lines of bare text without script parts
+ text = removeDisabledParts(response.text, ['script'])
+ text = re.sub('\n{2,}', '\n',
+ '\n'.join(removeHTMLParts(text).splitlines()[:20]))
+ msg = f"""\
+Non-JSON response received from server {self.site} for url
+{response.url}
The server may be down.
-Status code: {resp.status_code}
+Status code: {response.status_code}
The text message is:
{text}
-""".format(site=self.site, resp=response, text=text)
+"""
# Do not retry for AutoFamily but raise a SiteDefinitionError
# Note: family.AutoFamily is a function to create that class
@@ -741,7 +744,9 @@
raise SiteDefinitionError('Invalid AutoFamily({!r})'
.format(self.site.family.domain))
- pywikibot.warning(msg)
+ if not self.json_warning: # warn only once
+ pywikibot.warning(msg)
+ self.json_warning = True
# there might also be an overflow, so try a smaller limit
for param in self._params:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874026
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I03d410fcfe0e0b8e72f89667d259da79ccbeb1e6
Gerrit-Change-Number: 874026
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874431 )
Change subject: [doc] Update documentation
......................................................................
[doc] Update documentation
Change-Id: Ie29fbe475f05e6723ee623744014e891b48e239d
---
M pywikibot/__init__.py
M ROADMAP.rst
M pywikibot/page/_wikibase.py
M tests/wikibase_tests.py
4 files changed, 26 insertions(+), 10 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 4a0ef7b..59ae273 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -50,6 +50,7 @@
Bugfixes
^^^^^^^^
+* Normalize :class:`WbTimes<pywikibot.WbTime>` sent to Wikidata (:phab:`T325860`)
* Fix :class:`pywikibot.WbTime` precision (:phab:`T324798`)
* Unquote title for red-links in class:`proofreadpage.IndexPage`
* Find month with first letter uppercase or lowercase with :class:`textlib.TimeStripper` (:phab:`T324310`)
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 49bf812..8aea5a8 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -667,11 +667,13 @@
def toTimestr(self, force_iso: bool = False,
normalize: bool = False) -> str:
- """
- Convert the data to a UTC date/time string.
+ """Convert the data to a UTC date/time string.
- See fromTimestr() for differences between output with and without
- force_iso.
+ .. seealso:: :meth:`fromTimestr` for differences between output
+ with and without *force_iso* parameter.
+
+ .. versionchanged:: 8.0
+ *normalize* parameter was added.
:param force_iso: whether the output should be forced to ISO 8601
:param normalize: whether the output should be normalized (see
@@ -701,8 +703,10 @@
self.toTimestr(force_iso=True).lstrip('+'))
def toWikibase(self, normalize: bool = False) -> Dict[str, Any]:
- """
- Convert the data to a JSON object for the Wikibase API.
+ """Convert the data to a JSON object for the Wikibase API.
+
+ .. versionchanged:: 8.0
+ *normalize* parameter was added.
:param normalize: Whether to normalize the WbTime object before
converting it to a JSON object (see :func:`normalize` for details)
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index eedbbbd..07115bd 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -9,7 +9,7 @@
* WikibaseEntity: base interface for Wikibase entities.
"""
#
-# (C) Pywikibot team, 2013-2022
+# (C) Pywikibot team, 2013-2023
#
# Distributed under the terms of the MIT license.
#
@@ -1904,8 +1904,10 @@
for qualifier in self.qualifiers.get(qualifier_id, []))
def _formatValue(self) -> dict:
- """
- Format the target into the proper JSON value that Wikibase wants.
+ """Format the target into the proper JSON value that Wikibase wants.
+
+ .. versionchanges:: 8.0
+ normalize the result if type is ``time``.
:return: JSON value
"""
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index ac15c61..3bb61e5 100755
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
"""Tests for the Wikidata parts of the page module."""
#
-# (C) Pywikibot team, 2008-2022
+# (C) Pywikibot team, 2008-2023
#
# Distributed under the terms of the MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874431
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie29fbe475f05e6723ee623744014e891b48e239d
Gerrit-Change-Number: 874431
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged