ويكيبيديا:بوت/إزالة الصور غير الموجودة: الفرق بين النسختين

تم حذف المحتوى تمت إضافة المحتوى
لا ملخص تعديل
Hero9000 (نقاش | مساهمات)
لا ملخص تعديل
سطر 1:
????? ?????? ???????? ???? ??? ???? ???? ??? ??????? ??? ??? ?? ?? ??????? ???? ???? ????? ?????? ??? ???? ?? ??? ????? ?????? ?????? ???? ????? ??? ??? ????? ????? ??????? ????????[76] ????? ????? ????? ?? ??????[77][78] ????????? ??????? ?? ???????????[78] ????? ????? ??????? ????? ????? ??????? ??????? ??????? ????? ??????? ???????? ??? ???? ????? ???? ?????? ???????? ??? ???? ??????? ??? ???? ??? ???? ??? ??? ????? ???? ??????? ???????? ???? ?????? ????? ??????? ???????? ??? ?????? ???? ??????? ?? ???.[76] ???? ??????? ??? ???? ?????? ??????? ????? ??????? ??? ?????? ????????? ????????? ????? ??????? ??? ?????? ???? ?????? ???????. ??? ??? ?? ??? ?? ?????? ????????? ?? ???????????? ????????? ??? ??? ????? ??? ?????? ?? ??????? ??? ????? ?? ????? ?????? ?????? ??????? ???????? ?? ????? ????? ?????? ??? ?? ???? ??????? ????????? ?????.[79][80]
{{إدارة بوت}}
<noinclude>
[[تصنيف:سكربتات بوتات ويكيبيديا]]
</noinclude>
{{بيانات البوت
| الاسم = ازالة الصور غیر الموجودة
| الرخصة = [[رخصة إم إي تي|MIT]]
| تجريب = نعم
| قدرات = ازالة الصور الغیر موجودة من الصفحات
| الصانع = [[:fa:user:Mjbmr|Mjbmr]]
| المستخدم = [[user:Elph|عباس]]
| توضيح =
| المتغيرات =
| النتيجة = إزالة الصور غير الموجودة
| نموذج = [http://ar.wikipedia.org/w/index.php?title=%D8%A8%D9%8A%D8%A6%D8%A9_%D9%88%D9%82%D8%AA_%D8%A7%D9%84%D8%AA%D8%B4%D8%BA%D9%8A%D9%84_%D8%A7%D9%84%D8%AB%D9%86%D8%A7%D8%A6%D9%8A%D8%A9_%D9%84%D9%84%D8%AA%D8%B7%D8%A8%D9%8A%D9%82%D8%A7%D8%AA_%D8%A7%D9%84%D9%84%D8%A7%D8%B3%D9%84%D9%83%D9%8A%D8%A9&diff=prev&oldid=8496221 نموذج]
}}
{{-}}
 
?????? ??? ???? ?????? 18 ???? 1869 ?????? ??????? ?????????????? ???? ????? ???????? ??? ????? ??????? ??? ??????? ??????? ????? ????? ??? ??????? ??? ???? ????? ?? ??????? ???? ?? ???? ???? ???? ??? ??? ??? ??? ?????? ??????? ?? ???? ??? ???????? ????? ???????? ???? ???? ??????? ??????? ????? ???? ????? ?????? ??? ??? 1881 ???? ??? ????? ??????? ??????? ??? ????? ???????? ??????? ?????? ???????? ??????? ??????? ???????? ?????????? ??? ???.[81]
==الکود==
 
<source lang=python>
????? ?? ?? ??????? ?????????? ??? ??? ??????? ??????? ???? ??? ???????? ?? ??????? ???? ???? (1914-1917) ??? ??? ??????? ??? ??? ????? ??? ???????? ??? ???? ??????? ???? ???? ?????? ??????? ??? ????? ???????? ?? 1914 ?? ????? ????? ???????? ??????. ??? ?????? ???? ??????? ??????? ?????????? ??? ???? ?? ???? ????? ?? ???? ???? ????? ???? ??? ?????? ??? ??? ??? 1922 ????? ???? ??? ??? ??????? ???????.[82][83]
# -*- coding: utf-8 -*-
???????
"""
 
This script can be used to remove none exist images from pages
Crystal Clear app kdict.png ????? ?????: ??????? ???????
 
Syntax: python remove_none_exist_images.py [options]
????? ?????? ??? ???? ??? ??????? ??? ???? ???? ???? ?????? ?? ???? ??? ???? ?????.
 
Command line options:
??? ????? ??? ????? ???? ???? 1919 ??????????? ???? ??????? ????? ???????? ?? ??? ???? ????? ????? ??????? ??????? ??? ??? ??? ??? ? "????? 28 ?????? 1922" ????? ??? ??????? ?? ????? ????? ??????? ???????.[84]
??? ??? 1923 ?????? "???? ????????" ???? ???? ????? 1923? ?????? ??? ???? ????? ?? ????? ??? ???????? ??? ??? ??? ????????. ?? ??? ?????? 1936 ???? 20 ???? ??? ??? ?????????? ??????? ??? ?? ??? ???? ??? 8 ?????? 1951 ????? ???? ??????? ????? ??????? ??????? ??????? ??? 1899? ?? ???? ??? ?????? ???????? ???? 3 ???? ??? ???? ??????? ?????? ??? ????? ????? ??? 27 ????? 1952? ?? ????? ???? ?? ????? ?????? ?? 1952 ??? ????? ????? ????? ??????? ??? ?????? ?? ??? ???????? ????? ?????? ???? ???? ?????? ??? ???? ????[85] ?? ????? ????????? ??? 18 ????? 1953.[86][87]
-summary: Provide a custom edit summary. If the summary includes spaces,
?????????
surround it with single quotes, such as:
 
-summary:'My edit summary'
Crystal Clear app kdict.png ?????? ?????: ???? 23 ????? ???? ???? ???? ??? ?????? ???? ???????
 
-always Don't prompt to make changes, just do them.
Crystal Clear app kdict.png ???? ?????: ??? ?????????? ???? 6 ??????? ??????? ???? ?????
???? ???? ?????? ????? ???????? ??? ???????.
-namespace:n Number of namespace to process. The parameter can be
 
used multiple times.
?? 23 ????? 1952 ??? ?????? ???? ???? ????? ?????? ??????? ?????? ??????? ????? ??????? ?????? ????? ??????? ??? ??????? ?? ?????? ???? ?? ??????? �?????? ????????� ???? ????? ????? ????? "???? 23 ?????"?[88][89] ??? ??? 1953 ????? ????????? ??? ?????? ?????? ???? ???? ??? ???? ????????? ????? ????? ???????[90] ?? ???? ???? ??? ?????? ????? ??? ??????? ?? ?????? ?? ????? ??????? ?????? ?? ???????? ???? ??????? ?? ????? ??????? ???????? ??? ????? ????? ??????? ???????? ?? ??? 1958 ????? ??? ?????? ??? ???? ????????? ??????? ??????? ???? ????? ??? 1961? ??? ????? ???? ?????? 1960-1970? ??? ???? ?????? ????? ??????? ?? ????????? ?? ??? ??? ??????.[91][92]
 
Example:
???? ??????? ?? 5 ????? 1967 ??? ???? ??? ??? ?????? ??????? ?????? ????? ???????? ?????? ??????? ???? ??????� ????? ??? ???? ??? ????????? ??????? ??? ????? ??????? ??? ????? ?????? ??? ??? 1970 ???? ???? ??? ?????? ????? ?? ???? ????? ???? ???? ??????? ???? ??? ?????? ????? ????? ????? ?? ??????? ?????? ??????? ???????.[93][94]
python remove_none_exist_images.py -always -namespace:0
??? ????? ?????? ??? ????? ????? ??? ??????
 
"""
?? 6 ??????? 1973 ?? ???? ??????? ?????? ???? ?????? ??????? ??????? ??????? ??????? ??????? ??????? ?????? ??????? ??? ?????? ??????????? ?? ?? ?? ??? ????? ????? ???????? ??? ?? ??? ???? ??? ?????? ?? ??? ?????? ?? ?????. ???? ????? ??? ?????? ??????? ??????? ?????? ???????? ????? ?????? ??????? ??? ????? ??????? ???????? ??????? ??? ????? ??????? ?????? ?? ??????? ??? 22 ?????? ????? ??? ??? ??????? ??? ????? ?????? ????? ?????? ??????? ?? ???????? ?????? ????????.[95][96]
__version__ = '$Id:$'
 
import wikipedia as pywikibot
?? ??? 1977 ???? ?????? ??????? ???? ??????? ???? ?? ?????? ?????????? ????? ??????? ???? ????? ?????? ?????? ?? ????? ???????[97] ???? ??????? ?????? ???? ??? ????? ???? ?? ??????? ???? ???? ?????? ??????? ?????? ?? ????? ?? 25 ????? 1982 ??? ???? ???? ??????? ????? ????? ??????? ???? ??? ????? ??? ?? ??? ????????? ???? ??????? ??? ????? ?????? ?? ????? ??????? ???? ??? ?????????? ??? ????? ????? ??? ?? ????? ????? ??????? ?? ??? 1979 ??? ??? 1989.[98][99]
import pagegenerators, replace, re, query
#
# Distributed under the terms of the MIT license.
#
class remove_none_exist_images:
"""
This robot will remeve none exist files from pages
"""
# Edit Summary messages
msg_remove={
'en': u'روبوت:إزالة الصور غير الموجودة %s ([[ويكيبيديا:بوت/إزالة الصور غير الموجودة|الکود]])',
'fa': u'روبوت:إزالة الصور غير الموجودة %s ([[ويكيبيديا:بوت/إزالة الصور غير الموجودة|الکود]])',
}
def __init__(self,summary='',always=False,namespaces=[]):
"""
Arguments:
* summary - A custom edit summary.
* always - Don't prompt to make changes, just do them.
* namespaces - Array number of namespaces to process.
"""
self.always = always
self.namespaces = namespaces
mysite = pywikibot.getSite()
self.site = mysite
if summary:
self.editSummary = summary
else:
self.editSummary = pywikibot.translate(mysite, self.msg_remove)
def run(self):
"""
Starts the robot's action.
"""
fachr=u'۱۲۳۴۵۶۷۸۹۰'
params = {
'action': 'query',
'meta': 'allmessages',
'ammessages': 'broken-file-category',
'amenableparser': '',
}
self.categoryname = query.GetData(params, encodeTitle = True)
self.categoryname = self.categoryname['query']['allmessages'][0]['*']
pywikibot.output(u"Getting list of pages from category '%s' ..." % self.categoryname)
params = {
'action': 'query',
'list': 'categorymembers',
'cmlimit': 'max',
'cmtitle': u'Category:%s' % self.categoryname,
}
if (self.namespaces!=[]):
params['cmnamespace'] = '|'.join(str(self.namespaces))
self.pageslist = query.GetData(params, encodeTitle = True)
for pageitem in self.pageslist['query']['categorymembers']:
params = {
'action': 'query',
'prop': 'images',
'imlimit': 'max',
'titles': pageitem['title'],
}
imagelist = query.GetData(params, encodeTitle = True)
for image in imagelist['query']['pages'].values()[0]['images']:
params = {
'action': 'query',
'prop': 'imageinfo',
'titles': image['title'],
}
imagesinfo = query.GetData(params, encodeTitle = True)
for imageinfo in imagesinfo['query']['pages'].values():
site = self.site
imagename = re.match(r'(?:' + '|'.join(site.namespace(6, all = True))\
+ ')\:(.*)', image['title']).group(1)
try:
if (imageinfo['missing']=="" and imageinfo['imagerepository']==""):
pywikibot.output("Removing image '%s' ..." % imagename)
for i in fachr:
if imagename.find(i)!=-1:
pywikibot.output("Skiping image '%s' " % imagename)
continue
self.remove_image(site,imagename)
except:
pywikibot.output("Skiping image '%s'..." % imagename)
def remove_image(self,site,imagename):
ImagePage = pywikibot.ImagePage(site,site.namespace(6)+':%s' % imagename)
gen = pagegenerators.FileLinksGenerator(ImagePage)
preloadingGen = pagegenerators.PreloadingGenerator(gen)
if not site.nocapitalize:
case = re.escape(imagename[0].upper() + imagename[0].lower())
escaped = '[' + case + ']' + re.escape(imagename[1:])
else:
escaped = re.escape(imagename)
escaped = re.sub('\\\\[_ ]', '[_ ]', escaped)
for page in preloadingGen:
if(self.namespaces == [] or page.namespace() in self.namespaces):
try:
original_text = page.get()
new_text = re.sub(r'\[\[ *(?:' + '|'.join(site.namespace(6, all = True)) + ')\s*:\s*' \
+ escaped + ' *(?:\|[^\n]+|) *\]\]',"",original_text)
new_text = re.sub(r'' + escaped,"",new_text)
if new_text == original_text:
pywikibot.output(u'No changes were necessary in %s' % page.title(asLink=True))
else:
pywikibot.output(u">>> %s <<<" % page.title())
pywikibot.showDiff(original_text, new_text)
if not self.always:
choice = pywikibot.inputChoice(
u'Do you want to accept these changes?',
['Yes', 'No', 'All'],['y', 'N','a'], 'N')
if choice == 'y':
self.save_page(page, new_text, self.editSummary % imagename)
if choice == 'a':
self.always = True
else:
self.save_page(page, new_text, self.editSummary % imagename)
except pywikibot.NoPage:
pywikibot.output(u'Page %s has been deleted.' % page.title())
def save_page(self,page,text,summary):
try:
page.put(text, summary)
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
except pywikibot.SpamfilterError, e:
pywikibot.output(u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
except pywikibot.PageNotSaved, error:
pywikibot.output(u'Error putting page: %s'
% (error.args,))
except pywikibot.LockedPage:
pywikibot.output(u'Skipping %s (locked page)'
% (page.title(),))
def main():
summary = ''
always = False
namespaces = []
# read command line parameters
for arg in pywikibot.handleArgs():
if arg == '-always':
always = True
elif arg.startswith('-summary'):
if len(arg) == len('-summary'):
summary = pywikibot.input(u'Choose an edit summary: ')
else:
summary = arg[len('-summary:'):]
elif arg.startswith('-namespace:'):
try:
namespaces.append(int(arg[11:]))
except ValueError:
namespaces.append(arg[11:])
elif arg.startswith('-ns:'):
try:
namespaces.append(int(arg[4:]))
except ValueError:
namespaces.append(arg[4:])
bot = remove_none_exist_images(summary,always,namespaces)
bot.run()
if __name__ == "__main__":
try:
main()
finally:
pywikibot.stopme()
</source>