User:R. Hillgentleman/rcwatch.py

出自維基百科,自由嘅百科全書
Jump to navigation Jump to search
# rcwatch.py
# GET RC PAGELIST from rcpagelist.py , CONSISTING A NUMBER OF PAGES (4 AT PRESENT)
# AND READ THE OPENING LINES (100 CHARACTERS)
# (?)AND SHOW THE LAST DIFF(?)
# AND WE CAN CONFIGURE IT TO TAKE STANDARD ACTIONS FOR US, VIA if a=='bluh':...
# (PERHAPS WE SHOULD ADD THROTTLE; IT IS NOT STRICTLY NEEDED, THOUGH)

import rcpagelist
import wikipedia
site=wikipedia.getSite()

repeat = True
while repeat:
  print('\n #####################################################\n')
  list = rcpagelist.RCpagelist('4')
  page={}       
  for i in list:
    page['i'] = wikipedia.Page(site,i)
    t = page['i'].title()
    y = page['i'].get()
    u = page['i'].userName()
    print('\n ======================================================\n')
    print('[['+t+']],')
    print('User:',u) #NOTE: AT THE MOMENT,  userName() RETURNS NONE UNLESS THE LIST COMES FROM getall()  - A QUIRK IN wikipedia.py
    print(y[0:100])  #TO DO: SHOW THE DIFF INSTEAD
    a = raw_input('action?')
    ########### ADD SOME ACTIONS HERE:  TAG, EDIT, REVERT, DELETE, ETC
    # if a == 'bluh' : bluh....
  x = raw_input('End of list - repeat.....(n)ot?')
  if x=='n':repeat=False
wikipedia.stopme()