コード例 #1
0
ファイル: check_extern.py プロジェクト: pyropeter/PyroBot-1G
    import logger

    sys.stdout = logger.Logger(sys.stdout, filename="check_extern.log")

cont = True
checked = 0
working = 0
nonworking = 0
totalchecked = 0

try:
    while cont:
        print
        i = 0
        if len(todo) < 61 and do_all:
            for pl in wikipedia.allpages(start=start):
                todo.append(pl)
                i += 1
                if i == 480:
                    break
            start = todo[len(todo) - 1].title() + "_0"
        # todo is a list of pages to do, donow are the pages we will be doing in this run.
        if len(todo) > 60:
            # Take the first 60.
            donow = todo[0:60]
            todo = todo[60:]
        else:
            donow = todo
            # If there was more to do, the 'if len(todo)<61' part would have extended
            # todo beyond this size.
            cont = False
コード例 #2
0
ファイル: interwiki.py プロジェクト: karstenw/Library
    if globalvar.log:
        import logger
        sys.stdout = logger.Logger(sys.stdout, filename = 'treelang.log')

    unequal.read_exceptions()
    
    if skipfile:
        for pl in wikipedia.PageLinksFromFile(skipfile):
            globalvar.skip[pl] = None

    if start:
        if number:
            print "Treating %d pages starting at %s" % (number, start)
            i = 0
            for pl in wikipedia.allpages(start = start):
                sa.add(pl)
                i += 1
                if i >= number:
                    break
        else:
            print "Treating pages starting at %s" % start
            sa.setGenerator(wikipedia.allpages(start = start))

    inname = '_'.join(inname)
    if sa.isDone() and not inname:
        inname = raw_input('Which page to check:')

    if inname:
        inpl = wikipedia.PageLink(wikipedia.mylang, inname)
        sa.add(inpl, hints = hints)
コード例 #3
0
if log:
    import logger
    sys.stdout = logger.Logger(sys.stdout, filename='check_extern.log')

cont = True
checked = 0
working = 0
nonworking = 0
totalchecked = 0

try:
    while cont:
        print
        i = 0
        if len(todo) < 61 and do_all:
            for pl in wikipedia.allpages(start=start):
                todo.append(pl)
                i += 1
                if i == 480:
                    break
            start = todo[len(todo) - 1].title() + '_0'
        # todo is a list of pages to do, donow are the pages we will be doing in this run.
        if len(todo) > 60:
            # Take the first 60.
            donow = todo[0:60]
            todo = todo[60:]
        else:
            donow = todo
            # If there was more to do, the 'if len(todo)<61' part would have extended
            # todo beyond this size.
            cont = False
コード例 #4
0
ファイル: backref.py プロジェクト: karstenw/Library
    elif arg=='-file':
        mode=2
    elif arg=='-start':
        mode=3
    else:
        word.append(arg)

files={}

word=' '.join(word)
if mode==1:
    pages=[word]
elif mode==2:
    pages=open(word).readlines()
elif mode==3:
    pages=wikipedia.allpages(start=word)
else:
    raise "Please specify one of -one -file or -start"

for pl in pages:
    print pl
    sys.stdout.flush()
    try:
        ll=pl.interwiki()
    except wikipedia.IsRedirectPage:
        continue
    except wikipedia.LockedPage: # Can't do anything with a locked page
        continue
    except wikipedia.NoPage:
	print "ERROR: Yikes, does not exist"
        continue