Last modified: 2014-11-09 17:49:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74896, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72896 - generate_family_file.py creates dodgy syntax for semantic-mediawiki.org
generate_family_file.py creates dodgy syntax for semantic-mediawiki.org
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks: pwb-family
  Show dependency treegraph
 
Reported: 2014-11-03 04:49 UTC by John Mark Vandenberg
Modified: 2014-11-09 17:49 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description John Mark Vandenberg 2014-11-03 04:49:55 UTC
The family file generator believes there is a language 'sw', but the writes a family class with two 'en' langs, which is invalid dict syntax.

$ python ./generate_family_file.py https://www.semantic-mediawiki.org/wiki/ semantic-mw
Generating family file from https://www.semantic-mediawiki.org/wiki/

==================================
api url: https://semantic-mediawiki.org/w/api.php
MediaWiki version: 1.22.3
==================================

Determining other languages...sw

There are 2 languages available.
Do you want to generate interwiki links? This might take a long time. ([y]es/[N]o/[e]dit)y
Loading wikis... 
  * sw... downloaded
  * en... in cache
Writing pywikibot/families/semantic-mw_family.py... 


$ cat pywikibot/families/semantic-mw_family.py 
# -*- coding: utf-8 -*-
"""
This family file was auto-generated by $Id: 185033971c163ea46b2b1904773b8c407069a4d0 $
Configuration parameters:
  url = https://www.semantic-mediawiki.org/wiki/
  name = semantic-mw

Please do not commit this to the Git repository!
"""

from pywikibot import family

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)
        self.name = 'semantic-mw'
        self.langs = {
            'en': 'semanticweb.org',
            'en': 'semantic-mediawiki.org',
        }



    def scriptpath(self, code):
        return {
            'en': '',
            'en': '/w',
        }[code]

    def version(self, code):
        return {
            'en': u'1.20.2',
            'en': u'1.22.3',
        }[code]


It isnt quite invalid syntax, but it is dodgy.
The family file 'works' because semantic-mediawiki.org is second in that list, and all supported version of python return the second entry with the same key.

$ python2.6 pwb.py shell
Welcome to the Pywikibot interactive shell!
>>> import pywikibot
>>> s = pywikibot.Site('en', 'semantic-mw')
>>> s.family.langs
{'en': 'semantic-mediawiki.org'}
>>> {
...             'en': u'1.20.2',
...             'en': u'1.22.3',
...         }
{'en': u'1.22.3'}
Comment 1 John Mark Vandenberg 2014-11-09 17:49:21 UTC
While dodgy, it works correctly.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links