Hi,

If you have a database name, you can use pywikibot.site.APISite.fromDBName('enwiki'). It currently only works for WMF sites, and the naming is a bit awkward...
Site object to code is as simple as pywikibot.Site('en', 'wikipedia').dbName(). It returns "enwiki".
By fetching the "imported from" statements from wikidata, it makes it easier for other uses to make updates and other scripts can use them in once place. Since it only gets fetched once during script initialization, I don't think that's too in-efficient, though it would be neat if we could cache it somehow.

Automatically creating a DataSite object if wikidata is requested sounds interesting. I don't think there is any time where having a regular Site object is an advantage to a DataSite object. I know that right now you can do pywikibot.Site('wikidata', 'wikidata', interface='DataSite').

-- Legoktm



On Fri, Jul 12, 2013 at 6:05 AM, Pyfisch <pyfisch@googlemail.com> wrote:
Hello,

if you use PWB with Wikidata you need often some functions not yet provided by the framework. Here are some functions which I miss:
  • for the Wikidata Family class
    • get a Site object for a given code like 'enwiki'
    • Site object to code
    • add the items used for the 'imported from' statement directly to the file, because retrieving them always from online ( www.wikidata.org/wiki/Wikidata:List_of_wikis/python ) is very unusual
  • Site creation function: Return a DataSite object if Wikidata is requested. Sometimes you need a DataSite object directly, you can use pywikibot.site.DataSite, but this is not really nice.
I would help coding the feautures but I have no access to SVN and I don't now if it is useful to request it now because PWB will move to Git soon.

Greetings
Pyfisch

_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l