ویکی‌پدیا:درخواست‌های ربات/زیباسازی ویکی‌پدیا فارسی: تفاوت میان نسخه‌ها

محتوای حذف‌شده محتوای افزوده‌شده
خط ۵۲:
wikipedia.config.put_throttle = 0
wikipedia.put_throttle.setDelay()
cleaning_version=u'۸.۰۱۵'
msg=u'('+cleaning_version +u')'
faSite = wikipedia.getSite('fa')
خط ۲۷۵:
text = re.sub(re.compile(ur'^(\=+)\s*(.*?)\s*(\=+)$', re.MULTILINE), ur"\1 \2 \3",text)
text=text.replace(u'\n\n*',u'\n*').replace(u'\n\n#',u'\n#')
#تمیزکاری فاصلهٔ مجازی
text = re.sub(u'‌{2,}', u'‌', text) # پشت‌سرهم
text = re.sub(u'‌(?![ئاآأإژزرذدوؤةبپتثجچحخسشصضطظعغفقکگلمنهیيًٌٍَُِّْٰٓٔ]|[\u0900-\u097F]|ֹ)', '', text) # در پس
text = re.sub(u'(?<![ئبپتثجچحخسشصضطظعغفقکگلمنهیيًٌٍَُِّْٰٓٔ]|[\u0900-\u097F]|f|ֹ)‌', '', text) # در پیش
#a: الگوافزایی
if text.find(u'{{پانویس')==-1:
سطر ۴۴۳ ⟵ ۴۳۹:
text=text.replace(u'\r',u'').replace(u'\n^ "',u'\n*"').replace(u'&zwnj;',u'‌').replace(u'\n \n \n',u'\n\n').replace(u'\n \n',u'\n\n').replace(u'\n \n',u'\n\n').replace(u'\n \n',u'\n\n')
text=text.replace(u'< ',u'<').replace(u' >',u'>').replace(u'<!--\n',u'<!--').replace(u'\n-->',u'-->').replace(u'<!---\n',u'<!---').replace(u'\n--->',u'--->')
#تمیزکاری فاصلهٔ مجازی
text = re.sub(u'(\u202A|\u202B|\u202C|\u202D|\u202E|\u200F)',u'\u200C', text)#حذف کارکترهای تغییرجهت
text = re.sub(u'‌{2,}', u'‌', text) # پشت‌سرهم
text = re.sub(u'‌(?![ئاآأإژزرذدوؤةبپتثجچحخسشصضطظعغفقکگلمنهیيًٌٍَُِّْٰٓٔ]|[\u0900-\u097F]|ֹ)', '', text) # در پس
سطر ۷۸۸ ⟵ ۷۸۵:
return text,msg
 
def reverting (text,old_text):
#واگردانی بابت رفع باگ کد زیباسازی پای‌ویکی‌پدیا
text=text.replace(u'< /',u'</')
# math
Regexs=re.compile(ur'\<math\>.*?\<\/math\>')
maths = Regexs.findall(text)
old_maths = Regexs.findall(old_text)
count=0
for m in maths:
text=text.replace(mmaths[count],m.replace(u'،',u',')old_maths[count])
count+=1
# source
Regexs=re.compile(ur'(?is)<source .*?</source>')
sources = Regexs.findall(text)
old_sources = Regexs.findall(old_text)
count=0
for source in sources:
text=text.replace(sources[count],old_sources[count])
count+=1
return text
 
سطر ۸۳۱ ⟵ ۸۴۰:
old_text=text
text,cleaning_version,msg=fa_cosmetic_changes(text,fapage,msg_short=True,msg=msg)
text=reverting(text,old_text)
if old_text!=text and text!=minor_edits(old_text):
wikipedia.output(u'-------------------------------------------')