Revision: 4296 Author: cosoleto Date: 2007-09-15 13:30:18 +0000 (Sat, 15 Sep 2007)
Log Message: ----------- Restored -cat in conjuntion with -start lost feature by adding '|' to category name (for example: -cat:"Ancient Greek poets|H"). I follow the previous code, but I think that '-subcat' parameter should be a flag or renamed.
Modified Paths: -------------- trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2007-09-15 12:38:27 UTC (rev 4295) +++ trunk/pywikipedia/pagegenerators.py 2007-09-15 13:30:18 UTC (rev 4296) @@ -580,6 +580,22 @@ def __init__(self): pass
+ def setCategoryGen(self, arg, length, recurse = False): + if len(arg) == length: + categoryname = wikipedia.input(u'Please enter the category name:') + else: + categoryname = arg[length + 1:] + + ind = categoryname.find('|') + if ind > 0: + startfrom = categoryname[ind + 1:] + categoryname = categoryname[:ind] + else: + startfrom = None + + cat = catlib.Category(wikipedia.getSite(), 'Category:%s' % categoryname) + return CategorizedPageGenerator(cat, start = startfrom, recurse = False) + def handleArg(self, arg): gen = None if arg.startswith('-filelinks'): @@ -618,19 +634,9 @@ textfilename = arg[6:] gen = TextfilePageGenerator(textfilename) elif arg.startswith('-cat'): - if len(arg) == 4: - categoryname = wikipedia.input(u'Please enter the category name:') - else: - categoryname = arg[5:] - cat = catlib.Category(wikipedia.getSite(), 'Category:%s' % categoryname) - gen = CategorizedPageGenerator(cat) + gen = self.setCategoryGen(arg, 4) elif arg.startswith('-subcat'): - if len(arg) == 7: - categoryname = wikipedia.input(u'Please enter the category name:') - else: - categoryname = arg[8:] - cat = catlib.Category(wikipedia.getSite(), 'Category:%s' % categoryname) - gen = CategorizedPageGenerator(cat, recurse = True) + gen = self.setCategoryGen(arg, 7, recurse = True) elif arg.startswith('-ref'): if len(arg) == 4: referredPageTitle = wikipedia.input(u'Links to which page should be processed?')