XZise added a comment.
I like @Xqt's idea of having different default codes for different sites and I agree with @jayvdb that the logic shouldn't be in the `BaseSite.__init__`.
TASK DETAIL
https://phabricator.wikimedia.org/T71255
REPLY HANDLER ACTIONS
Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: m4tx, XZise
Cc: pywikipedia-bugs, Ladsgroup, jayvdb, Mpaa, Ricordisamoa, XZise, Xqt, valhallasw, m4tx
jayvdb added a comment.
IMO the BaseSite.__init__ shouldnt be where lang/code is auto-guessed. This should be done in the pywikibot.Site factory function, with some help from the command line arg parsing routines if required.
An approach I have been mulling over is : the default site (URL) for any family is the one which has the same code as the family name. i.e. 'wikidata:wikidata' , 'commons:commons', etc. This is only *necessary* where the family has multiple codes, but it would be good to make that rule universal, which would mean changing the code of some sites, such as the wikitech families only site would be changed from 'en'->'wikitech', and the osm family needs the same change, and lyricwiki could be changed, however there are other languages of this family which are not in the family file, so I'd suggest not touching that one.
Then -family:wikidata (i.e. on the command line) would implicitly be -lang:wikidata also. To use test.wikidata via the command line, it needs to be explicitly mentioned: i.e. -family:wikidata -lang:test .
TASK DETAIL
https://phabricator.wikimedia.org/T71255
REPLY HANDLER ACTIONS
Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: m4tx, jayvdb
Cc: pywikipedia-bugs, Ladsgroup, jayvdb, Mpaa, Ricordisamoa, XZise, Xqt, valhallasw, m4tx
Xqt added a comment.
Why not use a dict for default sites in user-config like
default_sites = {
'wikipedia': 'de'
'wikisource': 'en'
'wikidata': 'test'
'myownproject': 'klingon'
}
family = 'wikipedia'
mylang = None # maybe obsolete now
-family option will use the default language code except -lang option is given or there is only one langage in that project.
this means
1. -family overrides config.family
2. if -lang is given, take it and raise an error if site does not exist, otherwise
3. if default_sites[family] is given, take that language code and raise an error if site does not exist, otherwise
4. take mylang (as fallback, maybe deprecated) and raise an error if site does not exist.
This means bot operators may have the choice of the default sites for each project and if not defined an error would be the right hint. But there would be no surprise which site is used anymore.
TASK DETAIL
https://phabricator.wikimedia.org/T71255
REPLY HANDLER ACTIONS
Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: m4tx, Xqt
Cc: pywikipedia-bugs, Ladsgroup, jayvdb, Mpaa, Ricordisamoa, XZise, Xqt, valhallasw, m4tx
XZise added a subscriber: m4tx.
XZise added a comment.
That makes more sense than the current implementation and would improve @m4tx's implementation. The problem with “what is default?” still remains.
About the first suggested behavior: It's currently not possible to determine where the language is defined from; if it's from the config or command line. And 'mylang=test; -family=wikidata' using 'wikidata:wikidata' //could// be confusing so maybe this should be highlighted: If a family provides a default and the language is a valid language (but not the default).
TASK DETAIL
https://phabricator.wikimedia.org/T71255
REPLY HANDLER ACTIONS
Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: m4tx, XZise
Cc: pywikipedia-bugs, Ladsgroup, jayvdb, Mpaa, Ricordisamoa, XZise, Xqt, valhallasw, m4tx