Page MenuHomePhabricator

FamilyMaintenanceWarning: Family name wikimediachapter does not match family module name wikimedia
Closed, InvalidPublic

Description

when i running my Scripts i get this WARNING: core/pywikibot/family.py:930: FamilyMaintenanceWarning: Family name wikimediachapter does not match family module name wikimedia?

and the text saved with out Unicode. like this "تعرض هذه الصفحة قاØ"

is there Solution ?

Event Timeline

@Jar, please provide source of Your script and information from user-config.py, and information how You have installed it.

@Magul

my user-config.py

# -*- coding: utf-8  -*-
mylang = 'ar'
family = 'wikipedia'
usernames['wikipedia']['ar'] = u'user'
usernames['wikipedia']['vi'] = u'user'
usernames['wikipedia']['ur'] = u'user'
usernames['wikipedia']['vec'] = u'user'
usernames['wiktionary']['ar'] = u'user'
usernames['wikidata']['wikidata'] = u'user'

and my script something like this


#!/usr/bin/python
# -*- coding: utf-8  -*-

import MySQLdb as mysqldb
from pywikibot import pagegenerators
from pywikibot import config
import urllib,gzip,codecs,re
import pywikibot
import family
import sys
reload(sys)
sys.setdefaultencoding("utf-8")

pagetop=u'{{إحصاء}}\n'

pagedown=u'\n|}'

pagedown+=u'\n</center>'

pagedown+=u'\n</div>'

pagedown+=u'\n[[تصنيف:إحصاءات ويكيبيديا]] [[تصنيف:ويكيبيديا قائمة الويكيبيديين حسب عدد التعديلات]]'

pagedown+=u'\n</div>'

adress=u"%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85%3A%D8%AC%D8%A7%D8%B1%20%D8%A7%D9%84%D9%84%D9%87%2F%D8%AA%D8%AC%D8%A7%D8%B1%D8%A8%20%D8%A8%D9%88%D8%AA"

message=u"test"

count=0

rowi,rowfia,rowfi,mytime,text,rowfa,line_items=' ',' ',' ',' ',' ',' ',' '


#---------------------------------------------- sql part--------------

site  = pywikibot.getSite("ar")

query = '''SELECT user_name, user_editcount FROM user 

WHERE user_name NOT IN

(SELECT user_name FROM user_groups 



 INNER JOIN user ON user_id = ug_user WHERE ug_group = 'bot') 

 AND user_name NOT IN 

(Select pl_title from pagelinks where pl_from = 2803691) 

ORDER BY user_editcount DESC LIMIT 500;'''

pywikibot.output(u'Executing query:\n%s' % query)

conn = mysqldb.connect("arwiki.labsdb", db = pywikibot.Site().dbName() + "_p", user = config.db_username, passwd = config.db_password)

cursor = conn.cursor()

query = query.encode(site.encoding())

cursor.execute(query)

results = cursor.fetchall()

#---------------------------------------------- end of sql part---------

count=0

for row in results:

        count+=1

        rowi=unicode(str(row[0]),'UTF-8')

        rowi2=unicode(str(row[1]),'UTF-8')

        rowfa+=u'\n|bgcolor="#808080"|'+str(count)+u'||bgcolor="#D3D3D3"|[[user:'+rowi+u'|'+rowi+u']]||'

        rowfa+='\n|-\n'

        text=rowfa.strip()

text=pagetop+text+pagedown

page = pywikibot.Page(site,adress)

page.put(text,message)

and the save page was like this https://ar.wikipedia.org/w/index.php?title=%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:%D8%AC%D8%A7%D8%B1_%D8%A7%D9%84%D9%84%D9%87/%D8%AA%D8%AC%D8%A7%D8%B1%D8%A8_%D8%A8%D9%88%D8%AA&oldid=21743140

@Jar I was trying to recreate Your issue with this warning and wasn't able to do so. I assume that it caused by import family at the top of Your script. I don't have such module in fresh Pywikibot code, so I was getting ImportError: No module named family. After removal of this line it start working without any warning. Can You confirm that I'm right here? What do this family.py contains?

I'm trying to figure out unicode issue, but I'm not an expert here, so it could take me a moment.

@Jar I still don't know how You installed it?

@Jar I just used some of Your edits and created simple script:

# -*- coding: utf-8  -*-

import pywikibot as pwb

site  = pwb.getSite("ar")
address = u'مستخدم:MagulBot'
message = u'مستخدم'

text=u"""
{{إحصاء}}
<div style="background: #E5E4E2; padding: 0.5em; font-family: Traditional Arabic; font-size: 130%;  -moz-border-radius: 0.3em; border-radius: 0.3em;">
<center>

تعرض هذه الصفحة قائمة الـ500 [[وب:ويكيبيديون|ويكيبيدي]]  الأوائل حسب عدد التعديلات (بدون احتساب [[وب:بوت|البوتات]]).

انظر أيضا: [[ويكيبيديا:قائمة الويكيبيديين حسب عدد التعديلات (متضمنة البوتات)|قائمة الويكيبيديين حسب عدد التعديلات (متضمنة البوتات)]]

'''قام [[مستخدم:JarBot|JarBot]] بتحديث هذه القائمة في :''''' 00:29، 27 نوفمبر 2016 (ت ع م) '''
</div>
<center>
<div style="background: #E5E4E2; padding: 0.5em;   -moz-border-radius: 0.3em; border-radius: 0.3em;">
{| class="wikitable sortable"
!style="background-color:#808080" align="center"|الرقم!!style="background-color:#808080" align="center"|المستخدم!!style="background-color:#808080" align="center"|عدد المساهمات
|-
|bgcolor="#808080"|1||bgcolor="#D3D3D3"|[[مستخدم:Meno25|Meno25]]||bgcolor="#DCDCDC"|[[خاص:مساهمات/Meno25|132,168]]
|-
|}
</center>
</div>
[[تصنيف:إحصاءات ويكيبيديا]] [[تصنيف:ويكيبيديا قائمة الويكيبيديين حسب عدد التعديلات]]
</div>
"""

page = pwb.Page(site,address)

page.put(text,message)

And as You would see it saved page with unicode properly: https://ar.wikipedia.org/w/index.php?title=%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:MagulBot&oldid=21751610

Ok, I have digg into this issue and it looks, that You're mixing unicode with str here. I would assume that it happened here: rowi=unicode(str(row[0]),'UTF-8') but it's something that You need to check. I could only suggest that You're loosing decode('cp1256') somehere.

I'm closing it as invalid, cause it's not an issue in Pywikibot .