Ejemplo n.º 1
0
    def test_sort_numeric(self):
        """Test sorted results."""
        keys = ('good', 'prefix', 'total')

        ws = WikiStats()
        data = ws.sorted('wikipedia', 'total')
        top = data[0]
        bottom = data[-1]

        for key in keys:
            with self.subTest(key=key):
                self.assertIn(key, top)
                self.assertIn(key, bottom)

        self.assertTrue(all(isinstance(key, str)
                            for key in top.keys()
                            if key is not None))
        self.assertIsInstance(top['good'], str)
        self.assertIsInstance(top['total'], str)
        self.assertIsInstance(bottom['good'], str)
        self.assertIsInstance(bottom['total'], str)

        self.assertGreater(int(top['total']), int(bottom['good']))
        self.assertGreater(int(top['good']), int(bottom['good']))
        self.assertGreater(int(top['total']), int(bottom['total']))
Ejemplo n.º 2
0
 def test_sort(self):
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertEqual(top['prefix'], 'en')
     self.assertIsInstance(top['total'], basestring)
     self.assertEqual(ws.languages_by_size('wikipedia')[0], 'en')
     self.assertEqual(ws.languages_by_size('wikisource')[0], 'fr')
Ejemplo n.º 3
0
 def test_sort(self):
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertEqual(top['prefix'], 'en')
     self.assertIsInstance(top['total'], basestring)
     self.assertEqual(ws.languages_by_size('wikipedia')[0], 'en')
     self.assertEqual(ws.languages_by_size('wikisource')[0], 'fr')
Ejemplo n.º 4
0
 def test_sort(self):
     """Test sorted results."""
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertEqual(top['prefix'], 'en')
     self.assertIsInstance(top['total'], UnicodeType)
     self.assertEqual(ws.languages_by_size('wikipedia')[0], 'en')
     self.assertEqual(ws.languages_by_size('wikisource')[0], 'fr')
Ejemplo n.º 5
0
 def test_sort(self):
     """Test sorted results."""
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertEqual(top['prefix'], 'en')
     self.assertIsInstance(top['total'], UnicodeType)
     self.assertEqual(ws.languages_by_size('wikipedia')[0], 'en')
     self.assertEqual(ws.languages_by_size('wikisource')[0], 'fr')
Ejemplo n.º 6
0
 def test_sort_alphabetic(self):
     """Test alphabetic sorted results."""
     ws = WikiStats()
     for reverse in (True, False):
         last = ' ~'[reverse]  # first and last printable ASCII
         data = ws.sorted('wikisource', 'prefix', reverse=reverse)
         with self.subTest(reverse=reverse):
             for entry in data:
                 code = entry['prefix']
                 if reverse:
                     self.assertGreater(last, code)
                 else:
                     self.assertLess(last, code)
                 last = code
Ejemplo n.º 7
0
def main():

    ws = WikiStats()

    stats = ws.sorted('wikipedia', 'good')

    # rimuove mo.wikipedia.org redirect a ro.wikipedia.org

    stats = [stat for stat in stats if stat['prefix'] != 'mo']

    now = datetime.datetime.now()

    text = u'<!-- یہاں نئی زبان شامل کرنے سے قبل تبادلہ خیال صفحہ پر گفتگو کر لیں۔ -->\n<onlyinclude>{{#switch:{{{1}}}\n'

    text += '| data = %d %s %d\n' % (now.day, date.formats['MonthName']['ur'](
        now.month), now.year)

    total = {
        'good': 0,
        'images': 0,
        'total': 0,
        'users': 0,
        'activeusers': 0,
        'admins': 0,
        'edits': 0
    }

    for stat in stats:

        text += formatStat(stat)

        for key in total:

            total[key] += int(stat[key])

    total['prefix'] = 'total'

    text += formatStat(total)

    text += u'| 0 }}</onlyinclude>\n<noinclude>\n{{دستاویز}}\n</noinclude>\n'

    pywikibot.handleArgs()

    site = pywikibot.Site()

    page = pywikibot.Page(site, 'Template:NUMBEROF/data')

    page.put(text, 'خودکار: تجدید شماریات')
Ejemplo n.º 8
0
 def test_sort(self):
     """Test sorted results."""
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     bottom = data[-1]
     self.assertIn('good', top)
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertIn('good', bottom)
     self.assertIn('prefix', bottom)
     self.assertIn('total', bottom)
     self.assertIsInstance(top['good'], UnicodeType)
     self.assertTrue(all(isinstance(key, UnicodeType)
                         for key in top.keys()
                         if key is not None))
     self.assertIsInstance(top['total'], UnicodeType)
     self.assertIsInstance(bottom['good'], UnicodeType)
     self.assertIsInstance(bottom['total'], UnicodeType)
     self.assertGreater(int(top['total']), int(bottom['good']))
     self.assertGreater(int(top['good']), int(bottom['good']))
     self.assertGreater(int(top['total']), int(bottom['total']))
Ejemplo n.º 9
0
 def test_sort(self):
     """Test sorted results."""
     ws = WikiStats()
     data = ws.sorted('wikipedia', 'total')
     top = data[0]
     bottom = data[-1]
     self.assertIn('good', top)
     self.assertIn('prefix', top)
     self.assertIn('total', top)
     self.assertIn('good', bottom)
     self.assertIn('prefix', bottom)
     self.assertIn('total', bottom)
     self.assertIsInstance(top['good'], UnicodeType)
     self.assertTrue(
         all(
             isinstance(key, UnicodeType) for key in top.keys()
             if key is not None))
     self.assertIsInstance(top['total'], UnicodeType)
     self.assertIsInstance(bottom['good'], UnicodeType)
     self.assertIsInstance(bottom['total'], UnicodeType)
     self.assertGreater(int(top['total']), int(bottom['good']))
     self.assertGreater(int(top['good']), int(bottom['good']))
     self.assertGreater(int(top['total']), int(bottom['total']))