Hi Shane,

Thanks for contributing! However, is there a reason why you prefer this over using the -family: and -lang: parameters you can use for every script?

Best regards,
Merlijn van Deen

On 2 April 2011 21:19, Shane Geiger <shane.geiger@gmail.com> wrote:
Is there any interest in a script that quickly switches pywikipedia
between wikis?  This is something I created quickly to do the job.  If
there is interest in this, what would need to be changed?  Is there any
interest in incorporating it into the distribution of pywikipedia?

(There is a os.chdir call and some os.system calls that would obviously
need to be changed.)




#!/usr/bin/env python
"""
This script enables pywikipedia to be switched between different wikis
quickly.

Simply create various config files with this format:
user-config.py_<configname>

Then run the script:  ./workon.py [optional argument]

"""
import glob
import os
import sys

os.chdir('/Users/sg/pywikipedia')

configs = [x[15:] for x in glob.glob("user-config.py_*")]

def lines_from(filename,splice="[:]"):
    """ allows you specify a splice so you can skip part of the file.
    """
    file = open(filename, "r")
    return file.read().splitlines()

def print_current_wiki():
    for line in lines_from('user-config.py'):
        try:
            exec(line)
        except:
            pass
    print "working on:",family

if __name__ == '__main__':
    args = sys.argv[1:]
    if args == []:
        print_current_wiki()
    elif args[0] in configs:
        if os.path.exists('user-config.py_' + args[0]):
            os.system('rm -f user-config.py')
            os.system('cp user-config.py_' + args[0] + ' user-config.py')
            print_current_wiki()
    else:
            print "Not a valid option.  Did you create the
'user-config.py_<name>' file?"
            print "Valid options: " + ", ".join(configs)






--
Shane Geiger
shane.geiger@gmail.com
Phone: 347-237-7108

"Principles for the development of a complete mind:
Study the science of art.
Study the art of science.
Develop your senses--especially learn how to see.
Realize how everything connects to everything else."
  -- Leonardo DaVinci


_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l