jenkins-bot submitted this change.

View Change

Approvals: Hazard-SJ: Looks good to me, approved jenkins-bot: Verified
[IMPR] create a Site from sitename

like

s = pywikibot.Site('wikipedia:test')

Change-Id: I0ee625bbc8ed7ccae45679e5b92b53b84d7f51dc
---
M pywikibot/__init__.py
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index e9f40c7..56252c1 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1098,6 +1098,7 @@
using the method parameters.

@param code: language code (override config.mylang)
+ code may also be a sitename like 'wikipedia:test'
@param fam: family name or object (override config.family)
@type fam: str or pywikibot.family.Family
@param user: bot user name to use on this site (override config.usernames)
@@ -1123,13 +1124,19 @@
'URL to the wiki OR a pair of code and family name '
'should be provided')
code, fam = _code_fam_from_url(url)
+ elif code and ':' in code:
+ if fam:
+ raise ValueError(
+ 'sitename OR a pair of code and family name '
+ 'should be provided')
+ fam, _, code = code.partition(':')
else:
# Fallback to config defaults
code = code or config.mylang
fam = fam or config.family

- if not isinstance(fam, Family):
- fam = Family.load(fam)
+ if not isinstance(fam, Family):
+ fam = Family.load(fam)

interface = interface or fam.interface(code)


To view, visit change 638422. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0ee625bbc8ed7ccae45679e5b92b53b84d7f51dc
Gerrit-Change-Number: 638422
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Hazard-SJ <hazardsjwiki@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged