User:Ritchie333/afcbios.py

  1. !/usr/bin/python

import sys

import re

import pywikibot

from pywikibot import pagegenerators

name = 'Category:AfC submissions declined as a non-notable biography'

reText = re.compile( '(She is|She was|Her work|Her book)' )

reMarker = re.compile( '|{{.*}}||\'\'\'|----' )

reTitle = re.compile( '\(.*\)' )

site = pywikibot.Site()

cat = pywikibot.Category(site,name)

gen = pagegenerators.CategorizedPageGenerator(cat)

count = 0

for page in gen:

ns = page.namespace()

if( 118 == ns):

text = page.text

match = reText.search( text )

if( match is not None ):

if 0 == ( count % 50 ):

print '== ' + str( count + 1 ) + ' - ' + str( count + 50 ) + ' =='

title = page.title( False, False )

print '* Draft:' + title.encode( 'utf-8' ) + ''

shortText = reMarker.sub( '', text )

shortTitle = reTitle.sub( '', title )

sentences = re.search( shortTitle + '.*\.', shortText )

if not sentences is None:

components = sentences.group().partition( '.' )

lead = components[ 0 ].replace( '

print '::' + lead.encode( 'utf-8' ) + '.'

count += 1