jenkins-bot has submitted this change and it was merged.
Change subject: Implementing 79569 [1] on core, making generate_user_files.py a little more user-friendly [1]: https://gerrit.wikimedia.org/r/79569
......................................................................
Implementing 79569 [1] on core, making generate_user_files.py a little more user-friendly
[1]: https://gerrit.wikimedia.org/r/79569
Change-Id: Idc4e5ae816bb10354475aa176414f866e0c8b298
---
M generate_user_files.py
1 file changed, 28 insertions(+), 6 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index ef680df..5beff0d 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -85,11 +85,20 @@
if choice == '' and default:
return default
-
+ try:
+ choice=int(choice)
+ except ValueError:
+ pass
+ if isinstance(choice, basestring):
+ if not choice in clist:
+ print("Invalid response")
+ else:
+ return choice
try:
return clist[int(choice) - 1]
except:
- print("Invalid response")
+ if not isinstance(choice, basestring):
+ print("Invalid response")
return response
@@ -127,7 +136,7 @@
set environment variables.""" % locals(), width=76)
for line in msg:
print line
- ok = raw_input("Is this OK? ([yes], [N]o) ")
+ ok = raw_input("Is this OK? ([y]es, [N]o) ")
if ok in ["Y", "y"]:
base_dir = new_base
return True
@@ -152,9 +161,22 @@
)
known_families = sorted(known_families)
fam = listchoice(known_families,
- "Select family of sites we are working on",
+ "Select family of sites we are working on, " \
+ "just enter the number not name",
default='wikipedia')
if fam not in single_wiki_families:
+ codesds=codecs.open("pywikibot/families/%s_family.py" % fam, "r","utf-8").read()
+ rre=re.compile("self\.languages\_by\_size *\= *(.+?)\]",re.DOTALL)
+ known_langs=[]
+ if not rre.findall(codesds):
+ rre=re.compile("self\.langs *\= *(.+?)\}",re.DOTALL)
+ if rre.findall(codesds):
+ import ast
+ known_langs=ast.literal_eval(rre.findall(codesds)[0]+u"}").keys()
+ else:
+ known_langs=eval(rre.findall(codesds)[0]+u"]")
+ print "This is the list of known language(s):"
+ print " ".join(sorted(known_langs))
mylang = raw_input("The language code of the site we're working on (default: 'en'): ") or 'en'
else:
mylang = fam
@@ -301,13 +323,13 @@
elif do_copy and "NO".startswith(do_copy):
break
if not os.path.isfile(os.path.join(base_dir, "user-config.py")):
- a = raw_input("Create user-config.py file? ([y]es, [N]o) ")
+ a = raw_input("Create user-config.py file? Required for running bots ([y]es, [N]o) ")
if a[:1] in ["Y", "y"]:
create_user_config()
else:
print("NOTE: user-config.py already exists in the directory")
if not os.path.isfile(os.path.join(base_dir, "user-fixes.py")):
- a = raw_input("Create user-fixes.py file? ([y]es, [N]o) ")
+ a = raw_input("Create user-fixes.py file? Optional and for advanced users ([y]es, [N]o) ")
if a[:1] in ["Y", "y"]:
create_user_fixes()
else:
--
To view, visit https://gerrit.wikimedia.org/r/81500
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idc4e5ae816bb10354475aa176414f866e0c8b298
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot
Ladsgroup has submitted this change and it was merged.
Change subject: Overhaul README file with more information
......................................................................
Overhaul README file with more information
Now includes how to install the framework, a simple
code snippet, and a link on how to contribute patches.
Change-Id: I112b53e0a2a3767e459323a34dc012ccc05201bd
---
M README.md
1 file changed, 30 insertions(+), 6 deletions(-)
Approvals:
Ladsgroup: Verified; Looks good to me, approved
diff --git a/README.md b/README.md
index 3592013..7acbc43 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,34 @@
-# Python Wikipedia Robot Framework
+# Pywikibot Framework
[![Build Status](https://secure.travis-ci.org/wikimedia/pywikibot-core.png?branch=ma…
-This is the rewrite of the Python Wikipedia Robot Framework. It features several
-improvements, such as full API usage and a pythonic package layout.
+The pywikibot framework is a Python library that interfaces with the [MediaWiki API](https://www.mediawiki.org/wiki/API).
+Also included are various general function scripts that can be adapted for different tasks.
-If you want to run the rewrite as a stand-alone package, please also download the
-the contents of the externals/ subdirectory. Confer externals/README for more
-information.
+## Quick start
+```
+git clone https://gerrit.wikimedia.org/r/pywikibot/core.git
+cd core
+git submodule update --init
+python pwb.py script_name
+```
+
+Our [installation guide](https://www.mediawiki.org/wiki/Manual:Pywikipediabot/Installation) has more details for advanced usage.
+
+## Usage
+
+If you wish to write your own script it's very easy to get started:
+
+```python
+import pywikibot
+site = pywikibot.Site('en', 'wikipedia') # The site we want to run our bot on
+page = pywikibot.Page(site, 'Wikipedia:Sandbox')
+text = page.get() # The current text on the page
+text = text.replace('foo', 'bar')
+page.put(text, 'Replacing "foo" with "bar"') # Saves the page
+```
+
+## Contributing
+
+Our code is maintained on Wikimedia's [Gerrit installation](https://gerrit.wikimedia.org/), [learn](https://www.mediawiki.org/wiki/Developer_access) how to get started.
+
--
To view, visit https://gerrit.wikimedia.org/r/82076
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I112b53e0a2a3767e459323a34dc012ccc05201bd
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
DrTrigon has submitted this change and it was merged.
Change subject: adopt submodule settings, to be all the same ('.' means "the same branch" as in the main repo)
......................................................................
adopt submodule settings, to be all the same
('.' means "the same branch" as in the main repo)
Change-Id: Ibbbb150c23cafda7a1b8b5fef816eb6ff0dc56d0
---
M .gitmodules
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
DrTrigon: Verified; Looks good to me, approved
diff --git a/.gitmodules b/.gitmodules
index 9777d90..069aa96 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -13,8 +13,8 @@
[submodule "externals/opencv"]
path = externals/opencv
url = https://gerrit.wikimedia.org/r/pywikibot/opencv.git
- branch = master
+ branch = .
[submodule "externals/pycolorname"]
path = externals/pycolorname
url = https://gerrit.wikimedia.org/r/pywikibot/pycolorname.git
- branch = master
+ branch = .
--
To view, visit https://gerrit.wikimedia.org/r/81959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibbbb150c23cafda7a1b8b5fef816eb6ff0dc56d0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove 'bot' from kwargs checking where it has been defined explicitly
......................................................................
Remove 'bot' from kwargs checking where it has been defined explicitly
Change-Id: I563953578f0ca425f1e0ef1e757a8b0b6b70c1c7
---
M pywikibot/site.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
FelixReimann: Looks good to me, but someone else must approve
Ladsgroup: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 00a0104..1b1f1d6 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3466,7 +3466,7 @@
params['baserevid'] = kwargs['baserevid']
params['token'] = self.token(pywikibot.Page(self, u'Main Page'), 'edit') # Use a dummy page
for arg in kwargs:
- if arg in ['bot', 'clear', 'data', 'exclude', 'summary']:
+ if arg in ['clear', 'data', 'exclude', 'summary']:
params[arg] = kwargs[arg]
params['data'] = json.dumps(data)
req = api.Request(site=self, **params)
@@ -3569,7 +3569,7 @@
}
params['snaks'] = json.dumps(snak)
for arg in kwargs:
- if arg in ['bot', 'baserevid', 'summary']:
+ if arg in ['baserevid', 'summary']:
params[arg] = kwargs[arg]
req = api.Request(site=self, **params)
@@ -3584,7 +3584,7 @@
params['claim'] = '|'.join(claim.snak for claim in claims)
params['token'] = self.token(pywikibot.Page(self, u'Main Page'), 'edit') # Use a dummy page
for kwarg in kwargs:
- if kwarg in ['bot', 'baserevid', 'summary']:
+ if kwarg in ['baserevid', 'summary']:
params[kwarg] = kwargs[kwarg]
req = api.Request(site=self, **params)
data = req.submit()
--
To view, visit https://gerrit.wikimedia.org/r/81582
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I563953578f0ca425f1e0ef1e757a8b0b6b70c1c7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: FelixReimann <felix(a)fex-it.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Throw an error if a non-DataSite is passed to WikibasePage
......................................................................
Throw an error if a non-DataSite is passed to WikibasePage
Also added in documentation to the various __init__ functions
specifying that site must be a DataSite.
Bug: https://sourceforge.net/p/pywikipediabot/bugs/1660/
Change-Id: I3882705da8e337fdd4328de462f8f5a9d681fd62
---
M pywikibot/page.py
1 file changed, 18 insertions(+), 3 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index c13ae4e..59108e3 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2283,6 +2283,8 @@
There really should be no need to call this directly
"""
def __init__(self, site, title=u"", **kwargs):
+ if not isinstance(site, pywikibot.site.DataSite):
+ raise TypeError("site must be a pywikibot.site.DataSite object")
Page.__init__(self, site, title, **kwargs)
self.repo = self.site
self._isredir = False # Wikibase pages cannot be a redirect
@@ -2495,9 +2497,9 @@
def __init__(self, site, title=None):
"""
defined by qid XOR site AND title
- options:
- site=pywikibot.DataSite & title=Q42
- site=pywikibot.Site & title=Main Page
+ @param site: data repository
+ @type site: pywikibot.site.DataSite
+ @param title: id number of item, "Q###"
"""
super(ItemPage, self).__init__(site, title, ns=0)
self.id = title.lower()
@@ -2660,6 +2662,11 @@
PropertyPage(DataSite, 'Property:P21')
"""
def __init__(self, source, title=u""):
+ """
+ @param source: data repository property is on
+ @type source: pywikibot.site.DataSite
+ @param title: page name of property, like "Property:P##"
+ """
WikibasePage.__init__(self, source, title, ns=120)
self.id = self.title(withNamespace=False).lower()
if not self.id.startswith(u'p'):
@@ -2699,6 +2706,14 @@
isQualifier=False):
"""
Defined by the "snak" value, supplemented by site + pid
+
+ @param site: repository the claim is on
+ @type site: pywikibot.site.DataSite
+ @param pid: property id, with "P" prefix
+ @param snak: snak identifier for claim
+ @param hash: hash identifer for references
+ @param isReference: whether specified claim is a reference
+ @param isQualifier: whether specified claim is a qualifier
"""
PropertyPage.__init__(self, site, 'Property:' + pid)
self.snak = snak
--
To view, visit https://gerrit.wikimedia.org/r/81677
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3882705da8e337fdd4328de462f8f5a9d681fd62
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mineo <themineo(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Make family file generator work with broken user_config
......................................................................
Make family file generator work with broken user_config
This reverts the removal of os.path.exists monkey patching that was
done in r10886 (git sha1 971d1150f66ddde5ea53def0c7e8f0e1edbd763c),
which means config.py will not find any user-config.py file. However,
we also restore the functionality after importing config, because
importing wikipedia requires a working os.path.exists.
Change-Id: I050d050dee536d0c44589651bff4dce866c50942
---
M generate_family_file.py
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_family_file.py b/generate_family_file.py
index 06464c9..05b264f 100644
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -32,10 +32,16 @@
import wikipediatools
wikipediatools.get_base_dir = lambda: '.'
-# Set some config settings
+# Set some config settings, but monkey-patch os.path.exists to prevent loading user_config.py
+import os
+oldexists = os.path.exists
+os.path.exists = lambda x: False
+
import config
config.mylang = 'en'
+os.path.exists = oldexists
+
# Now we can boot the framework
import wikipedia
import family
--
To view, visit https://gerrit.wikimedia.org/r/80238
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I050d050dee536d0c44589651bff4dce866c50942
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot