Page MenuHomePhabricator

sitename of site created with Autofamily looks strange
Open, MediumPublic

Description

Try to create a Site via AutoFamily for steward wiki as follows:

>>> import pywikibot
>>> site = pywikibot.Site(url='https://steward.wikimedia.org/')
>>> site
APISite('wikimedia', 'wikimedia')
>>> site.family
Family("wikimedia")
>>> type(site.family)
<class 'pywikibot.family.AutoFamily'>
>>> site.sitename                        
'wikimedia:wikimedia'
>>> site = pywikibot.Site(url='https://commons.wikimedia.org/')                        
>>> site                
APISite('wikimedia', 'wikimedia')

I would expect steward:steward as sitename and commons:commons for the second but the same name is provided here.

See also this check:

>>> import pywikibot
>>> site = pywikibot.Site(url='https://fr.wikipedia.org')
>>> site
APISite('fr', 'wikipedia')
>>> site.sitename
'wikipedia:fr'
>>> site.family
Family("wikipedia")
>>> type(site.family)
<class 'wikipedia_family.Family'>

The family file is found here.

Be careful with the url:

>>> site = pywikibot.Site(url='https://commons.wikimedia.org/')
>>> site
APISite('wikimedia', 'wikimedia')
>>> site = pywikibot.Site(url='https://commons.wikimedia.org')
>>> site
DataSite('commons', 'commons')

This should not happen.

Event Timeline

Xqt triaged this task as Medium priority.Jun 11 2025, 11:18 AM
Xqt updated the task description. (Show Details)
Xqt renamed this task from sitename of Autofamily looks strange to sitename of site created with Autofamily looks strange.Jun 11 2025, 11:21 AM

Change #1155737 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] IMPR: create s Site with a given url even if the url ends with a slash

https://gerrit.wikimedia.org/r/1155737

Change #1155737 merged by jenkins-bot:

[pywikibot/core@master] IMPR: create a Site with a given url even if the url ends with a slash

https://gerrit.wikimedia.org/r/1155737