משתמש:Tomerbot/פונקציות שימושיות

parse output from catscan:
while bbyte != -1:
	bbyte = text.find(':',bbyte)
	cbyte = text.find ('*',bbyte)
	text = text[:bbyte] + '\n' + text[cbyte:]
text = text.replace('*','#')


Categorize shichtuv articles:
aricha=u'{{\u05e2\u05e8\u05d9\u05db\u05d4}}'
aricha_new=u'{{\u05dc\u05e9\u05db\u05ea\u05d5\u05d1|\u05e0\u05d5\u05e9\u05d0=\u05e1\u05e4\u05d5\u05e8\u05d8}}'
aricha_new2= u'{{\u05dc\u05e2\u05e8\u05d5\u05da}}'
aricha_new3=u'{{\u05dc\u05e2\u05e8\u05d9\u05db\u05d4}}'
page = output from previous function
for item in page.linkedPages():
	print item.title()
	text = item.get(force=True)
	bbyte = text.find(aricha[:7])
	if bbyte == -1:
		bbyte = text.find(aricha_new2[:7])
		if bbyte == -1:
			bbyte = text.find(aricha_new3[:8])
	if bbyte == -1:
		problems = problems + item.title()
	else:
		cbyte = text.find(aricha_new[-2:],bbyte)
		if aricha_new[9:14] in text[bbyte:cbyte]:
			text = text[:cbyte] + aricha_new[8:13] + '2' + aricha_new[13:-2] + text[cbyte:]
		else:
			text = text[:cbyte] + aricha_new[8:-2] + text[cbyte:]
		item.put(text,u'\u05DE\u05E7\u05D8\u05DC\u05D2 \u05DC\u05E2\u05E8\u05D9\u05DB\u05D4',force=True)
טבלה עבור עודד
for item in page2.linkedPages():
	output= output + '|[[' + item.title() +']] || ' + u'[[%D7%A4%D7%95%D7%A8%D7%98%D7%9C:%D7%A2%D7%A8%D7%9B%D7%99%D7%9D_%D7%9E%D7%95%D7%9E%D7%9C%D7%A6%D7%99%D7%9D/%D7%A2%D7%A8%D7%9B%D7%99%D7%9D/'+item.title()+ ']] || || ||\n|-\n '
אכלוס מתוך רשימה (עדיין דורש שיפצורים)
for article in lis: #run over all articles
        interwiki = getArticleInterwiki(article) #get article interwiki
        if interwiki != -1 and findIfCategoryDontExist(openHebrewArticle (interwiki),category.title()): #if interwiki exist
		hebPage = openHebrewArticle (interwiki) #open hebrew article according to interwiki
                if hebPage.isRedirectPage():
                    hebpage = parseRedirect(hebpage)
                if hebPage.isDisambig():
			problematicArticles = problematicArticles + hebPage.title() + '\n'
                print article.title() + hebPage.title() #display actions for operator
                addCategory(hebPage,category.title()) #add category interwiki to its place
                userpage = userpage +'# '+ category.title() + '\\' + article.title()
דפים יתומים
for item in page.linkedPages():
	counter = 0
	for item2 in item.getReferences():
		if item2.namespace() == 0:
			counter = counter +1
	if counter == 0:
		output = output + "#[[" + item.title() + "]]\n"
	else:
		output_not = output_not + "#[[" + item.title() + "]]\n"
הסרת קטלוג כפול
for subcategory in category.subcategories():
	for item in subcategory.articles():
		lis.append(item)
for item in category.articles():
	if item in lis:
		text = item.get(force=True)
		bbyte = text.find(category.title()+']]')
		cbyte = text.find(']]',bbyte)
		text = text[:bbyte-2] + text[cbyte+2:]
		item.put (text,u'\u05d1\u05d5\u05d8 \u05DE\u05E1\u05D9\u05E8 '+category.title() + u' \u05E4\u05D5\u05E6\u05DC')

החלפת רישיון התמונות לדו-רישיוניות

duel=u'{{\u05d3\u05d5-\u05e8\u05d9\u05e9\u05d9\u05d5\u05e0\u05d9|GFDL|cc-by-sa-3.0}}'
for item in page.linkedPages(withImageLinks=True):
	bbyte = 0
	text2=item.get()
	text2 = text2.replace('{{GFDL}}',duel)
	item.put(text2,summey,force=True)