Example #1
0
 def test_RegexFilterPageGenerator(self):
     """Test RegexFilterPageGenerator."""
     self.assertFunction("RegexFilterPageGenerator")
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen, '/doc')
     self.assertPagelistTitles(gen,
                               ('Template:!/Doc', 'Template:Template/Doc'))
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   '/doc',
                                                   quantifier='none')
     self.assertEqual(len(tuple(gen)), 11)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'])
     self.assertPagelistTitles(
         gen, ('Template:!/Doc', 'Template:!/Meta', 'Template:Template/Doc',
               'Template:Template/Meta'))
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'],
                                                   quantifier='none')
     self.assertEqual(len(tuple(gen)), 9)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'],
                                                   quantifier='all')
     self.assertPagelistTitles(gen, [])
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['Template', '/meta'],
                                                   quantifier='all')
     self.assertPagelistTitles(gen, ('Template:Template/Meta', ))
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='any')
     self.assertPagelistTitles(
         gen, ('Template:Template', 'Template:!/Meta',
               'Template:Template/Doc', 'Template:Template/Meta'))
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='any',
                                                   ignore_namespace=False)
     self.assertEqual(len(tuple(gen)), 6)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='all',
                                                   ignore_namespace=False)
     self.assertPagelistTitles(
         gen, ('Template:!/Meta', 'Template:Template/Meta'))
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='none',
                                                   ignore_namespace=False)
     self.assertEqual(len(tuple(gen)), 7)
Example #2
0
 def test_RegexFilterPageGenerator(self):
     self.assertFunction("RegexFilterPageGenerator")
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen, '/doc')
     self.assertTrue(len(tuple(gen)) == 2)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   '/doc',
                                                   quantifier='none')
     self.assertTrue(len(tuple(gen)) == 11)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'])
     self.assertTrue(len(tuple(gen)) == 4)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'],
                                                   quantifier='none')
     self.assertTrue(len(tuple(gen)) == 9)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'],
                                                   quantifier='all')
     self.assertTrue(len(tuple(gen)) == 0)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['Template', '/meta'],
                                                   quantifier='all')
     self.assertTrue(len(tuple(gen)) == 1)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='any')
     self.assertTrue(len(tuple(gen)) == 4)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='any',
                                                   ignore_namespace=False)
     self.assertTrue(len(tuple(gen)) == 6)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='all',
                                                   ignore_namespace=False)
     self.assertTrue(len(tuple(gen)) == 2)
     gen = pagegenerators.PagesFromTitlesGenerator(self.titles,
                                                   site=self.site)
     gen = pagegenerators.RegexFilterPageGenerator(gen,
                                                   ['template', '/meta'],
                                                   quantifier='none',
                                                   ignore_namespace=False)
     self.assertTrue(len(tuple(gen)) == 7)
 def generator(self):
     """Generator."""
     gen = self.site.allpages(start=self.opt.start,
                              namespace=10, filterredir=False)
     if self.site.doc_subpage:
         gen = pagegenerators.RegexFilterPageGenerator(
             gen, self.site.doc_subpage, quantifier='none')
     return gen