jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/444268 )
Change subject: Skip casting in UnusedFilesGenerator
......................................................................
Skip casting in UnusedFilesGenerator
Page yielded by site.unusedfiles() is already a FilePage.
Change-Id: I9369fdedef9a61b34b588a45e5145b95d01f78c3
---
M pywikibot/pagegenerators.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 893bc15..bceae51 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -2338,7 +2338,7 @@
if site is None:
site = pywikibot.Site()
for page in site.unusedfiles(total=total):
- yield pywikibot.FilePage(page.site, page.title())
+ yield page
@deprecated_args(number="total", repeat=None)
--
To view, visit https://gerrit.wikimedia.org/r/444268
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9369fdedef9a61b34b588a45e5145b95d01f78c3
Gerrit-Change-Number: 444268
Gerrit-PatchSet: 1
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/444025 )
Change subject: [bugfix] Terminate script instead of raising an error
......................................................................
[bugfix] Terminate script instead of raising an error
If an IOError occurs during read operation a bad nested IOError occurs.
with a loth of traceback lines.
Now the script terminate with just showing that exception.
Change-Id: Ib4808beaf936a7243bc5ef6fba1978f0f2c24920
---
M scripts/pagefromfile.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 31ad263..7fdac72 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -224,9 +224,9 @@
encoding=config.textfile_encoding) as f:
text = f.read()
- except IOError as err:
- pywikibot.output(str(err))
- raise IOError
+ except IOError:
+ pywikibot.exception()
+ return
position = 0
length = 0
--
To view, visit https://gerrit.wikimedia.org/r/444025
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4808beaf936a7243bc5ef6fba1978f0f2c24920
Gerrit-Change-Number: 444025
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/444011 )
Change subject: [IMPR] New options for pagefromfile.py
......................................................................
[IMPR] New options for pagefromfile.py
-textonly: Text is given without markers. Only one page text is given.
-begin and -end options are ignored.
-title:xxx The page title is given directly. Ignores -titlestart,
-titleend and -notitle options
Now you are able to create a page file like
$ echo "Hello world" > Test.wiki
and upload it with the command line:
pwb.py pagefromfile -summary:"The edit summary" -title:"Test" -file:"Test.wiki" -textonly
Bug: T198817
Change-Id: Ie778256d2a624cd77b3305155dd2d773cc918971
---
M scripts/pagefromfile.py
1 file changed, 28 insertions(+), 16 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 31ad263..fe92bd1 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -24,6 +24,8 @@
-end:xxx The text that marks the end of the page,
the default value is "{{-stop-}}"
-include Include the beginning and end markers to the page
+-textonly Text is given without markers. Only one page text is given.
+ -begin and -end options are ignored.
-titlestart:xxx The text used in place of ''' for identifying
the beginning of a page title
-titleend:xxx The text used in place of ''' for identifying
@@ -31,6 +33,8 @@
-notitle Do not include the page title, including titlestart
and titleend, to the page. Can be used to specify unique
page title above the page content
+-title:xxx The page title is given directly. Ignores -titlestart,
+ -titleend and -notitle options
-nocontent:xxx If the existing page contains specified statement,
the page is skipped from editing
-noredirect Do not upload on redirect pages
@@ -198,6 +202,8 @@
'titleend': "'''",
'include': False,
'notitle': False,
+ 'textonly': False,
+ 'title': None,
}
def __init__(self, filename, **kwargs):
@@ -243,33 +249,39 @@
pywikibot.output(u'\nNo title found - skipping a page.')
position += err.offset
continue
-
+ if length == 0:
+ break
position += length
yield title, contents
def findpage(self, text):
"""Find page to work on."""
- page_regex = re.compile(
- re.escape(self.pageStartMarker) + '(.*?)'
- + re.escape(self.pageEndMarker), re.DOTALL)
+ if self.getOption('textonly'):
+ pattern = '^(.*)$'
+ else:
+ pattern = (re.escape(self.pageStartMarker) + '(.*?)'
+ + re.escape(self.pageEndMarker))
+ page_regex = re.compile(pattern, re.DOTALL)
title_regex = re.compile(
re.escape(self.titleStartMarker) + '(.*?)'
+ re.escape(self.titleEndMarker))
-
location = page_regex.search(text)
if self.include:
contents = location.group()
else:
contents = location.group(1)
- try:
- title = title_regex.search(contents).group(1)
- if self.notitle:
- # Remove title (to allow creation of redirects)
- contents = title_regex.sub('', contents, count=1)
- except AttributeError:
- raise NoTitle(location.end())
- else:
- return location.end(), title, contents
+
+ title = self.getOption('title')
+ if not title:
+ try:
+ title = title_regex.search(contents).group(1)
+ if self.notitle:
+ # Remove title (to allow creation of redirects)
+ contents = title_regex.sub('', contents, count=1)
+ except AttributeError:
+ raise NoTitle(location.end())
+
+ return location.end(), title, contents
def main(*args):
@@ -294,11 +306,11 @@
warn('-start param (text that marks the beginning) of a page has '
'been deprecated in favor of begin; make sure to use the '
'updated param.', ArgumentDeprecationWarning)
- elif option in ('begin', 'end', 'titlestart', 'titleend'):
+ elif option in ('begin', 'end', 'titlestart', 'titleend', 'title'):
r_options[option] = value
elif option == 'file':
filename = value
- elif option in ('include', 'notitle'):
+ elif option in ('include', 'notitle', 'textonly'):
r_options[option] = True
# bot options
elif option == 'appendbottom':
--
To view, visit https://gerrit.wikimedia.org/r/444011
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie778256d2a624cd77b3305155dd2d773cc918971
Gerrit-Change-Number: 444011
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-Reviewer: saper <saper(a)saper.info>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/443918 )
Change subject: site.py: Improve type hints
......................................................................
site.py: Improve type hints
This change fixes some of the "WARNING: more than one target found for
cross-reference" warnings during documentation build process.
Bug: T187009
Change-Id: I593ac38d2258ea1aa3f1ad61a3988e74440d3900
---
M pywikibot/site.py
1 file changed, 22 insertions(+), 22 deletions(-)
Approvals:
Xqt: Looks good to me, approved
Dvorapa: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 57a33dc..0959fa5 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1125,7 +1125,7 @@
@param title: Title of the page to link to
@type title: unicode
@param othersite: Generate a interwiki link for use on this site.
- @type othersite: Site (optional)
+ @type othersite: BaseSite or None
@rtype: unicode
"""
@@ -1925,7 +1925,7 @@
items in total
@type total: int
@return: iterable with parameters set
- @rtype: QueryGenerator
+ @rtype: api.QueryGenerator
@raises KeyError: a namespace identifier was not resolved
@raises TypeError: a namespace identifier has an inappropriate
type such as NoneType or bool
@@ -2988,7 +2988,7 @@
Load [[mw:Extension:PageImages]] info.
@param page: The page for which to obtain the image
- @type page: Page class
+ @type page: pywikibot.Page
@raises APIError: PageImages extension is not installed
"""
@@ -3013,7 +3013,7 @@
"""Iterate global image usage for a given FilePage.
@param page: the page to return global image usage for.
- @type image: FilePage
+ @type image: pywikibot.FilePage
@param total: iterate no more than this number of pages in total.
@raises TypeError: input page is not a FilePage.
@raises SiteDefinitionError: Site could not be defined for a returned
@@ -3157,9 +3157,9 @@
Return page object for the redirect target of page.
@param page: page to search redirects for
- @type page: BasePage
+ @type page: pywikibot.page.BasePage
@return: redirect target of page
- @rtype: BasePage
+ @rtype: pywikibot.Page
@raises IsNotRedirectPage: page is not a redirect
@raises RuntimeError: no redirects found
@@ -4518,7 +4518,7 @@
@param image: the image to search for (FilePage need not exist on
the wiki)
- @type image: FilePage
+ @type image: pywikibot.FilePage
@param namespaces: If present, only iterate pages in these namespaces
@type namespaces: iterable of basestring or Namespace key,
or a single instance of those types. May be a '|' separated
@@ -5605,7 +5605,7 @@
"""Undelete page from the wiki. Requires appropriate privilege level.
@param page: Page to be deleted.
- @type page: Page
+ @type page: pywikibot.BasePage
@param revisions: List of timestamps to restore.
If None, restores all revisions.
@type revisions: list
@@ -6793,7 +6793,7 @@
shows all protection levels.
@type level: str or False
@return: The pages which are protected.
- @rtype: generator of Page
+ @rtype: Iterable[pywikibot.Page]
"""
namespaces = self.namespaces.resolve(namespace)
# always assert that, so we are be sure that type could be 'create'
@@ -6910,7 +6910,7 @@
@type lint_from: str representing digit or integer
@return: pages with Linter errors.
- @rtype: generator of Page
+ @rtype: Iterable[pywikibot.Page]
"""
query = self._generator(api.ListGenerator, type_arg='linterrors',
@@ -7712,7 +7712,7 @@
@param item: Entity to modify
@type item: WikibasePage
@param claim: Claim to be added
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
@@ -7744,7 +7744,7 @@
Set the claim target to the value of the provided claim target.
@param claim: The source of the claim target value
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param snaktype: An optional snaktype. Default: 'value'
@type snaktype: str ('value', 'novalue' or 'somevalue')
@param bot: Whether to mark the edit as a bot edit
@@ -7775,7 +7775,7 @@
Save the whole claim to the wikibase site.
@param claim: The claim to save
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
@@ -7806,9 +7806,9 @@
Create/Edit a source.
@param claim: A Claim object to add the source to
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param source: A Claim object to be used as a source
- @type source: Claim
+ @type source: pywikibot.Claim
@param new: Whether to create a new one if the "source" already exists
@type new: bool
@param bot: Whether to mark the edit as a bot edit
@@ -7861,9 +7861,9 @@
Create/Edit a qualifier.
@param claim: A Claim object to add the qualifier to
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param qualifier: A Claim object to be used as a qualifier
- @type qualifier: Claim
+ @type qualifier: pywikibot.Claim
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
@@ -7899,7 +7899,7 @@
Remove claims.
@param claims: Claims to be removed
- @type claims: list of Claim
+ @type claims: List[pywikibot.Claim]
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
@@ -7934,9 +7934,9 @@
Remove sources.
@param claim: A Claim object to remove the sources from
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param sources: A list of Claim objects that are sources
- @type sources: Claim
+ @type sources: pywikibot.Claim
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
@@ -7965,9 +7965,9 @@
Remove qualifiers.
@param claim: A Claim object to remove the qualifier from
- @type claim: Claim
+ @type claim: pywikibot.Claim
@param qualifiers: Claim objects currently used as a qualifiers
- @type qualifiers: list of Claim
+ @type qualifiers: List[pywikibot.Claim]
@param bot: Whether to mark the edit as a bot edit
@type bot: bool
@param summary: Edit summary
--
To view, visit https://gerrit.wikimedia.org/r/443918
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I593ac38d2258ea1aa3f1ad61a3988e74440d3900
Gerrit-Change-Number: 443918
Gerrit-PatchSet: 2
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot