ویکیپدیا:درخواستهای ربات/تصویر همسنگ: تفاوت میان نسخهها
محتوای حذفشده محتوای افزودهشده
جز ویرایش Reza1615 (بحث) به آخرین تغییری که Mahdi.hajiha انجام داده بود واگردانده شد |
جز ویرایش درفش کاویانی (بحث) به آخرین تغییری که Reza1615 انجام داده بود واگردانده شد |
||
خط ۷۹:
except:
return u'error'
def enwikiimagecheck(text_en2):
try:
im = re.search(ur'\|\s*(?:[Ff]ile|[Pp]hoto|[Ii]mage).*?\=\s*([^\|]*?)\s*\|', text_en2)▼
imagename=im.group(0).split(u'=')[1].replace(u'|',u'').strip()
except:
im = re.search(ur'\[\[([Ff]ile|[Ii]mage):.*?\|', text_en2)
imagename=im.group(0).split(u':')[1].replace(u'|',u'').strip()
return imagename
def BotRun(page,text_fa,text_en):
try:
pagename=
except:
pagename=unicode(str(page),'UTF-8').replace(u'Fa:',u'').replace(u'fa:',u'').replace(u'[[',u'').replace(u']]',u'').strip()
page=wikipedia.Page(faSite,pagename)
#--------------------------------------------------------------action that you want to do on pages-----------------
text_fa2=text_fa.replace(u'\n',u'').replace(u'\r',u'')
text_en2=text_en.replace(u'\n',u'').replace(u'\r',u'')
imagename=u''
try:
imagename=enwikiimagecheck(text_en2)
▲ im = re.search(ur'\|\s*(?:[Ff]ile|[Ii]mage).*?\=\s*([^\|]*?)\s*\|', text_en2)
if
▲ imagename=im.group(1)
if checksite(imagename)==u'commons':
try:
imfa = re.
if imfa:
try:
imagenamefa=imfa.group(0).split(u'=')[1].replace(u'|',u'').strip()
if imagenamefa!=u'':▼
if imagenamefa.find(u'Replace this image
text_fa2=text_fa2.replace(u'Replace
text_fa=text_fa.replace(u'Replace this image male.svg',u'',1).replace(u'Replace this image female.svg',u'',1)
▲ else:
imfa
if
wikipedia.output(u'infobox
imageparameter=imfa.group(0).split(u'=')[0]
text_fa=text_fa.replace(imageparameter+u'=',imageparameter+u'='+imagename.strip(),1)
wikipedia.output( u"--image added to infobox!--" )
try:
imfasize = re.search(ur'\|\s*(?:سایز تصویر|اندازه تصویر|عرض تصویر|سایز نگاره|اندازه نگاره|عرض نگاره|سایز عکس|انداز عکس|عرض عکس|سایز_تصویر|اندازه_تصویر|عرض_تصویر|سایز_نگاره|اندازه_نگاره|عرض_نگاره|سایز_عکس|انداز_عکس|عرض_عکس).*?\=.*?\|', text_fa2)
imagenamesize=imfasize.group(0).split(u'=')[1].replace(u'|',u'').strip()
imagesizeparameter=imfasize.group(0).split(u'=')[0]
text_fa=text_fa.replace(imagesizeparameter+u'='+imagenamesize,imagesizeparameter+u'={{جا:formatnum:200|R}}px',1)
except:
pass
return text_fa
except:
wikipedia.output( u"--infobox doesn't be in fa.wiki--" )
سطر ۱۲۰ ⟵ ۱۴۵:
for inter in interwiki:
inters=str(inter)
if inters.find(secondwiki+
enSite = wikipedia.getSite(secondwiki)
page=wikipedia.Page(enSite,inter.title())
سطر ۱۴۲ ⟵ ۱۶۷:
def run(generator):
for pages in generator:
try:
pagename=unicode(str(pages),'UTF-8').replace(u'Fa:',u'').replace(u'fa:',u'').replace(u'[[',u'').replace(u']]',u'').strip() except:
pagename=str(pages).replace(u'Fa:',u'').replace(u'fa:',u'').replace(u'[[',u'').replace(u']]',u'').strip()
if pagename.find(u':')!=-1:
continue
pagefa=wikipedia.Page(faSite,pagename)
try:
if not pagefa.canBeEdited():
wikipedia.output( u'Skipping locked page %s' % pagefa.title() )
continue
سطر ۱۶۳ ⟵ ۱۹۱:
except:
continue
if interwikis==[]:
wikipedia.output( u'---------------------------')
wikipedia.output( pagename)
wikipedia.output( u"dosen't have english page!")
continue
text_en=enpageget(interwikis)
test=text_en.replace(u'\n',u'')
except:
wikipedia.output( u'---------------------------')
wikipedia.output( pagename)
wikipedia.output( u"dosen't have english page!")
continue
if text_en==u' ' or text_en==u'':
wikipedia.output( u'---------------------------')
wikipedia.output( pagename)
wikipedia.output( u"dosen't have english page!")
continue
wikipedia.output( u'---------------------------')
wikipedia.output( pagename)
new_text=BotRun(pagename,text_fa,text_en)
if new_text:
savepart(pagename,new_text )#---------------saving changes in page with new_text content-----------------------------------
else:
wikipedia.output( u'Skipping %s ' % pagename )
def savepart( page,new_text):
pagename=
page=wikipedia.Page(faSite,pagename)
try:
سطر ۱۹۰ ⟵ ۲۳۷:
gencat = pagegenerators.SubCategoriesPageGenerator(catname, recurse=False)
for subcat in gencat:
try:
wikipedia.output(subcat) except:
wikipedia.output(str(subcat))
if subcat in listacategory:
continue
سطر ۲۷۵ ⟵ ۳۲۵:
facatfalist=facatlist(cat)
if facatfalist!=False:
run(facatfalist)
if PageTitles:
pages = [wikipedia.Page(faSite,PageTitle) for PageTitle in PageTitles]
|